From 56c8ba4e4389b0593996737cd8a567ff01646503 Mon Sep 17 00:00:00 2001 From: Emruz Hossain Date: Sun, 11 Oct 2020 12:40:00 +0600 Subject: [PATCH] Fix smooth scroll for multi-language setup (#93) --- README.md | 50 +++++++------------ exampleSite/config.yaml | 3 +- exampleSite/data/bn/sections/about.yaml | 1 + .../data/bn/sections/achievements.yaml | 1 + exampleSite/data/bn/sections/experiences.yaml | 1 + exampleSite/data/bn/sections/projects.yaml | 1 + .../data/bn/sections/recent-posts.yaml | 1 + exampleSite/data/bn/sections/skills.yaml | 1 + exampleSite/data/en/sections/about.yaml | 1 + .../data/en/sections/achievements.yaml | 1 + exampleSite/data/en/sections/experiences.yaml | 1 + exampleSite/data/en/sections/projects.yaml | 1 + .../data/en/sections/recent-posts.yaml | 1 + exampleSite/data/en/sections/skills.yaml | 1 + exampleSite/data/fr/sections/about.yaml | 1 + .../data/fr/sections/achievements.yaml | 1 + exampleSite/data/fr/sections/experiences.yaml | 1 + exampleSite/data/fr/sections/projects.yaml | 1 + .../data/fr/sections/recent-posts.yaml | 1 + exampleSite/data/fr/sections/skills.yaml | 1 + layouts/partials/footer.html | 10 ++-- layouts/partials/navigators/navbar.html | 6 ++- layouts/partials/sections/about.html | 7 ++- layouts/partials/sections/achievements.html | 7 ++- layouts/partials/sections/experiences.html | 7 ++- layouts/partials/sections/home.html | 6 ++- layouts/partials/sections/projects.html | 7 ++- layouts/partials/sections/recent-posts.html | 7 ++- layouts/partials/sections/skills.html | 7 ++- static/assets/js/main.js | 2 + 30 files changed, 94 insertions(+), 43 deletions(-) diff --git a/README.md b/README.md index 0113569..ffb711c 100644 --- a/README.md +++ b/README.md @@ -54,6 +54,22 @@ languageCode: en-us title: "Toha" theme: "toha" +# Manage languages +# For any more details, you can check the official documentation: https://gohugo.io/content-management/multilingual/ +languages: + en: + languageName: English + weight: 1 + fr: + languageName: Français + weight: 2 + bn: + languageName: বাংলা + weight: 3 + +# Force a locale to be use, really useful to develop the application ! Should be commented in production, the "weight" should rocks. +# DefaultContentLanguage: fr + # Allow raw html in markdown file markup: goldmark: @@ -75,12 +91,6 @@ enableEmoji: true # Custom parameters params: - # Copyright Notice - copyright: © 2020 Copyright. - - # Meta description for your site. This will help the search engines to find your site. - description: Portfolio and personal blog of Jane Doe. - # background image of the landing page background: "images/background.jpg" @@ -88,8 +98,9 @@ params: # transparent navbar and the main logo will be used in the non-transparent navbar. # It will be default to the theme logos if not provided. logo: - main: /assets/images/main-logo.png - inverted: /assets/images/inverted-logo.png + main: assets/images/main-logo.png + inverted: assets/images/inverted-logo.png + favicon: assets/images/favicon.png # GitHub repo URL of your site gitRepo: https://github.com/hossainemruz/toha-example-site @@ -100,33 +111,10 @@ params: # specify whether you want to show Table of Contents in reading page enableTOC: true - # specify the list of custom menus that you want to show in the top navbar. - # they will be separated by a divider from the main menus. - customMenus: - - name: Notes - url: https://hossainnotes.netlify.app/docs/example/ - # Provide newsletter configuration. This feature hasn't been implemented yet. # Currently, you can just hide it from the footer. newsletter: enable: true - - # some information about you - author: - name: "Jane Doe" - nickname: "Jane" - image: "images/avatar.png" - # greeting message before your name. it will default to "Hi! I am" if not provided - greeting: "Hi, I am" - # give your some contact information. they will be used in the footer - contactInfo: - email: "janedoe@example.com" - phone: "+0123456789" - # a summary of what you do - summary: - - I am a Developer - - I work with Go - - I love to work with some fun projects ``` You can just copy the content for `config.yaml` files from `theme/toha/exampleSite/config.yaml`. diff --git a/exampleSite/config.yaml b/exampleSite/config.yaml index 784f6b7..ba2641e 100644 --- a/exampleSite/config.yaml +++ b/exampleSite/config.yaml @@ -15,8 +15,9 @@ languages: bn: languageName: বাংলা weight: 3 + # Force a locale to be use, really useful to develop the application ! Should be commented in production, the "weight" should rocks. -#DefaultContentLanguage: fr +# DefaultContentLanguage: fr # Allow raw html in markdown file markup: diff --git a/exampleSite/data/bn/sections/about.yaml b/exampleSite/data/bn/sections/about.yaml index e695107..04ef76d 100644 --- a/exampleSite/data/bn/sections/about.yaml +++ b/exampleSite/data/bn/sections/about.yaml @@ -1,6 +1,7 @@ # section information section: name: আমার-সম্পর্কে + id: about enable: true weight: 1 showOnNavbar: true diff --git a/exampleSite/data/bn/sections/achievements.yaml b/exampleSite/data/bn/sections/achievements.yaml index 0d20550..431c8f1 100644 --- a/exampleSite/data/bn/sections/achievements.yaml +++ b/exampleSite/data/bn/sections/achievements.yaml @@ -1,6 +1,7 @@ # section information section: name: সাফল্য + id: achievements enable: true weight: 6 showOnNavbar: true diff --git a/exampleSite/data/bn/sections/experiences.yaml b/exampleSite/data/bn/sections/experiences.yaml index f4ace28..62ec87b 100644 --- a/exampleSite/data/bn/sections/experiences.yaml +++ b/exampleSite/data/bn/sections/experiences.yaml @@ -1,6 +1,7 @@ # section information section: name: অভিজ্ঞতা + id: experiences enable: true weight: 3 showOnNavbar: true diff --git a/exampleSite/data/bn/sections/projects.yaml b/exampleSite/data/bn/sections/projects.yaml index 6e39f27..e15aad8 100644 --- a/exampleSite/data/bn/sections/projects.yaml +++ b/exampleSite/data/bn/sections/projects.yaml @@ -1,6 +1,7 @@ # section information section: name: প্রোজেক্ট + id: projects enable: true weight: 4 showOnNavbar: true diff --git a/exampleSite/data/bn/sections/recent-posts.yaml b/exampleSite/data/bn/sections/recent-posts.yaml index 4fd6f61..2477c86 100644 --- a/exampleSite/data/bn/sections/recent-posts.yaml +++ b/exampleSite/data/bn/sections/recent-posts.yaml @@ -1,6 +1,7 @@ # section information section: name: সাম্প্রতিক-পোস্ট + id: recent-posts enable: true weight: 5 showOnNavbar: true diff --git a/exampleSite/data/bn/sections/skills.yaml b/exampleSite/data/bn/sections/skills.yaml index 8e166be..6f39406 100644 --- a/exampleSite/data/bn/sections/skills.yaml +++ b/exampleSite/data/bn/sections/skills.yaml @@ -1,6 +1,7 @@ # section information section: name: দক্ষতা + id: skills enable: true weight: 2 showOnNavbar: true diff --git a/exampleSite/data/en/sections/about.yaml b/exampleSite/data/en/sections/about.yaml index 4ef5ee0..85d1312 100644 --- a/exampleSite/data/en/sections/about.yaml +++ b/exampleSite/data/en/sections/about.yaml @@ -1,6 +1,7 @@ # section information section: name: About + id: about enable: true weight: 1 showOnNavbar: true diff --git a/exampleSite/data/en/sections/achievements.yaml b/exampleSite/data/en/sections/achievements.yaml index a4b6838..a31cd80 100644 --- a/exampleSite/data/en/sections/achievements.yaml +++ b/exampleSite/data/en/sections/achievements.yaml @@ -1,6 +1,7 @@ # section information section: name: Achievements + id: achievements enable: true weight: 6 showOnNavbar: true diff --git a/exampleSite/data/en/sections/experiences.yaml b/exampleSite/data/en/sections/experiences.yaml index fb99079..6503753 100644 --- a/exampleSite/data/en/sections/experiences.yaml +++ b/exampleSite/data/en/sections/experiences.yaml @@ -1,6 +1,7 @@ # section information section: name: Experiences + id: experiences enable: true weight: 3 showOnNavbar: true diff --git a/exampleSite/data/en/sections/projects.yaml b/exampleSite/data/en/sections/projects.yaml index 618fa4e..34c2ec7 100644 --- a/exampleSite/data/en/sections/projects.yaml +++ b/exampleSite/data/en/sections/projects.yaml @@ -1,6 +1,7 @@ # section information section: name: Projects + id: projects enable: true weight: 4 showOnNavbar: true diff --git a/exampleSite/data/en/sections/recent-posts.yaml b/exampleSite/data/en/sections/recent-posts.yaml index f2a1977..520f3ff 100644 --- a/exampleSite/data/en/sections/recent-posts.yaml +++ b/exampleSite/data/en/sections/recent-posts.yaml @@ -1,6 +1,7 @@ # section information section: name: Recent Posts + id: recent-posts enable: true weight: 5 showOnNavbar: true diff --git a/exampleSite/data/en/sections/skills.yaml b/exampleSite/data/en/sections/skills.yaml index f5e05e6..5bd2190 100644 --- a/exampleSite/data/en/sections/skills.yaml +++ b/exampleSite/data/en/sections/skills.yaml @@ -1,6 +1,7 @@ # section information section: name: Skills + id: skills enable: true weight: 2 showOnNavbar: true diff --git a/exampleSite/data/fr/sections/about.yaml b/exampleSite/data/fr/sections/about.yaml index 0fc0f7d..f9c5d7b 100644 --- a/exampleSite/data/fr/sections/about.yaml +++ b/exampleSite/data/fr/sections/about.yaml @@ -1,6 +1,7 @@ # section information section: name: "A propos" + id: about enable: true weight: 1 showOnNavbar: true diff --git a/exampleSite/data/fr/sections/achievements.yaml b/exampleSite/data/fr/sections/achievements.yaml index baec23f..a357e37 100644 --- a/exampleSite/data/fr/sections/achievements.yaml +++ b/exampleSite/data/fr/sections/achievements.yaml @@ -1,6 +1,7 @@ # section information section: name: Realisations + id: achievements enable: true weight: 6 showOnNavbar: true diff --git a/exampleSite/data/fr/sections/experiences.yaml b/exampleSite/data/fr/sections/experiences.yaml index f9e82d2..a128135 100644 --- a/exampleSite/data/fr/sections/experiences.yaml +++ b/exampleSite/data/fr/sections/experiences.yaml @@ -1,6 +1,7 @@ # section information section: name: Experiences + id: experiences enable: true weight: 3 showOnNavbar: true diff --git a/exampleSite/data/fr/sections/projects.yaml b/exampleSite/data/fr/sections/projects.yaml index 6646421..7678964 100644 --- a/exampleSite/data/fr/sections/projects.yaml +++ b/exampleSite/data/fr/sections/projects.yaml @@ -1,6 +1,7 @@ # section information section: name: Projets + id: projects enable: true weight: 4 showOnNavbar: true diff --git a/exampleSite/data/fr/sections/recent-posts.yaml b/exampleSite/data/fr/sections/recent-posts.yaml index 0f26716..06ef589 100644 --- a/exampleSite/data/fr/sections/recent-posts.yaml +++ b/exampleSite/data/fr/sections/recent-posts.yaml @@ -1,6 +1,7 @@ # section information section: name: Posts recents + id: recent-posts enable: true weight: 5 showOnNavbar: true diff --git a/exampleSite/data/fr/sections/skills.yaml b/exampleSite/data/fr/sections/skills.yaml index 60b6fbe..91b5617 100644 --- a/exampleSite/data/fr/sections/skills.yaml +++ b/exampleSite/data/fr/sections/skills.yaml @@ -1,6 +1,7 @@ # section information section: name: Competences + id: skills enable: true weight: 2 showOnNavbar: true diff --git a/layouts/partials/footer.html b/layouts/partials/footer.html index 90cff75..d39f682 100644 --- a/layouts/partials/footer.html +++ b/layouts/partials/footer.html @@ -25,9 +25,13 @@ diff --git a/layouts/partials/navigators/navbar.html b/layouts/partials/navigators/navbar.html index f0575df..e947bf8 100644 --- a/layouts/partials/navigators/navbar.html +++ b/layouts/partials/navigators/navbar.html @@ -36,8 +36,12 @@ {{ if $sections }} {{ range sort $sections "section.weight" }} {{ if and (.section.enable) (.section.showOnNavbar)}} + {{ $sectionID := replace (lower .section.name) " " "-" }} + {{ if .section.id }} + {{ $sectionID = .section.id }} + {{ end }} {{ end }} {{- end }} diff --git a/layouts/partials/sections/about.html b/layouts/partials/sections/about.html index dcdf784..ea00d6b 100644 --- a/layouts/partials/sections/about.html +++ b/layouts/partials/sections/about.html @@ -1,4 +1,9 @@ -
+{{ $sectionID := replace (lower .section.name) " " "-" }} +{{ if .section.id }} + {{ $sectionID = .section.id }} +{{ end }} + +
diff --git a/layouts/partials/sections/achievements.html b/layouts/partials/sections/achievements.html index bd9a192..9744fc7 100644 --- a/layouts/partials/sections/achievements.html +++ b/layouts/partials/sections/achievements.html @@ -1,4 +1,9 @@ -
+{{ $sectionID := replace (lower .section.name) " " "-" }} +{{ if .section.id }} + {{ $sectionID = .section.id }} +{{ end }} + +
{{ if not (.section.hideTitle) }}

{{ .section.name }}

{{ end }} diff --git a/layouts/partials/sections/experiences.html b/layouts/partials/sections/experiences.html index 8d6b72f..c0c6ff8 100644 --- a/layouts/partials/sections/experiences.html +++ b/layouts/partials/sections/experiences.html @@ -1,4 +1,9 @@ -
+{{ $sectionID := replace (lower .section.name) " " "-" }} +{{ if .section.id }} + {{ $sectionID = .section.id }} +{{ end }} + +
{{ if not (.section.hideTitle) }}

{{ .section.name }}

{{ end }} diff --git a/layouts/partials/sections/home.html b/layouts/partials/sections/home.html index 4766a31..76715f7 100644 --- a/layouts/partials/sections/home.html +++ b/layouts/partials/sections/home.html @@ -48,7 +48,11 @@ {{ if $sections }} {{ range first 1 (where (sort $sections "section.weight") ".section.enable" true) }} - + {{ $sectionID := replace (lower .section.name) " " "-" }} + {{ if .section.id }} + {{ $sectionID = .section.id }} + {{ end }} + {{ end }} {{ end }}
diff --git a/layouts/partials/sections/projects.html b/layouts/partials/sections/projects.html index fc23c72..dd3ec39 100644 --- a/layouts/partials/sections/projects.html +++ b/layouts/partials/sections/projects.html @@ -1,4 +1,9 @@ -
+{{ $sectionID := replace (lower .section.name) " " "-" }} +{{ if .section.id }} + {{ $sectionID = .section.id }} +{{ end }} + +
{{ if not (.section.hideTitle) }}

{{ .section.name }}

{{ end }} diff --git a/layouts/partials/sections/recent-posts.html b/layouts/partials/sections/recent-posts.html index 2d0cc87..46387d2 100644 --- a/layouts/partials/sections/recent-posts.html +++ b/layouts/partials/sections/recent-posts.html @@ -1,4 +1,9 @@ -
+{{ $sectionID := replace (lower .section.name) " " "-" }} +{{ if .section.id }} + {{ $sectionID = .section.id }} +{{ end }} + +
{{ if not (.section.hideTitle) }}

{{ .section.name }}

{{ end }} diff --git a/layouts/partials/sections/skills.html b/layouts/partials/sections/skills.html index 8790be6..0bfb92b 100644 --- a/layouts/partials/sections/skills.html +++ b/layouts/partials/sections/skills.html @@ -1,4 +1,9 @@ -
+{{ $sectionID := replace (lower .section.name) " " "-" }} +{{ if .section.id }} + {{ $sectionID = .section.id }} +{{ end }} + +
{{ if not (.section.hideTitle) }}

{{ .section.name }}

{{ end }} diff --git a/static/assets/js/main.js b/static/assets/js/main.js index 1d468a8..c02f237 100644 --- a/static/assets/js/main.js +++ b/static/assets/js/main.js @@ -64,6 +64,8 @@ var isMobile = false, isTablet = false, isLaptop = false; $target.focus(); // Set focus again }; }); + // Add hash (#) to URL when done scrolling (default click behavior) + window.location.hash = this.hash } } });