Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 5 additions & 2 deletions assets/js/slate/app/_lang.js
Original file line number Diff line number Diff line change
Expand Up @@ -36,8 +36,11 @@ under the License.
$(codeSelectorPrefix + languages[i]).parentsUntil(".highlight").hide();
$(".lang-specific." + languages[i]).hide();
}
$(codeSelectorPrefix + language).parentsUntil(".highlight").show();
$(".lang-specific." + language).parentsUntil(".highlight").show();
var languagesToKeep = $( "body").data('with' + language);
for (var i=0; i < languagesToKeep.length; i++) {
$(codeSelectorPrefix + languagesToKeep[i]).parentsUntil(".highlight").show();
$(".lang-specific." + languagesToKeep[i]).parentsUntil(".highlight").show();
}

// scroll to the new location of the position
if ($(window.location.hash).get(0)) {
Expand Down
3 changes: 3 additions & 0 deletions exampleSite/config.toml
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ path="github.com/bep/empty-hugo-module"

[params]
search = true
custom_css = ["css/custom.css"]

# Configure the language example tabs.
[[params.language_tabs]]
Expand All @@ -42,9 +43,11 @@ name = "Ruby"
[[params.language_tabs]]
key = "python"
name = "Python"
otherlangs = ["xml", "r"]
[[params.language_tabs]]
key = "javascript"
name = "Javascript"
otherlangs = ["java"]

#Languages
[languages]
Expand Down
21 changes: 21 additions & 0 deletions exampleSite/content/kittens.md
Original file line number Diff line number Diff line change
Expand Up @@ -33,11 +33,32 @@ api = kittn.authorize('meowmeowmeow')
api.kittens.get()
```

```xml
<example>
blablabla
</example>
```

```r
library("kitten")
kt_authorize()
kt_get()
```

```shell
curl "http://example.com/api/kittens"
-H "Authorization: meowmeowmeow"
```

```java
public class MyClass {
public static void main(String[] args) {
System.out.println("Hello World");
}
}

```

```javascript
const kittn = require('kittn');

Expand Down
3 changes: 3 additions & 0 deletions exampleSite/static/css/custom.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
.content pre {
margin-top: 10px;
}
2 changes: 1 addition & 1 deletion layouts/_default/baseof.html
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
{{ partial "js.html" . }}
{{ partial "hook_head_end.html" . }}
</head>
<body class="index" data-languages="{{ with .Site.Params.language_tabs }}[{{ range $i,$e := . }}{{- if $i -}}, {{ end -}}{{ printf " %q " $e.key }}{{end}}]{{ end }}">
<body class="index" data-languages='[{{ partial "site_languages.html" . }}]' {{ with .Site.Params.language_tabs }}{{ range $i,$e := . }} data-with{{ $e.key }}='[{{ printf " %q " $e.key }}{{ if isset $e "otherlangs" }}{{ range $e.otherlangs }}, {{ printf " %q " . }}{{ end }}{{ end }}]'{{ end }}{{ end }}>
<a href="#" id="nav-button">
<span>
NAV
Expand Down
14 changes: 14 additions & 0 deletions layouts/partials/site_languages.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
{{ $string := "" }}
{{ with .Site.Params.language_tabs }}
{{ $scratch := newScratch }}
{{ range $i,$e := . }}
{{ $scratch.SetInMap "languages" $e.key ( printf " %q " $e.key ) }}
{{ if isset $e "otherlangs" }}
{{ range $e.otherlangs }}
{{ $scratch.SetInMap "languages" . ( printf " %q " . ) }}
{{ end }}
{{ end }}
{{ end }}
{{ $string = (delimit ($scratch.Get "languages") ", " )}}
{{ end }}
{{ return $string }}
6 changes: 5 additions & 1 deletion layouts/partials/styles.html
Original file line number Diff line number Diff line change
Expand Up @@ -9,4 +9,8 @@
{{ end }}
<link href='{{ $screenCSS.RelPermalink }}' rel="stylesheet" media="screen" {{ if not $isDev }}integrity="{{ $screenCSS.Data.Integrity }}"{{ end }} />
<link href='{{ $printCSS.RelPermalink }}' rel="stylesheet" media="print" {{ if not $isDev }}integrity="{{ $printCSS.Data.Integrity }}"{{ end }} />

{{ with .Site.Params.custom_css }}
{{ range . }}
<link rel="stylesheet" href="/{{ . }}">
{{ end }}
{{ end }}