From 47f7d8e3c634985b674f8894a1c111f473a6b4bd Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ma=C3=ABlle=20Salmon?= Date: Mon, 11 May 2020 16:37:17 +0200 Subject: [PATCH 1/9] start --- exampleSite/config.toml | 1 + exampleSite/content/kittens.md | 9 +++++++++ layouts/_default/baseof.html | 2 +- layouts/partials/site_languages.html | 12 ++++++++++++ 4 files changed, 23 insertions(+), 1 deletion(-) create mode 100644 layouts/partials/site_languages.html diff --git a/exampleSite/config.toml b/exampleSite/config.toml index 053b705..c0440ae 100644 --- a/exampleSite/config.toml +++ b/exampleSite/config.toml @@ -45,6 +45,7 @@ name = "Python" [[params.language_tabs]] key = "javascript" name = "Javascript" +otherlangs = "java" #Languages [languages] diff --git a/exampleSite/content/kittens.md b/exampleSite/content/kittens.md index f4d4a41..1463e24 100644 --- a/exampleSite/content/kittens.md +++ b/exampleSite/content/kittens.md @@ -38,6 +38,15 @@ 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'); diff --git a/layouts/_default/baseof.html b/layouts/_default/baseof.html index fdde37c..4df3bdb 100644 --- a/layouts/_default/baseof.html +++ b/layouts/_default/baseof.html @@ -9,7 +9,7 @@ {{ partial "js.html" . }} {{ partial "hook_head_end.html" . }} - + NAV diff --git a/layouts/partials/site_languages.html b/layouts/partials/site_languages.html new file mode 100644 index 0000000..4d32b33 --- /dev/null +++ b/layouts/partials/site_languages.html @@ -0,0 +1,12 @@ +{{ $string := "" }} +{{ with .Site.Params.language_tabs }} +{{ $scratch := newScratch }} + {{ range $i,$e := . }} + {{ $scratch.SetInMap "languages" $e.key ( printf " %q " $e.key ) }} + {{ if isset $e "otherlangs" }} + {{ $scratch.SetInMap "languages" $e.otherlangs ( printf " %q " $e.otherlangs ) }} + {{ end }} + {{ end }} + {{ $string = (delimit ($scratch.Get "languages") ", " )}} +{{ end }} +{{ return $string }} \ No newline at end of file From ac9fd9afad9d31b2c74f2f81dfc2095195ee4685 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ma=C3=ABlle=20Salmon?= Date: Mon, 11 May 2020 17:01:56 +0200 Subject: [PATCH 2/9] more --- layouts/_default/baseof.html | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/layouts/_default/baseof.html b/layouts/_default/baseof.html index 4df3bdb..18777a0 100644 --- a/layouts/_default/baseof.html +++ b/layouts/_default/baseof.html @@ -9,7 +9,7 @@ {{ partial "js.html" . }} {{ partial "hook_head_end.html" . }} - + NAV From cbca461109351539aeacef370c751927080b6959 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ma=C3=ABlle=20Salmon?= Date: Mon, 11 May 2020 17:11:51 +0200 Subject: [PATCH 3/9] does this work --- assets/js/slate/app/_lang.js | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/assets/js/slate/app/_lang.js b/assets/js/slate/app/_lang.js index 745ecba..e22dd6d 100644 --- a/assets/js/slate/app/_lang.js +++ b/assets/js/slate/app/_lang.js @@ -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 = JSON.parse(document.activeElement.getAttribute('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)) { From 38a713649a155c0d553b6fb88a2ed74b6ca80349 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ma=C3=ABlle=20Salmon?= Date: Mon, 11 May 2020 17:14:06 +0200 Subject: [PATCH 4/9] oops --- layouts/_default/baseof.html | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/layouts/_default/baseof.html b/layouts/_default/baseof.html index 18777a0..4dfe4e3 100644 --- a/layouts/_default/baseof.html +++ b/layouts/_default/baseof.html @@ -9,7 +9,7 @@ {{ partial "js.html" . }} {{ partial "hook_head_end.html" . }} - + NAV From 36037e44ceeecd165b1bcbdbd808149368789419 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ma=C3=ABlle=20Salmon?= Date: Mon, 11 May 2020 19:19:59 +0200 Subject: [PATCH 5/9] fix --- assets/js/slate/app/_lang.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/assets/js/slate/app/_lang.js b/assets/js/slate/app/_lang.js index e22dd6d..2b116c9 100644 --- a/assets/js/slate/app/_lang.js +++ b/assets/js/slate/app/_lang.js @@ -36,7 +36,7 @@ under the License. $(codeSelectorPrefix + languages[i]).parentsUntil(".highlight").hide(); $(".lang-specific." + languages[i]).hide(); } - var languagesToKeep = JSON.parse(document.activeElement.getAttribute('data-with' + language)); + 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(); From a2448d0900925ca62ac741de3c7987ef6bdfe6c3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ma=C3=ABlle=20Salmon?= Date: Tue, 12 May 2020 11:45:35 +0200 Subject: [PATCH 6/9] tweaks --- exampleSite/config.toml | 4 +++- exampleSite/content/kittens.md | 12 ++++++++++++ exampleSite/static/css/custom.css | 3 +++ layouts/_default/baseof.html | 2 +- layouts/partials/site_languages.html | 4 +++- layouts/partials/styles.html | 6 +++++- 6 files changed, 27 insertions(+), 4 deletions(-) create mode 100644 exampleSite/static/css/custom.css diff --git a/exampleSite/config.toml b/exampleSite/config.toml index c0440ae..de9c55a 100644 --- a/exampleSite/config.toml +++ b/exampleSite/config.toml @@ -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]] @@ -42,10 +43,11 @@ name = "Ruby" [[params.language_tabs]] key = "python" name = "Python" +otherlangs = ["xml", "r"] [[params.language_tabs]] key = "javascript" name = "Javascript" -otherlangs = "java" +otherlangs = ["java"] #Languages [languages] diff --git a/exampleSite/content/kittens.md b/exampleSite/content/kittens.md index 1463e24..363d41c 100644 --- a/exampleSite/content/kittens.md +++ b/exampleSite/content/kittens.md @@ -33,6 +33,18 @@ api = kittn.authorize('meowmeowmeow') api.kittens.get() ``` +```xml + +blablabla + +``` + +```r +library("kitten") +kt_authorize() +kt_get() +``` + ```shell curl "http://example.com/api/kittens" -H "Authorization: meowmeowmeow" diff --git a/exampleSite/static/css/custom.css b/exampleSite/static/css/custom.css new file mode 100644 index 0000000..bb0fc6f --- /dev/null +++ b/exampleSite/static/css/custom.css @@ -0,0 +1,3 @@ +.content pre { + margin-top: 10px; +} \ No newline at end of file diff --git a/layouts/_default/baseof.html b/layouts/_default/baseof.html index 4dfe4e3..34ae9de 100644 --- a/layouts/_default/baseof.html +++ b/layouts/_default/baseof.html @@ -9,7 +9,7 @@ {{ partial "js.html" . }} {{ partial "hook_head_end.html" . }} - + NAV diff --git a/layouts/partials/site_languages.html b/layouts/partials/site_languages.html index 4d32b33..967103b 100644 --- a/layouts/partials/site_languages.html +++ b/layouts/partials/site_languages.html @@ -4,7 +4,9 @@ {{ range $i,$e := . }} {{ $scratch.SetInMap "languages" $e.key ( printf " %q " $e.key ) }} {{ if isset $e "otherlangs" }} - {{ $scratch.SetInMap "languages" $e.otherlangs ( printf " %q " $e.otherlangs ) }} + {{ range $e.otherlangs }} + {{ $scratch.SetInMap "languages" . ( printf " %q " . ) }} + {{ end }} {{ end }} {{ end }} {{ $string = (delimit ($scratch.Get "languages") ", " )}} diff --git a/layouts/partials/styles.html b/layouts/partials/styles.html index 1f48c14..e5997fb 100644 --- a/layouts/partials/styles.html +++ b/layouts/partials/styles.html @@ -9,4 +9,8 @@ {{ end }} - +{{ with .Site.Params.custom_css }} + {{ range . }} + + {{ end }} + {{ end }} From f591e96eca32245f69fc8e13f344f4a80f23821e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ma=C3=ABlle=20Salmon?= Date: Tue, 12 May 2020 11:50:56 +0200 Subject: [PATCH 7/9] fix --- layouts/partials/styles.html | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/layouts/partials/styles.html b/layouts/partials/styles.html index e5997fb..112848a 100644 --- a/layouts/partials/styles.html +++ b/layouts/partials/styles.html @@ -11,6 +11,6 @@ {{ with .Site.Params.custom_css }} {{ range . }} - + {{ end }} {{ end }} From f63ba82951f694c0dc7271b171192aa3e838be9c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ma=C3=ABlle=20Salmon?= Date: Tue, 12 May 2020 11:53:42 +0200 Subject: [PATCH 8/9] actual fix --- layouts/partials/styles.html | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/layouts/partials/styles.html b/layouts/partials/styles.html index 112848a..4ef3ee0 100644 --- a/layouts/partials/styles.html +++ b/layouts/partials/styles.html @@ -11,6 +11,6 @@ {{ with .Site.Params.custom_css }} {{ range . }} - + {{ end }} {{ end }} From feb7fbb94a98b5f77a0dfd2c00cc3a54baea5d22 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ma=C3=ABlle=20Salmon?= Date: Tue, 12 May 2020 15:03:44 +0200 Subject: [PATCH 9/9] oops --- layouts/_default/baseof.html | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/layouts/_default/baseof.html b/layouts/_default/baseof.html index 34ae9de..1d26e43 100644 --- a/layouts/_default/baseof.html +++ b/layouts/_default/baseof.html @@ -9,7 +9,7 @@ {{ partial "js.html" . }} {{ partial "hook_head_end.html" . }} - + NAV