From 70cc14fcbe9e229fef7dc2c6a861f1bd6d3c647e Mon Sep 17 00:00:00 2001 From: Jimmy Cai Date: Thu, 7 Jan 2021 11:28:16 +0100 Subject: [PATCH 1/8] feat(list): display subsections in list style when there are no normal pages (#121) closes https://github.com/CaiJimmy/hugo-theme-stack/issues/116 --- layouts/_default/list.html | 17 +++++++++++++---- 1 file changed, 13 insertions(+), 4 deletions(-) diff --git a/layouts/_default/list.html b/layouts/_default/list.html index b4efb67..90e5b66 100644 --- a/layouts/_default/list.html +++ b/layouts/_default/list.html @@ -42,8 +42,17 @@ {{ end }} - {{ $subsections := .Sections }} - {{ with $subsections }} + {{- $subsections := .Sections -}} + {{- $pages := .Pages | complement $subsections -}} + + {{- if eq (len $pages) 0 -}} + {{/* If there are no normal pages, display subsections in list style, with pagination */}} + {{/* This happens with taxonomies like categories or tags */}} + {{- $pages = $subsections -}} + {{- $subsections = slice -}} + {{- end -}} + + {{- with $subsections -}}

{{ T "list.subsection" (len $subsections) }}

@@ -52,10 +61,10 @@ {{ end }}
- {{ end }} + {{- end -}} {{/* List only pages that are not a subsection */}} - {{ $paginator := .Paginate (.Pages | complement $subsections) }} + {{ $paginator := .Paginate $pages }}
{{ range $paginator.Pages }} {{ partial "article-list/compact" . }} From a8718592dfce06452ffd66dc544777e71b4a2782 Mon Sep 17 00:00:00 2001 From: Jimmy Cai Date: Thu, 11 Feb 2021 18:46:23 +0100 Subject: [PATCH 2/8] fix(utterances): set color scheme on load (#138) * fix(utterances): set color scheme on load Remove utterances.theme option from config.yaml * fix(utterances): restore async tag --- exampleSite/config.yaml | 1 - .../comments/provider/utterances.html | 19 ++++++++++++++----- 2 files changed, 14 insertions(+), 6 deletions(-) diff --git a/exampleSite/config.yaml b/exampleSite/config.yaml index fb89f51..515c97c 100644 --- a/exampleSite/config.yaml +++ b/exampleSite/config.yaml @@ -50,7 +50,6 @@ params: repo: issueTerm: pathname label: - theme: preferred-color-scheme widgets: enabled: diff --git a/layouts/partials/comments/provider/utterances.html b/layouts/partials/comments/provider/utterances.html index e2ecf6d..a0c07a6 100644 --- a/layouts/partials/comments/provider/utterances.html +++ b/layouts/partials/comments/provider/utterances.html @@ -1,12 +1,12 @@ \ No newline at end of file From 83e3a4e8e16d395b929e89b449e10f208de3e0a3 Mon Sep 17 00:00:00 2001 From: Julian Alarcon Date: Thu, 11 Feb 2021 12:56:39 -0500 Subject: [PATCH 3/8] feat: Google Analytics support (#135) * Added Google Analytics feature * style: load GA script before head/custom * style(config): googleAnalytics field empty by default Co-authored-by: Jimmy Cai --- exampleSite/config.yaml | 3 +++ layouts/partials/head/head.html | 3 ++- 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/exampleSite/config.yaml b/exampleSite/config.yaml index 515c97c..438984a 100644 --- a/exampleSite/config.yaml +++ b/exampleSite/config.yaml @@ -7,6 +7,9 @@ title: Example Site # Change it to your Disqus shortname before using disqusShortname: hugo-theme-stack +# GA Tracking ID +googleAnalytics: + # Theme i18n support # Available values: en, fr, id, ja, ko, pt-br, zh-cn DefaultContentLanguage: en diff --git a/layouts/partials/head/head.html b/layouts/partials/head/head.html index de2982c..fd9ef73 100644 --- a/layouts/partials/head/head.html +++ b/layouts/partials/head/head.html @@ -21,4 +21,5 @@ {{ end }} -{{- partial "head/custom.html" . -}} \ No newline at end of file +{{- template "_internal/google_analytics_async.html" . -}} +{{- partial "head/custom.html" . -}} From a37ebbe2aa463da68b23b858592939027648a550 Mon Sep 17 00:00:00 2001 From: Akatsuki Rui <3736910+akiirui@users.noreply.github.com> Date: Fri, 12 Feb 2021 02:00:59 +0800 Subject: [PATCH 4/8] assets: fix font-family fallback (#130) If not have monospace, fonts will fallback to sans-serif when these fonts not available. --- assets/scss/variables.scss | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/assets/scss/variables.scss b/assets/scss/variables.scss index 3a8a1a5..cba32e5 100644 --- a/assets/scss/variables.scss +++ b/assets/scss/variables.scss @@ -52,8 +52,8 @@ $defaultTagColors: #fff, #fff, #fff, #fff, #fff; --sys-font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "Droid Sans", "Helvetica Neue"; --zh-font-family: "PingFang SC", "Hiragino Sans GB", "Droid Sans Fallback", "Microsoft YaHei"; - --base-font-family: "Lato", var(--sys-font-family), var(--zh-font-family); - --code-font-family: Menlo, Monaco, Consolas, "Courier New"; + --base-font-family: "Lato", var(--sys-font-family), var(--zh-font-family), sans-serif; + --code-font-family: Menlo, Monaco, Consolas, "Courier New", monospace; } /* From 9914bba42c520b279c41f448b9d3c8dd0e8ae6db Mon Sep 17 00:00:00 2001 From: Junwoo Hwang Date: Fri, 12 Feb 2021 03:05:12 +0900 Subject: [PATCH 5/8] fix: remove word-wrap property for Safari (#131) --- assets/scss/partials/layout/article.scss | 1 - 1 file changed, 1 deletion(-) diff --git a/assets/scss/partials/layout/article.scss b/assets/scss/partials/layout/article.scss index 4b3beca..361e691 100644 --- a/assets/scss/partials/layout/article.scss +++ b/assets/scss/partials/layout/article.scss @@ -244,7 +244,6 @@ padding: 2px 4px; border-radius: var(--tag-border-radius); font-family: var(--code-font-family); - word-wrap: break-word; } .gallery { From 326c052a24063aaa9503f7e35f7580c476da1635 Mon Sep 17 00:00:00 2001 From: Jimmy Cai Date: Thu, 11 Feb 2021 21:22:02 +0100 Subject: [PATCH 6/8] fix(article): code background (#139) closes https://github.com/CaiJimmy/hugo-theme-stack/issues/126 --- assets/scss/partials/highlight/dark.scss | 3 +-- assets/scss/partials/highlight/light.scss | 1 - 2 files changed, 1 insertion(+), 3 deletions(-) diff --git a/assets/scss/partials/highlight/dark.scss b/assets/scss/partials/highlight/dark.scss index 00e8942..2c13946 100644 --- a/assets/scss/partials/highlight/dark.scss +++ b/assets/scss/partials/highlight/dark.scss @@ -14,8 +14,7 @@ /* Error */ .chroma .err { - color: #960050; - background-color: #1e0010 + color: #bb0064; } /* LineTableTD */ diff --git a/assets/scss/partials/highlight/light.scss b/assets/scss/partials/highlight/light.scss index 7ac7d71..9ddcff9 100644 --- a/assets/scss/partials/highlight/light.scss +++ b/assets/scss/partials/highlight/light.scss @@ -15,7 +15,6 @@ /* Error */ .chroma .err { color: #960050; - background-color: #1e0010 } /* LineTableTD */ From 8b17b8a4eeeacb3ae022822a6264aa43cba2576c Mon Sep 17 00:00:00 2001 From: Jimmy Cai Date: Fri, 12 Feb 2021 13:21:43 +0100 Subject: [PATCH 7/8] feat: add data/external.yaml (#140) * feat: add data/external.yaml Manage all external resources URL in one file * style: format data/external * style(helper/external): error message * remove whitespace --- data/external.yaml | 38 +++++++++++++++++++ layouts/partials/article/components/math.html | 15 ++------ .../article/components/photoswipe.html | 6 +-- .../partials/footer/components/script.html | 3 +- layouts/partials/helper/external.html | 29 ++++++++++++++ 5 files changed, 72 insertions(+), 19 deletions(-) create mode 100644 data/external.yaml create mode 100644 layouts/partials/helper/external.html diff --git a/data/external.yaml b/data/external.yaml new file mode 100644 index 0000000..2721e76 --- /dev/null +++ b/data/external.yaml @@ -0,0 +1,38 @@ +Vibrant: + - src: https://cdn.jsdelivr.net/npm/node-vibrant@3.1.5/dist/vibrant.min.js + integrity: sha256-5NovOZc4iwiAWTYIFiIM7DxKUXKWvpVEuMEPLzcm5/g= + type: script + +PhotoSwipe: + - src: https://cdn.jsdelivr.net/npm/photoswipe@4.1.3/dist/photoswipe.min.js + integrity: sha256-ePwmChbbvXbsO02lbM3HoHbSHTHFAeChekF1xKJdleo= + type: script + defer: true + + - src: https://cdn.jsdelivr.net/npm/photoswipe@4.1.3/dist/photoswipe-ui-default.min.js + integrity: sha256-UKkzOn/w1mBxRmLLGrSeyB4e1xbrp4xylgAWb3M42pU= + type: script + defer: true + + - src: https://cdn.jsdelivr.net/npm/photoswipe@4.1.3/dist/default-skin/default-skin.css + integrity: sha256-c0uckgykQ9v5k+IqViZOZKc47Jn7KQil4/MP3ySA3F8= + type: style + + - src: https://cdn.jsdelivr.net/npm/photoswipe@4.1.3/dist/photoswipe.css + integrity: sha256-SBLU4vv6CA6lHsZ1XyTdhyjJxCjPif/TRkjnsyGAGnE= + type: style + +KaTeX: + - src: https://cdn.jsdelivr.net/npm/katex@0.12.0/dist/katex.min.css + integrity: sha384-AfEj0r4/OFrOo5t7NnNe46zW/tFgW6x/bCJG8FqQCEo3+Aro6EYUG4+cU+KJWu/X + type: style + + - src: https://cdn.jsdelivr.net/npm/katex@0.12.0/dist/katex.min.js + integrity: sha384-g7c+Jr9ZivxKLnZTDUhnkOnsh30B4H0rpLUpJ4jAIKs4fnJI+sEnkvrMWph2EDg4 + type: script + defer: true + + - src: https://cdn.jsdelivr.net/npm/katex@0.12.0/dist/contrib/auto-render.min.js + integrity: sha384-mll67QQFJfxn0IYznZYonOWZ644AWYC+Pt2cHqMaRhXVrursRwvLnLaebdGIlYNa + type: script + defer: true diff --git a/layouts/partials/article/components/math.html b/layouts/partials/article/components/math.html index 0f85127..d05861c 100644 --- a/layouts/partials/article/components/math.html +++ b/layouts/partials/article/components/math.html @@ -1,14 +1,6 @@ - - - - +{{- partial "helper/external" (dict "Context" . "Namespace" "KaTeX") -}} \ No newline at end of file diff --git a/layouts/partials/article/components/photoswipe.html b/layouts/partials/article/components/photoswipe.html index ed1c677..c33ff49 100644 --- a/layouts/partials/article/components/photoswipe.html +++ b/layouts/partials/article/components/photoswipe.html @@ -65,8 +65,4 @@ - - - - - \ No newline at end of file +{{- partial "helper/external" (dict "Context" . "Namespace" "PhotoSwipe") -}} \ No newline at end of file diff --git a/layouts/partials/footer/components/script.html b/layouts/partials/footer/components/script.html index 08e357b..83522ff 100644 --- a/layouts/partials/footer/components/script.html +++ b/layouts/partials/footer/components/script.html @@ -1,5 +1,4 @@ - +{{- partial "helper/external" (dict "Context" . "Namespace" "Vibrant") -}} {{- $opts := dict "minify" hugo.IsProduction -}} {{- $script := resources.Get "ts/main.ts" | js.Build $opts -}} diff --git a/layouts/partials/helper/external.html b/layouts/partials/helper/external.html new file mode 100644 index 0000000..e1505d4 --- /dev/null +++ b/layouts/partials/helper/external.html @@ -0,0 +1,29 @@ +{{- $List := index .Context.Site.Data.external .Namespace -}} +{{- with $List -}} + {{- range . -}} + {{- if eq .type "script" -}} + + {{- else if eq .type "style" -}} + + {{- else -}} + {{- errorf "Error: unknown external resource type: %s" .type -}} + {{- end -}} + {{- end -}} +{{- else -}} + {{- errorf "Error: external resource '%s' is not found" .Namespace -}} +{{- end -}} \ No newline at end of file From e661fe2ead2c6b1db272421d57599cc6b44b0d13 Mon Sep 17 00:00:00 2001 From: Jimmy Cai Date: Fri, 12 Feb 2021 13:30:52 +0100 Subject: [PATCH 8/8] ci: build Hugo artifact (#142) --- .github/workflows/hugo-artifact.yml | 42 +++++++++++++++++++++++++++++ 1 file changed, 42 insertions(+) create mode 100644 .github/workflows/hugo-artifact.yml diff --git a/.github/workflows/hugo-artifact.yml b/.github/workflows/hugo-artifact.yml new file mode 100644 index 0000000..be63ba0 --- /dev/null +++ b/.github/workflows/hugo-artifact.yml @@ -0,0 +1,42 @@ +name: Build Hugo Artifact + +# Controls when the action will run. +on: + # Triggers the workflow on push or pull request events but only for the master branch + push: + branches: [master] + + # Allows you to run this workflow manually from the Actions tab + workflow_dispatch: + +# A workflow run is made up of one or more jobs that can run sequentially or in parallel +jobs: + # This workflow contains a single job called "build" + build: + # The type of runner that the job will run on + runs-on: ubuntu-latest + + # Steps represent a sequence of tasks that will be executed as part of the job + steps: + # Checks-out your repository under $GITHUB_WORKSPACE, so your job can access it + - uses: actions/checkout@v2 + + - name: Hugo setup + uses: peaceiris/actions-hugo@v2.4.13 + with: + # The Hugo version to download (if necessary) and use. Example: 0.58.2 + hugo-version: latest # optional, default is latest + # Download (if necessary) and use Hugo extended version. Example: true + extended: true # optional, default is false + + # Runs a set of commands using the runners shell + - name: Generate Hugo site + run: cd exampleSite && hugo --gc --themesDir ../.. + + - name: Upload Hugo artifact + uses: actions/upload-artifact@v2.2.2 + with: + # Artifact name + name: resources + # A file, directory or wildcard pattern that describes what to upload + path: resources