Skip to content

Commit

Permalink
Front-matter 'polyglot' param for polyglot pages. Closes cucumber#8
Browse files Browse the repository at this point in the history
  • Loading branch information
aslakhellesoy committed Jul 20, 2017
1 parent 31ad4ba commit 2728a48
Show file tree
Hide file tree
Showing 6 changed files with 65 additions and 25 deletions.
39 changes: 39 additions & 0 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,3 +13,42 @@ body - do not use `#` headers as we only want a single `h1` header per page.
Start the body with a paragraph, not a header. If you start with a header, the
top of the page will have a `h1` followed immediately by a `h2`, which does not
look good.

## Polyglot pages

All pages with source code should be polyglot, meaning there should be source code
for all supported programming languages. See `themes/cucumber-hugo/layouts/partials/language-tabs.html`
for a list of supported languages.

The front-matter should also declare that this is a polyglot page so that the
programming language tabs are displayed at the top of the page:

```yaml
polyglot: true
```

When a tab is selected, only source code and language-specific text for the selected
language will be displayed.

### Source code

Use fenced code blocks to specify polyglot source code:

```ruby
puts "hello"
```

```javascript
console.log("hello")
```

```java
System.out.println("hello")
```

### Language-specific text

Use the `{{% text %}}` shortcode around text that should only be displayed for
a particular programming language:

The preferred build tool is {{% text "java" %}}Rake{{% /text %}}{{% text "java" %}}Yarn{{% /text %}}{{% text "java" %}}Maven{{% /text %}}.
1 change: 1 addition & 0 deletions content/cucumber/Step-Definitions-Orig.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
---
menu: gherkin
title: Step Definitions Orig
polyglot: true
---

When Cucumber executes a step in a scenario it will look for a matching *step definition* to execute.
Expand Down
1 change: 0 additions & 1 deletion themes/cucumber-hugo/layouts/_default/single.html
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
{{ partial "header.html" . }}
{{ partial "nav.html" . }}
{{ partial "language-nav.html" . }}
{{ partial "menu-content" . }}
{{ partial "footer.html" . }}
24 changes: 0 additions & 24 deletions themes/cucumber-hugo/layouts/partials/language-nav.html

This file was deleted.

22 changes: 22 additions & 0 deletions themes/cucumber-hugo/layouts/partials/language-tabs.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
<div class="tabs is-boxed is-right">
<ul>
<li data-language="java">
<a>
<span class="icon is-small"><i class="devicon-java-plain colored"></i></span>
<span>Java</span>
</a>
</li>
<li data-language="javascript">
<a>
<span class="icon is-small"><i class="devicon-javascript-plain colored"></i></span>
<span>JavaScript</span>
</a>
</li>
<li data-language="ruby">
<a>
<span class="icon is-small"><i class="devicon-ruby-plain colored"></i></span>
<span>Ruby</span>
</a>
</li>
</ul>
</div>
3 changes: 3 additions & 0 deletions themes/cucumber-hugo/layouts/partials/menu-content.html
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,9 @@
{{ partial "menu.html" . }}
</div>
<div class="column is-three-quarters">
{{ if eq .Page.Params.polyglot true }}
{{ partial "language-tabs.html" . }}
{{ end }}
<div class="content">
<h1>{{ .Title }}</h1>
{{ .Content }}
Expand Down

0 comments on commit 2728a48

Please sign in to comment.