From 9859ea3f8bc35bcb4fa687f49ec521865f104f05 Mon Sep 17 00:00:00 2001 From: Jimmy Cai Date: Sat, 16 Oct 2021 09:53:44 +0200 Subject: [PATCH 01/10] feat: add theme config.yaml (#393) Add Hugo version requirement --- config.yaml | 4 ++++ theme.toml | 2 +- 2 files changed, 5 insertions(+), 1 deletion(-) create mode 100644 config.yaml diff --git a/config.yaml b/config.yaml new file mode 100644 index 0000000..a192dac --- /dev/null +++ b/config.yaml @@ -0,0 +1,4 @@ +module: + hugoVersion: + extended: true + min: "0.87.0" diff --git a/theme.toml b/theme.toml index 2b9b841..a1a3d74 100644 --- a/theme.toml +++ b/theme.toml @@ -20,7 +20,7 @@ features = [ "search", ] -min_version = "0.78.0" +min_version = "0.87.0" [author] name = "Jimmy Cai" From b3088be62dce87c2f6663700a2689ee308ce729b Mon Sep 17 00:00:00 2001 From: Jimmy Cai Date: Sat, 16 Oct 2021 10:14:06 +0200 Subject: [PATCH 02/10] feat: add default parameters to config.yaml (#394) This will avoid those ugly errors caused by forgetting to copy exampleSite/config.yaml to the site folder --- config.yaml | 143 ++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 143 insertions(+) diff --git a/config.yaml b/config.yaml index a192dac..0e5283c 100644 --- a/config.yaml +++ b/config.yaml @@ -2,3 +2,146 @@ module: hugoVersion: extended: true min: "0.87.0" + +params: + mainSections: + - post + featuredImageField: image + rssFullContent: true + favicon: + + footer: + since: + customText: + + dateFormat: + published: Jan 02, 2006 + lastUpdated: Jan 02, 2006 15:04 MST + + sidebar: + emoji: + subtitle: + avatar: + enabled: true + local: true + src: img/avatar.png + + article: + math: false + toc: true + readingTime: true + license: + enabled: false + default: Licensed under CC BY-NC-SA 4.0 + + comments: + enabled: false + provider: disqus + + disqusjs: + shortname: + apiUrl: + apiKey: + admin: + adminLabel: + + utterances: + repo: + issueTerm: pathname + label: + + remark42: + host: + site: + locale: + + vssue: + platform: + owner: + repo: + clientId: + clientSecret: + autoCreateIssue: false + + # Waline client configuration see: https://waline.js.org/en/reference/client.html + waline: + serverURL: + lang: + visitor: + avatar: + emoji: + - https://cdn.jsdelivr.net/gh/walinejs/emojis/weibo + requiredMeta: + - name + - email + - url + placeholder: + locale: + admin: Admin + + twikoo: + envId: + region: + path: + lang: + + giscus: + repo: + repoID: + category: + categoryID: + mapping: + lightTheme: + darkTheme: + reactionsEnabled: 1 + emitMetadata: 0 + + gitalk: + owner: + admin: + repo: + clientID: + clientSecret: + + cusdis: + host: + id: + + widgets: + enabled: + - search + - archives + - tag-cloud + + archives: + limit: 5 + + tagCloud: + limit: 10 + + opengraph: + twitter: + # Your Twitter username + site: + + # Available values: summary, summary_large_image + card: summary_large_image + + defaultImage: + opengraph: + enabled: false + local: false + src: + + colorScheme: + # Display toggle + toggle: true + + # Available values: auto, light, dark + default: auto + + imageProcessing: + cover: + enabled: true + content: + enabled: true From d04b3a8771386c9988be00adda53f0bf542cf269 Mon Sep 17 00:00:00 2001 From: MikDal002 Date: Sat, 16 Oct 2021 10:56:55 +0200 Subject: [PATCH 03/10] fix: appropriate back button and menu links for multi-language site (#386) --- layouts/_default/single.html | 2 +- layouts/partials/sidebar/left.html | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/layouts/_default/single.html b/layouts/_default/single.html index 902fa98..8b21c52 100644 --- a/layouts/_default/single.html +++ b/layouts/_default/single.html @@ -29,7 +29,7 @@ {{ define "left-sidebar" }} {{ if (.Scratch.Get "hasTOC") }}
- + {{ (resources.Get "icons/back.svg").Content | safeHTML }} {{ T "article.back" }} diff --git a/layouts/partials/sidebar/left.html b/layouts/partials/sidebar/left.html index c14092f..53a6655 100644 --- a/layouts/partials/sidebar/left.html +++ b/layouts/partials/sidebar/left.html @@ -29,7 +29,7 @@ {{ end }} {{ end }} -

{{ .Site.Title }}

+

{{ .Site.Title }}

{{ .Site.Params.sidebar.subtitle }}

@@ -39,7 +39,7 @@ {{ $active := or (eq $currentPage.Title .Name) (or ($currentPage.HasMenuCurrent "main" .) ($currentPage.IsMenuCurrent "main" .)) }}
  • - + {{ if .Pre }} {{ partial "helper/icon" .Pre }} {{ end }} From 30467ae65ca0cccf5c42dee24db3561674fee3ef Mon Sep 17 00:00:00 2001 From: Daniel Pessoa Date: Sat, 16 Oct 2021 06:10:25 -0300 Subject: [PATCH 04/10] feat(i18n): add missing pt-BR translations (#384) --- i18n/pt-BR.yaml | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/i18n/pt-BR.yaml b/i18n/pt-BR.yaml index 8240755..ffdbe41 100644 --- a/i18n/pt-BR.yaml +++ b/i18n/pt-BR.yaml @@ -17,11 +17,22 @@ list: other: Subseções article: + back: + other: Voltar + + tableOfContents: + other: Índice + relatedContents: - other: Conteúdos Relacionados + other: Conteúdo relacionado + lastUpdatedOn: other: Última atualização em + readingTime: + one: "{{ .Count }} minuto de leitura" + other: "{{ .Count }} minutos de leitura" + notFound: title: other: Não Encontrado From 913a4e8898a794fb646f8832170dcd4742f7a254 Mon Sep 17 00:00:00 2001 From: Ar-ruk Kachen Date: Sun, 17 Oct 2021 17:34:19 +0700 Subject: [PATCH 05/10] feat(i18n): Thai language (#396) --- exampleSite/config.yaml | 2 +- i18n/th.yaml | 70 +++++++++++++++++++++++++++++++++++++++++ 2 files changed, 71 insertions(+), 1 deletion(-) create mode 100644 i18n/th.yaml diff --git a/exampleSite/config.yaml b/exampleSite/config.yaml index dcf6c63..3064ca4 100644 --- a/exampleSite/config.yaml +++ b/exampleSite/config.yaml @@ -11,7 +11,7 @@ disqusShortname: hugo-theme-stack googleAnalytics: # Theme i18n support -# Available values: en, fr, id, ja, ko, pt-br, zh-cn, es, de, nl, it +# Available values: en, fr, id, ja, ko, pt-br, zh-cn, es, de, nl, it, th DefaultContentLanguage: en # Set hasCJKLanguage to true if DefaultContentLanguage is in [zh-cn ja ko] diff --git a/i18n/th.yaml b/i18n/th.yaml new file mode 100644 index 0000000..b2ae1cd --- /dev/null +++ b/i18n/th.yaml @@ -0,0 +1,70 @@ +toggleMenu: + other: สลับเมนู + +darkMode: + other: ธีมมืด + +list: + page: + one: "{{ .Count }} หน้า" + other: "{{ .Count }} หน้า" + + section: + other: หมวดหมู่ + + subsection: + one: หมวดหมู่ย่อย + other: หมวดหมู่ย่อยอื่นๆ + +article: + back: + other: กลับไป + + tableOfContents: + other: สารบัญ + + relatedContents: + other: เนื้อหาคล้ายคลึงกัน + + lastUpdatedOn: + other: อัปเดตล่าสุดเมื่อ + + readingTime: + one: "น่าจะใช้เวลา {{ .Count }} นาทีในการอ่าน" + other: "น่าจะใช้เวลา {{ .Count }} นาทีในการอ่าน" + +notFound: + title: + other: ไม่พบหัวข้อ + + subtitle: + other: ไม่พบหน้านี้ในระบบ + +widget: + archives: + title: + other: เนื้อหาที่เก็บถาวรแล้ว + + more: + other: อื่นๆ นอกจากนี้ + + tagCloud: + title: + other: แท็ก + +search: + title: + other: ค้นหา + + placeholder: + other: พิมพ์เพื่อค้นหา ... + + resultTitle: + other: "#PAGES_COUNT pages (#TIME_SECONDS seconds)" + +footer: + builtWith: + other: ถูกสร้างด้วย {{ .Generator }} + + designedBy: + other: ธีม {{ .Theme }} ออกแบบโดย {{ .DesignedBy }} From ca9dcc870d9421524acb68f8b0d7e94ed6b24c2a Mon Sep 17 00:00:00 2001 From: Christos Manios Date: Fri, 22 Oct 2021 17:12:44 +0300 Subject: [PATCH 06/10] feat(i18n): add Greek translation (#378) --- exampleSite/config.yaml | 2 +- i18n/el.yaml | 70 +++++++++++++++++++++++++++++++++++++++++ 2 files changed, 71 insertions(+), 1 deletion(-) create mode 100644 i18n/el.yaml diff --git a/exampleSite/config.yaml b/exampleSite/config.yaml index 3064ca4..a285296 100644 --- a/exampleSite/config.yaml +++ b/exampleSite/config.yaml @@ -11,7 +11,7 @@ disqusShortname: hugo-theme-stack googleAnalytics: # Theme i18n support -# Available values: en, fr, id, ja, ko, pt-br, zh-cn, es, de, nl, it, th +# Available values: en, fr, id, ja, ko, pt-br, zh-cn, es, de, nl, it, th, el DefaultContentLanguage: en # Set hasCJKLanguage to true if DefaultContentLanguage is in [zh-cn ja ko] diff --git a/i18n/el.yaml b/i18n/el.yaml new file mode 100644 index 0000000..38d867f --- /dev/null +++ b/i18n/el.yaml @@ -0,0 +1,70 @@ +toggleMenu: + other: Εναλλαγή Μενού + +darkMode: + other: Σκοτεινό θέμα + +list: + page: + one: "{{ .Count }} σελιδα" + other: "{{ .Count }} σελιδες" + + section: + other: Ενότητα + + subsection: + one: Υποενότητα + other: Υποενότητες + +article: + back: + other: Πισω + + tableOfContents: + other: Πινακας περιεχομενων + + relatedContents: + other: Σχετικο περιεχομενο + + lastUpdatedOn: + other: Τελευταια τροποποιηση στις + + readingTime: + one: "{{ .Count }} λεπτό ανάγνωσης" + ### Seems that there's no need to add 's' even if it's plural in English + other: "{{ .Count }} λεπτά ανάγνωσης" + +notFound: + title: + other: Δε βρέθηκε + subtitle: + other: Η σελίδα δε βρέθηκε. + +widget: + archives: + title: + other: Αρχειο + + more: + other: Περισσότερα + + tagCloud: + title: + other: Tags + +search: + title: + other: Αναζήτηση + + placeholder: + other: Πληκτρολογήστε κάτι... + + resultTitle: + other: "#PAGES_COUNT σελιδες (#TIME_SECONDS δευτερολεπτα)" + +footer: + builtWith: + other: Δημιουργήθηκε με τη χρήση {{ .Generator }} + + designedBy: + other: Το θέμα {{ .Theme }} σχεδιάστηκε από το {{ .DesignedBy }} From a822411a030663c8acaf399c349b7462da467d92 Mon Sep 17 00:00:00 2001 From: Jimmy Cai Date: Sat, 23 Oct 2021 06:51:56 +0000 Subject: [PATCH 07/10] chore: add Github Codespace config --- .devcontainer/Dockerfile | 31 +++++++++++++++++++++++ .devcontainer/devcontainer.json | 45 +++++++++++++++++++++++++++++++++ .gitignore | 3 +++ debug.sh | 1 + 4 files changed, 80 insertions(+) create mode 100644 .devcontainer/Dockerfile create mode 100644 .devcontainer/devcontainer.json create mode 100644 .gitignore create mode 100755 debug.sh diff --git a/.devcontainer/Dockerfile b/.devcontainer/Dockerfile new file mode 100644 index 0000000..b601136 --- /dev/null +++ b/.devcontainer/Dockerfile @@ -0,0 +1,31 @@ +# Update the NODE_VERSION arg in docker-compose.yml to pick a Node version: 10, 12, 14 +ARG NODE_VERSION=14 +FROM mcr.microsoft.com/vscode/devcontainers/javascript-node:0-${NODE_VERSION} + +# VARIANT can be either 'hugo' for the standard version or 'hugo_extended' for the extended version. +ARG VARIANT=hugo +# VERSION can be either 'latest' or a specific version number +ARG VERSION=latest + +# Download Hugo +RUN apt-get update && apt-get install -y ca-certificates openssl git curl && \ + rm -rf /var/lib/apt/lists/* && \ + case ${VERSION} in \ + latest) \ + export VERSION=$(curl -s https://api.github.com/repos/gohugoio/hugo/releases/latest | grep "tag_name" | awk '{print substr($2, 3, length($2)-4)}') ;;\ + esac && \ + echo ${VERSION} && \ + wget -O ${VERSION}.tar.gz https://github.com/gohugoio/hugo/releases/download/v${VERSION}/${VARIANT}_${VERSION}_Linux-64bit.tar.gz && \ + tar xf ${VERSION}.tar.gz && \ + mv hugo /usr/bin/hugo + +# Hugo dev server port +EXPOSE 1313 + +# [Optional] Uncomment this section to install additional OS packages you may want. +# +# RUN apt-get update && export DEBIAN_FRONTEND=noninteractive \ +# && apt-get -y install --no-install-recommends + +# [Optional] Uncomment if you want to install more global node packages +# RUN sudo -u node npm install -g diff --git a/.devcontainer/devcontainer.json b/.devcontainer/devcontainer.json new file mode 100644 index 0000000..4bf8a19 --- /dev/null +++ b/.devcontainer/devcontainer.json @@ -0,0 +1,45 @@ +// For format details, see https://aka.ms/devcontainer.json. For config options, see the README at: +// https://github.com/microsoft/vscode-dev-containers/tree/v0.202.3/containers/hugo +{ + "name": "Hugo (Community)", + "build": { + "dockerfile": "Dockerfile", + "args": { + // Update VARIANT to pick hugo variant. + // Example variants: hugo, hugo_extended + // Rebuild the container if it already exists to update. + "VARIANT": "hugo_extended", + // Update VERSION to pick a specific hugo version. + // Example versions: latest, 0.73.0, 0,71.1 + // Rebuild the container if it already exists to update. + "VERSION": "latest", + // Update NODE_VERSION to pick the Node.js version: 12, 14 + "NODE_VERSION": "14", + } + }, + + // Set *default* container specific settings.json values on container create. + "settings": { + "html.format.templating": true, + }, + + // Add the IDs of extensions you want installed when the container is created. + "extensions": [ + "bungcip.better-toml", + "davidanson.vscode-markdownlint" + ], + + // Use 'forwardPorts' to make a list of ports inside the container available locally. + "forwardPorts": [ + 1313 + ], + + // Use 'postCreateCommand' to run commands after the container is created. + // "postCreateCommand": "uname -a", + + // Comment out connect as root instead. More info: https://aka.ms/vscode-remote/containers/non-root. + "remoteUser": "node", + "features": { + "golang": "latest" + } +} diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..9ebefdf --- /dev/null +++ b/.gitignore @@ -0,0 +1,3 @@ +public +resources +assets/jsconfig.json \ No newline at end of file diff --git a/debug.sh b/debug.sh new file mode 100755 index 0000000..4d1312e --- /dev/null +++ b/debug.sh @@ -0,0 +1 @@ +cd exampleSite && hugo server --gc --themesDir=../.. \ No newline at end of file From 7c59ac77137a9bbf2d9b4430aeca7006fb044da0 Mon Sep 17 00:00:00 2001 From: Jimmy Cai Date: Sat, 23 Oct 2021 09:18:44 +0200 Subject: [PATCH 08/10] refactor(menu): use .Params.icon to configure menu item icon (#400) --- exampleSite/config.yaml | 2 +- exampleSite/content/page/about.md | 3 ++- exampleSite/content/page/archives.md | 3 ++- exampleSite/content/page/search.md | 3 ++- layouts/partials/sidebar/left.html | 6 +++++- 5 files changed, 12 insertions(+), 5 deletions(-) diff --git a/exampleSite/config.yaml b/exampleSite/config.yaml index a285296..d5cf58d 100644 --- a/exampleSite/config.yaml +++ b/exampleSite/config.yaml @@ -174,10 +174,10 @@ menu: name: Home url: / weight: -100 - pre: home params: ### For demonstration purpose, the home link will be open in a new tab newTab: true + icon: home related: includeNewer: true diff --git a/exampleSite/content/page/about.md b/exampleSite/content/page/about.md index 79898de..494cb46 100644 --- a/exampleSite/content/page/about.md +++ b/exampleSite/content/page/about.md @@ -11,7 +11,8 @@ lastmod: '2020-10-09' menu: main: weight: -90 - pre: user + params: + icon: user --- Written in Go, Hugo is an open source static site generator available under the [Apache Licence 2.0.](https://github.com/gohugoio/hugo/blob/master/LICENSE) Hugo supports TOML, YAML and JSON data file types, Markdown and HTML content files and uses shortcodes to add rich content. Other notable features are taxonomies, multilingual mode, image processing, custom output formats, HTML/CSS/JS minification and support for Sass SCSS workflows. diff --git a/exampleSite/content/page/archives.md b/exampleSite/content/page/archives.md index 027dfc6..2862deb 100644 --- a/exampleSite/content/page/archives.md +++ b/exampleSite/content/page/archives.md @@ -6,5 +6,6 @@ slug: "archives" menu: main: weight: -70 - pre: archives + params: + icon: archives --- diff --git a/exampleSite/content/page/search.md b/exampleSite/content/page/search.md index f54cdb5..b2a5943 100644 --- a/exampleSite/content/page/search.md +++ b/exampleSite/content/page/search.md @@ -8,5 +8,6 @@ outputs: menu: main: weight: -60 - pre: search + params: + icon: search --- \ No newline at end of file diff --git a/layouts/partials/sidebar/left.html b/layouts/partials/sidebar/left.html index 53a6655..9d4dd3e 100644 --- a/layouts/partials/sidebar/left.html +++ b/layouts/partials/sidebar/left.html @@ -40,8 +40,12 @@
  • + {{ $icon := default .Pre .Params.Icon }} {{ if .Pre }} - {{ partial "helper/icon" .Pre }} + {{ warnf "Menu item [%s] is using [pre] field to set icon, please use [params.icon] instead.\nMore information: https://docs.stack.jimmycai.com/configuration/custom-menu.html" .URL }} + {{ end }} + {{ with $icon }} + {{ partial "helper/icon" . }} {{ end }} {{- .Name -}} From 661e59b85d6761905da906018a26120a0b45ef5e Mon Sep 17 00:00:00 2001 From: Jimmy Cai Date: Sat, 23 Oct 2021 11:58:55 +0200 Subject: [PATCH 09/10] feat: social menu (#401) --- assets/icons/brand-github.svg | 6 ++++++ assets/icons/brand-twitter.svg | 6 ++++++ assets/scss/partials/menu.scss | 15 +++++++++++++++ exampleSite/config.yaml | 13 +++++++++++++ layouts/partials/sidebar/left.html | 20 ++++++++++++++++++++ 5 files changed, 60 insertions(+) create mode 100644 assets/icons/brand-github.svg create mode 100644 assets/icons/brand-twitter.svg diff --git a/assets/icons/brand-github.svg b/assets/icons/brand-github.svg new file mode 100644 index 0000000..1fe7e0b --- /dev/null +++ b/assets/icons/brand-github.svg @@ -0,0 +1,6 @@ + + + + + + diff --git a/assets/icons/brand-twitter.svg b/assets/icons/brand-twitter.svg new file mode 100644 index 0000000..17ab1b1 --- /dev/null +++ b/assets/icons/brand-twitter.svg @@ -0,0 +1,6 @@ + + + + + + diff --git a/assets/scss/partials/menu.scss b/assets/scss/partials/menu.scss index 2c7ad74..1d612d1 100644 --- a/assets/scss/partials/menu.scss +++ b/assets/scss/partials/menu.scss @@ -201,3 +201,18 @@ } } } + +.social-menu { + list-style: none; + padding: 0%; + display: flex; + flex-direction: row; + gap: 10px; + + svg { + width: 24px; + height: 24px; + stroke: var(--body-text-color); + stroke-width: 1.33; + } +} diff --git a/exampleSite/config.yaml b/exampleSite/config.yaml index d5cf58d..db3a8a9 100644 --- a/exampleSite/config.yaml +++ b/exampleSite/config.yaml @@ -178,6 +178,19 @@ menu: ### For demonstration purpose, the home link will be open in a new tab newTab: true icon: home + + social: + - identifier: github + name: GitHub + url: https://github.com/CaiJimmy/hugo-theme-stack + params: + icon: brand-github + + - identifier: twitter + name: Twitter + url: https://twitter.com + params: + icon: brand-twitter related: includeNewer: true diff --git a/layouts/partials/sidebar/left.html b/layouts/partials/sidebar/left.html index 9d4dd3e..108c029 100644 --- a/layouts/partials/sidebar/left.html +++ b/layouts/partials/sidebar/left.html @@ -29,8 +29,28 @@ {{ end }} {{ end }} +

    {{ .Site.Title }}

    {{ .Site.Params.sidebar.subtitle }}

    + + {{- with .Site.Menus.social -}} + + {{- end -}}