From 406fcef7cdd1d342fcf87439082b5f6eb674fb8e Mon Sep 17 00:00:00 2001 From: Jimmy Date: Sun, 25 Jan 2026 19:51:10 +0100 Subject: [PATCH] refactor: use TOML for configuration file (#1228) * refactor: remove jsconfig.json * chore: remove devcontainer config * refactor: migrate Hugo configuration from `hugo.yaml` to dedicated `module.toml` and `params.toml` files, and update minimum Hugo version. * refactor: migrate demo site configuration from `hugo.yaml` to `config/_default/*.toml` * feat: enable local sidebar avatar for demo site and relocate its image to demo assets. * feat: migrate demo site to Hugo Modules for theme management. * fix: wrong config folder name --- .devcontainer/Dockerfile | 56 ----- .devcontainer/devcontainer.json | 51 ----- assets/jsconfig.json | 12 -- config/_default/module.toml | 3 + config/_default/params.toml | 138 ++++++++++++ {assets => demo/assets}/img/avatar.png | Bin demo/config/_default/hugo.toml | 26 +++ demo/config/_default/languages.toml | 35 +++ demo/config/_default/markup.toml | 24 +++ demo/config/_default/menu.toml | 13 ++ demo/config/_default/params.toml | 37 ++++ demo/config/_default/related.toml | 8 + demo/go.mod | 7 + demo/hugo.yaml | 285 ------------------------- hugo.yaml | 149 ------------- theme.toml | 14 +- 16 files changed, 298 insertions(+), 560 deletions(-) delete mode 100644 .devcontainer/Dockerfile delete mode 100644 .devcontainer/devcontainer.json delete mode 100644 assets/jsconfig.json create mode 100644 config/_default/module.toml create mode 100644 config/_default/params.toml rename {assets => demo/assets}/img/avatar.png (100%) create mode 100644 demo/config/_default/hugo.toml create mode 100644 demo/config/_default/languages.toml create mode 100644 demo/config/_default/markup.toml create mode 100644 demo/config/_default/menu.toml create mode 100644 demo/config/_default/params.toml create mode 100644 demo/config/_default/related.toml create mode 100644 demo/go.mod delete mode 100644 demo/hugo.yaml delete mode 100644 hugo.yaml diff --git a/.devcontainer/Dockerfile b/.devcontainer/Dockerfile deleted file mode 100644 index 9704b97..0000000 --- a/.devcontainer/Dockerfile +++ /dev/null @@ -1,56 +0,0 @@ -# syntax=docker/dockerfile:1 -FROM mcr.microsoft.com/devcontainers/base:ubuntu-22.04 - -ARG USER=vscode -ARG DEBIAN_FRONTEND=noninteractive -RUN usermod -s /usr/bin/zsh ${USER} - -# VARIANT can be either 'hugo' for the standard version or 'hugo_extended' for the extended version. -ARG VARIANT=hugo_extended -# VERSION can be either 'latest' or a specific version number -ARG VERSION=latest - -# Download Hugo -RUN 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} && \ - case $(uname -m) in \ - aarch64) \ - export ARCH=ARM64 ;; \ - *) \ - export ARCH=64bit ;; \ - esac && \ - echo ${ARCH} && \ - wget -O ${VERSION}.tar.gz https://github.com/gohugoio/hugo/releases/download/v${VERSION}/${VARIANT}_${VERSION}_Linux-${ARCH}.tar.gz && \ - tar xf ${VERSION}.tar.gz && \ - mv hugo /usr/bin/hugo - -# Hugo dev server port -EXPOSE 1313 - - -USER ${USER} -ARG HOME=/home/${USER} -WORKDIR ${HOME} - -ARG PNPM_HOME=${HOME}/.local/share/pnpm -ENV PATH="${PNPM_HOME}:$PATH" -RUN <> .zshrc -# EOT - -RUN < ${OHMYZSH_HOME}/plugins/git/_hugo -EOT diff --git a/.devcontainer/devcontainer.json b/.devcontainer/devcontainer.json deleted file mode 100644 index fba096d..0000000 --- a/.devcontainer/devcontainer.json +++ /dev/null @@ -1,51 +0,0 @@ -{ - "name": "Hugo & pnpm", - - "build": { - "dockerfile": "Dockerfile" - }, - - // 👇 Features to add to the Dev Container. More info: https://containers.dev/implementors/features. - // "features": { "ghcr.io/devcontainers/features/docker-in-docker:2": {} }, - - // 👇 Use 'forwardPorts' to make a list of ports inside the container available locally. - // "forwardPorts": [], - - // Configure tool-specific properties. - "customizations": { - // Configure properties specific to VS Code. - "vscode": { - // 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": [ - // https://marketplace.visualstudio.com/items?itemName=eliostruyf.vscode-front-matter - "eliostruyf.vscode-front-matter", - // https://marketplace.visualstudio.com/items?itemName=rusnasonov.vscode-hugo - "rusnasonov.vscode-hugo", - // https://marketplace.visualstudio.com/items?itemName=budparr.language-hugo-vscode - "budparr.language-hugo-vscode", - // https://marketplace.visualstudio.com/items?itemName=eliostruyf.vscode-hugo-themer - "eliostruyf.vscode-hugo-themer", - // https://marketplace.visualstudio.com/items?itemName=kaellarkin.hugo-shortcode-syntax - "kaellarkin.hugo-shortcode-syntax", - - // "csstools.postcss", - - // "esbenp.prettier-vscode", - // "tamasfe.even-better-toml", - // "naumovs.color-highlight", - // "GitHub.vscode-pull-request-github", - // "eamodio.gitlens", - "davidanson.vscode-markdownlint", - "streetsidesoftware.code-spell-checker" - ] - } - }, - - "remoteUser": "vscode", - - "postCreateCommand": "pnpm install-completion zsh" -} diff --git a/assets/jsconfig.json b/assets/jsconfig.json deleted file mode 100644 index 040177a..0000000 --- a/assets/jsconfig.json +++ /dev/null @@ -1,12 +0,0 @@ -{ - "compilerOptions": { - "baseUrl": ".", - "paths": { - "*": [ - "*" - ] - }, - "lib": ["es2020", "dom"], - "jsx": "preserve" - } -} \ No newline at end of file diff --git a/config/_default/module.toml b/config/_default/module.toml new file mode 100644 index 0000000..8ccccf2 --- /dev/null +++ b/config/_default/module.toml @@ -0,0 +1,3 @@ +[hugoVersion] + extended = true + min = "0.154.0" diff --git a/config/_default/params.toml b/config/_default/params.toml new file mode 100644 index 0000000..d495248 --- /dev/null +++ b/config/_default/params.toml @@ -0,0 +1,138 @@ +mainSections = ["post"] +featuredImageField = "image" +rssFullContent = true + +[footer] + since = 2026 + customText = "" + +[dateFormat] + published = "Jan 02, 2006" + lastUpdated = "Jan 02, 2006 15:04 MST" + +[sidebar] + compact = false + + [sidebar.avatar] + enabled = false + local = true + src = "img/avatar.png" + +[article] + headingAnchor = false + math = false + toc = true + readingTime = true + + [article.license] + enabled = false + default = "Licensed under CC BY-NC-SA 4.0" + +[widgets] + homepage = [] + page = [] + +[opengraph.twitter] + site = "" + card = "summary_large_image" + +[defaultImage.opengraph] + enabled = false + local = false + +[colorScheme] + toggle = true + default = "auto" + +[imageProcessing.cover] + enabled = true + +[imageProcessing.content] + enabled = true + +[comments] + enabled = true + provider = "disqus" + + [comments.disqusjs] + shortname = "" + apiUrl = "" + apiKey = "" + admin = "" + adminLabel = "" + + [comments.utterances] + repo = "" + issueTerm = "pathname" + label = "" + + [comments.beaudar] + repo = "" + issueTerm = "pathname" + label = "" + theme = "" + + [comments.remark42] + host = "" + site = "" + locale = "" + + [comments.vssue] + platform = "" + owner = "" + repo = "" + clientId = "" + clientSecret = "" + autoCreateIssue = false + + # Waline client configuration see: https://waline.js.org/en/reference/component.html + [comments.waline] + serverURL = "" + lang = "" + pageview = "" + emoji = [ + "https://unpkg.com/@waline/emojis@1.0.1/weibo" + ] + requiredMeta = [ + "name", + "email", + "url" + ] + [comments.waline.locale] + admin = "Admin" + placeholder = "" + + [comments.twikoo] + envId = "" + region = "" + path = "" + lang = "" + + # See https://cactus.chat/docs/reference/web-client/#configuration for description of the various options + [comments.cactus] + defaultHomeserverUrl = "https://matrix.cactus.chat:8448" + serverName = "cactus.chat" + siteName = "" # You must insert a unique identifier here matching the one you registered (See https://cactus.chat/docs/getting-started/quick-start/#register-your-site) + + [comments.giscus] + repo = "" + repoID = "" + category = "" + categoryID = "" + mapping = "" + lightTheme = "" + darkTheme = "" + reactionsEnabled = 1 + emitMetadata = 0 + + [comments.gitalk] + owner = "" + admin = "" + repo = "" + clientID = "" + clientSecret = "" + proxy = "" + + [comments.cusdis] + host = "" + id = "" \ No newline at end of file diff --git a/assets/img/avatar.png b/demo/assets/img/avatar.png similarity index 100% rename from assets/img/avatar.png rename to demo/assets/img/avatar.png diff --git a/demo/config/_default/hugo.toml b/demo/config/_default/hugo.toml new file mode 100644 index 0000000..1a6ac47 --- /dev/null +++ b/demo/config/_default/hugo.toml @@ -0,0 +1,26 @@ +baseURL = "https://example.com/" +languageCode = "en-us" +title = "Example Site" +copyright = "Example Person" + +# Theme i18n support +# Available values: ar, bn, ca, de, el, en, es, fr, hu, id, it, ja, ko, nl, pt-br, th, uk, zh-cn, zh-hk, zh-tw +defaultContentLanguage = "en" + +# Set hasCJKLanguage to true if DefaultContentLanguage is in [zh-cn ja ko] +# This will make .Summary and .WordCount behave correctly for CJK languages. +hasCJKLanguage = false + +[[module.imports]] +path = "github.com/CaiJimmy/hugo-theme-stack/v3" + + +[pagination] + pagerSize = 3 + +[permalinks] + post = "/p/:slug/" + page = "/:slug/" + +[services.disqus] + shortname = "hugo-theme-stack" diff --git a/demo/config/_default/languages.toml b/demo/config/_default/languages.toml new file mode 100644 index 0000000..464ab10 --- /dev/null +++ b/demo/config/_default/languages.toml @@ -0,0 +1,35 @@ +[en] + languageName = "English" + title = "Example Site" + weight = 1 + [en.params.sidebar] + subtitle = "Example description" + +[zh-cn] + languageName = "简体中文" + title = "演示站点" + weight = 2 + [zh-cn.params.sidebar] + subtitle = "演示说明" + +[zh-tw] + languageName = "正體中文" + title = "演示站點" + weight = 2 + [zh-tw.params.sidebar] + subtitle = "演示說明" + +[ja] + languageName = "日本語" + title = "サンプルサイト" + weight = 2 + [ja.params.sidebar] + subtitle = "サンプル説明" + +[ar] + languageName = "عربي" + languagedirection = "rtl" + title = "موقع تجريبي" + weight = 3 + [ar.params.sidebar] + subtitle = "وصف تجريبي" diff --git a/demo/config/_default/markup.toml b/demo/config/_default/markup.toml new file mode 100644 index 0000000..8870cd0 --- /dev/null +++ b/demo/config/_default/markup.toml @@ -0,0 +1,24 @@ +[goldmark] + [goldmark.extensions] + [goldmark.extensions.passthrough] + enable = true + [goldmark.extensions.passthrough.delimiters] + block = [["\\[", "\\]"], ["$$", "$$"]] + inline = [["\\(", "\\)"]] + [goldmark.renderer] + ## Set to true if you have HTML content inside Markdown + unsafe = true + +[tableOfContents] + endLevel = 4 + ordered = true + startLevel = 2 + +[highlight] + noClasses = false + codeFences = true + guessSyntax = true + lineNoStart = 1 + lineNos = true + lineNumbersInTable = true + tabWidth = 4 diff --git a/demo/config/_default/menu.toml b/demo/config/_default/menu.toml new file mode 100644 index 0000000..8364e1f --- /dev/null +++ b/demo/config/_default/menu.toml @@ -0,0 +1,13 @@ +[[social]] + identifier = "github" + name = "GitHub" + url = "https://github.com/CaiJimmy/hugo-theme-stack" + [social.params] + icon = "brand-github" + +[[social]] + identifier = "twitter" + name = "Twitter" + url = "https://twitter.com" + [social.params] + icon = "brand-twitter" diff --git a/demo/config/_default/params.toml b/demo/config/_default/params.toml new file mode 100644 index 0000000..faa7438 --- /dev/null +++ b/demo/config/_default/params.toml @@ -0,0 +1,37 @@ +mainSections = ["post"] +rssFullContent = true +favicon = "" + +[footer] + since = 2020 + +[dateFormat] + published = "Jan 02, 2006" + lastUpdated = "Jan 02, 2006 15:04 MST" + +[sidebar] + emoji = "🍥" + subtitle = "Lorem ipsum dolor sit amet, consectetur adipiscing elit." + [sidebar.avatar] + enabled = true + local = true + src = "img/avatar.png" + +[article] + [article.license] + enabled = true + default = "Licensed under CC BY-NC-SA 4.0" + +[widgets] + homepage = [ + { type = "search" }, + { type = "archives", params = { limit = 5 } }, + { type = "categories", params = { limit = 10 } }, + { type = "tag-cloud", params = { limit = 10 } }, + ] + page = [{ type = "toc" }] + +[comments] + # See complete configuration in config/_default/params.toml + enabled = true + provider = "disqus" diff --git a/demo/config/_default/related.toml b/demo/config/_default/related.toml new file mode 100644 index 0000000..3d667e3 --- /dev/null +++ b/demo/config/_default/related.toml @@ -0,0 +1,8 @@ +includeNewer = true +threshold = 60 +toLower = false + +indices = [ + { name = "tags", weight = 100 }, + { name = "categories", weight = 200 }, +] diff --git a/demo/go.mod b/demo/go.mod new file mode 100644 index 0000000..f918063 --- /dev/null +++ b/demo/go.mod @@ -0,0 +1,7 @@ +module github.com/CaiJimmy/hugo-theme-stack/demo + +go 1.25.6 + +replace github.com/CaiJimmy/hugo-theme-stack/v3 => ../ + +require github.com/CaiJimmy/hugo-theme-stack/v3 v3.34.0 // indirect diff --git a/demo/hugo.yaml b/demo/hugo.yaml deleted file mode 100644 index 0ec4ed0..0000000 --- a/demo/hugo.yaml +++ /dev/null @@ -1,285 +0,0 @@ -baseurl: https://example.com/ -languageCode: en-us -theme: hugo-theme-stack -title: Example Site -copyright: Example Person - -# Theme i18n support -# Available values: ar, bn, ca, de, el, en, es, fr, hu, id, it, ja, ko, nl, pt-br, th, uk, zh-cn, zh-hk, zh-tw -DefaultContentLanguage: en - -# Set hasCJKLanguage to true if DefaultContentLanguage is in [zh-cn ja ko] -# This will make .Summary and .WordCount behave correctly for CJK languages. -hasCJKLanguage: false - -languages: - en: - languageName: English - title: Example Site - weight: 1 - params: - sidebar: - subtitle: Example description - zh-cn: - languageName: 简体中文 - title: 演示站点 - weight: 2 - params: - sidebar: - subtitle: 演示说明 - - zh-tw: - languageName: 正體中文 - title: 演示站點 - weight: 2 - params: - sidebar: - subtitle: 演示說明 - - ja: - languageName: 日本語 - title: サンプルサイト - weight: 2 - params: - sidebar: - subtitle: サンプル説明 - ar: - languageName: عربي - languagedirection: rtl - title: موقع تجريبي - weight: 3 - params: - sidebar: - subtitle: وصف تجريبي - -services: - # Change it to your Disqus shortname before using - disqus: - shortname: "hugo-theme-stack" - # GA Tracking ID - googleAnalytics: - id: - -pagination: - pagerSize: 3 - -permalinks: - post: /p/:slug/ - page: /:slug/ - -params: - mainSections: - - post - featuredImageField: image - rssFullContent: true - favicon: # e.g.: favicon placed in `static/favicon.ico` of your site folder, then set this field to `/favicon.ico` (`/` is necessary) - - footer: - since: 2020 - customText: - - dateFormat: - published: Jan 02, 2006 - lastUpdated: Jan 02, 2006 15:04 MST - - sidebar: - emoji: 🍥 - subtitle: Lorem ipsum dolor sit amet, consectetur adipiscing elit. - avatar: - enabled: true - local: true - src: img/avatar.png - - article: - math: false - toc: true - readingTime: true - license: - enabled: true - default: Licensed under CC BY-NC-SA 4.0 - - comments: - enabled: true - provider: disqus - - disqusjs: - shortname: - apiUrl: - apiKey: - admin: - adminLabel: - - utterances: - repo: - issueTerm: pathname - label: - - beaudar: - repo: - issueTerm: pathname - label: - theme: - - remark42: - host: - site: - locale: - - vssue: - platform: - owner: - repo: - clientId: - clientSecret: - autoCreateIssue: false - - # Waline client configuration see: https://waline.js.org/en/reference/component.html - waline: - serverURL: - lang: - pageview: - emoji: - - https://unpkg.com/@waline/emojis@1.0.1/weibo - requiredMeta: - - name - - email - - url - locale: - admin: Admin - placeholder: - - twikoo: - envId: - region: - path: - lang: - - # See https://cactus.chat/docs/reference/web-client/#configuration for description of the various options - cactus: - defaultHomeserverUrl: "https://matrix.cactus.chat:8448" - serverName: "cactus.chat" - siteName: "" # You must insert a unique identifier here matching the one you registered (See https://cactus.chat/docs/getting-started/quick-start/#register-your-site) - - giscus: - repo: - repoID: - category: - categoryID: - mapping: - lightTheme: - darkTheme: - reactionsEnabled: 1 - emitMetadata: 0 - - gitalk: - owner: - admin: - repo: - clientID: - clientSecret: - proxy: - - cusdis: - host: - id: - widgets: - homepage: - - type: search - - type: archives - params: - limit: 5 - - type: categories - params: - limit: 10 - - type: tag-cloud - params: - limit: 10 - page: - - type: toc - - 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 - -### Custom menu -### See https://stack.jimmycai.com/config/menu -### To remove about, archive and search page menu item, remove `menu` field from their FrontMatter -menu: - main: [] - - 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 - threshold: 60 - toLower: false - indices: - - name: tags - weight: 100 - - - name: categories - weight: 200 - -markup: - goldmark: - extensions: - passthrough: - enable: true - delimiters: - block: - - - \[ - - \] - - - $$ - - $$ - inline: - - - \( - - \) - renderer: - ## Set to true if you have HTML content inside Markdown - unsafe: true - tableOfContents: - endLevel: 4 - ordered: true - startLevel: 2 - highlight: - noClasses: false - codeFences: true - guessSyntax: true - lineNoStart: 1 - lineNos: true - lineNumbersInTable: true - tabWidth: 4 diff --git a/hugo.yaml b/hugo.yaml deleted file mode 100644 index b1a0bff..0000000 --- a/hugo.yaml +++ /dev/null @@ -1,149 +0,0 @@ -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: - compact: false - emoji: - subtitle: - avatar: - enabled: true - local: true - src: img/avatar.png - - article: - headingAnchor: false - 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: - - beaudar: - repo: - issueTerm: pathname - label: - theme: - - remark42: - host: - site: - locale: - - vssue: - platform: - owner: - repo: - clientId: - clientSecret: - autoCreateIssue: false - - # Waline client configuration see: https://waline.js.org/en/reference/client/props.html - waline: - serverURL: - lang: - visitor: - avatar: - emoji: - - https://cdn.jsdelivr.net/gh/walinejs/emojis/weibo - requiredMeta: - - nick - - mail - locale: - admin: Admin - placeholder: - - twikoo: - envId: - region: - path: - lang: - - giscus: - repo: - repoID: - category: - categoryID: - mapping: - strict: - lightTheme: - darkTheme: - reactionsEnabled: 1 - emitMetadata: 0 - inputPosition: - lang: - - gitalk: - owner: - admin: - repo: - clientID: - clientSecret: - - cusdis: - host: - id: - - widgets: - homepage: [] - page: [] - - 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 diff --git a/theme.toml b/theme.toml index 6c5ea62..5dfce66 100644 --- a/theme.toml +++ b/theme.toml @@ -1,12 +1,12 @@ # theme.toml template for a Hugo theme # See https://github.com/gohugoio/hugoThemes#themetoml for an example -name = "Stack" -license = "GPL-3.0-only" +name = "Stack" +license = "GPL-3.0-only" licenselink = "https://github.com/CaiJimmy/hugo-theme-stack/blob/master/LICENSE" description = "Card-style Hugo theme designed for bloggers" -homepage = "https://github.com/CaiJimmy/hugo-theme-stack" -demosite = "https://demo.stack.jimmycai.com" +homepage = "https://github.com/CaiJimmy/hugo-theme-stack" +demosite = "https://demo.stack.jimmycai.com" tags = ["blog", "responsive", "clean", "light", "dark", "personal"] @@ -20,8 +20,8 @@ features = [ "search", ] -min_version = "0.123.0" +min_version = "0.154.0" [author] -name = "Jimmy Cai" -homepage = "https://jimmycai.com" + name = "Jimmy Cai" + homepage = "https://jimmycai.com"