From 36ee9b9f97211f4b5c1eee9284df71fdd47ffbef Mon Sep 17 00:00:00 2001 From: toshimaru Date: Sun, 6 Jun 2021 14:08:33 +0900 Subject: [PATCH 1/5] load sidemenu navigation via jQuery.load --- src/_layouts/default.html | 3 +-- src/assets/js/app.js | 18 ++++++++++-------- src/navigation.html | 1 + 3 files changed, 12 insertions(+), 10 deletions(-) create mode 100644 src/navigation.html diff --git a/src/_layouts/default.html b/src/_layouts/default.html index 7f64a4c464..b8ef286fc0 100644 --- a/src/_layouts/default.html +++ b/src/_layouts/default.html @@ -49,8 +49,7 @@
diff --git a/src/assets/js/app.js b/src/assets/js/app.js index b90ac0b2a6..ad0ef33884 100644 --- a/src/assets/js/app.js +++ b/src/assets/js/app.js @@ -6,12 +6,14 @@ $(() => { // highlight.js hljs.highlightAll(); - $(".sidebar-sticky .icon").on("click", function (e) { - $(this).siblings("ul").toggle(); - this.classList.toggle("icon-opened"); - }); - $(`.sidebar-content a[href='${window.location.pathname}']`) - .attr("class", "active-link") - .parents('ul') - .show(); + $("#navigation").load("/navigation.html", function() { + $(".sidebar-sticky .icon").on("click", function (e) { + $(this).siblings("ul").toggle(); + this.classList.toggle("icon-opened"); + }); + $(`.sidebar-content a[href='${window.location.pathname}']`) + .attr("class", "active-link") + .parents('ul') + .show(); + }) }); diff --git a/src/navigation.html b/src/navigation.html new file mode 100644 index 0000000000..5164d7d61a --- /dev/null +++ b/src/navigation.html @@ -0,0 +1 @@ + \ No newline at end of file From 860bd986f452527133ec3d52e3a8b16b1d98bda2 Mon Sep 17 00:00:00 2001 From: toshimaru Date: Sun, 6 Jun 2021 15:08:53 +0900 Subject: [PATCH 2/5] Set rootPath for JavaScript --- _config.yml | 3 +++ src/_layouts/default.html | 4 ++++ 2 files changed, 7 insertions(+) diff --git a/_config.yml b/_config.yml index b65ee5a08e..a389e870de 100644 --- a/_config.yml +++ b/_config.yml @@ -25,11 +25,14 @@ defaults: version: 6.1 image: https://avatars.githubusercontent.com/u/4223 toc: true + root_path: '/' - scope: path: "6.0" values: version: 6.0 + root_path: '/6.0/' - scope: path: "5.2" values: version: 5.2 + root_path: '/5.2/' diff --git a/src/_layouts/default.html b/src/_layouts/default.html index b8ef286fc0..702f11a3a4 100644 --- a/src/_layouts/default.html +++ b/src/_layouts/default.html @@ -18,6 +18,10 @@ gtag('js', new Date()); gtag('config', 'UA-134470810-1'); + + window.config = { + rootPath: "{{ page.root_path }}" + } From 7928b0f2189ea48920f7bbf735597a61c5bea093 Mon Sep 17 00:00:00 2001 From: toshimaru Date: Sun, 6 Jun 2021 15:24:25 +0900 Subject: [PATCH 3/5] Generate new navigation.html for JS --- Rakefile | 14 +++++--------- 1 file changed, 5 insertions(+), 9 deletions(-) diff --git a/Rakefile b/Rakefile index d237dfe74d..65410062e8 100644 --- a/Rakefile +++ b/Rakefile @@ -66,15 +66,11 @@ def generate_src(target_version: nil) cd target_dir do cp INDEX_HTML, 'index.html' - if target_version.nil? - mv 'navigation.html', '_includes/navigation.html', force: true - else - # Replace absolute path in navigation.html - content = File.read("navigation.html") - content.gsub!(" Date: Sun, 6 Jun 2021 15:26:15 +0900 Subject: [PATCH 4/5] Generate single navigations for each Rails version Single navigation.html instead of _includes/navigation.html --- src/{_includes/navigation5.2.html => 5.2/navigation.html} | 0 src/6.0/navigation.html | 1 + src/_includes/.keep | 0 src/_includes/navigation.html | 1 - src/_includes/navigation6.0.html | 1 - src/_includes/navigation6.1.html | 1 - 6 files changed, 1 insertion(+), 3 deletions(-) rename src/{_includes/navigation5.2.html => 5.2/navigation.html} (100%) create mode 100644 src/6.0/navigation.html create mode 100644 src/_includes/.keep delete mode 100644 src/_includes/navigation.html delete mode 100644 src/_includes/navigation6.0.html delete mode 120000 src/_includes/navigation6.1.html diff --git a/src/_includes/navigation5.2.html b/src/5.2/navigation.html similarity index 100% rename from src/_includes/navigation5.2.html rename to src/5.2/navigation.html diff --git a/src/6.0/navigation.html b/src/6.0/navigation.html new file mode 100644 index 0000000000..60c05cef40 --- /dev/null +++ b/src/6.0/navigation.html @@ -0,0 +1 @@ + \ No newline at end of file diff --git a/src/_includes/.keep b/src/_includes/.keep new file mode 100644 index 0000000000..e69de29bb2 diff --git a/src/_includes/navigation.html b/src/_includes/navigation.html deleted file mode 100644 index 1289db0c60..0000000000 --- a/src/_includes/navigation.html +++ /dev/null @@ -1 +0,0 @@ - \ No newline at end of file diff --git a/src/_includes/navigation6.0.html b/src/_includes/navigation6.0.html deleted file mode 100644 index 50c265e012..0000000000 --- a/src/_includes/navigation6.0.html +++ /dev/null @@ -1 +0,0 @@ - \ No newline at end of file diff --git a/src/_includes/navigation6.1.html b/src/_includes/navigation6.1.html deleted file mode 120000 index 48c4e92d5e..0000000000 --- a/src/_includes/navigation6.1.html +++ /dev/null @@ -1 +0,0 @@ -navigation.html \ No newline at end of file From a443925ab271d0581a3145e34f6255e57de5ac0c Mon Sep 17 00:00:00 2001 From: toshimaru Date: Sun, 6 Jun 2021 15:26:25 +0900 Subject: [PATCH 5/5] load each navigations --- src/assets/js/app.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/assets/js/app.js b/src/assets/js/app.js index ad0ef33884..90c5f5243f 100644 --- a/src/assets/js/app.js +++ b/src/assets/js/app.js @@ -6,7 +6,7 @@ $(() => { // highlight.js hljs.highlightAll(); - $("#navigation").load("/navigation.html", function() { + $("#navigation").load(`${config.rootPath}navigation.html`, function() { $(".sidebar-sticky .icon").on("click", function (e) { $(this).siblings("ul").toggle(); this.classList.toggle("icon-opened");