diff --git a/.domains b/.domains deleted file mode 100644 index 95bdcf5..0000000 --- a/.domains +++ /dev/null @@ -1,2 +0,0 @@ -duckquill.daudix.one -duckquill.daudix.codeberg.page diff --git a/.gitignore b/.gitignore index 364fdec..7af4e43 100644 --- a/.gitignore +++ b/.gitignore @@ -1 +1,2 @@ public/ +.vercel diff --git a/.woodpecker.yaml b/.woodpecker.yaml index 6db6a97..05656fc 100644 --- a/.woodpecker.yaml +++ b/.woodpecker.yaml @@ -1,53 +1,32 @@ -# Exclude the pipeline to run on the pages branch -when: - branch: - exclude: pages +# Taken from https://www.markpitblado.me/blog/deploying-to-vercel-from-codeberg steps: - # Check for typos - typos: - image: alpine:edge + preview: + image: node + environment: + VERCEL_TOKEN: + from_secret: vercel_token + VERCEL_ORG_ID: + from_secret: vercel_org_id + VERCEL_PROJECT_ID: + from_secret: vercel_project_id commands: - - apk add curl jq - - curl -s "https://api.github.com/repos/crate-ci/typos/releases/latest" | jq -r '.assets[] | select(.name | contains("unknown-linux-musl")) | .browser_download_url' | xargs -n 1 curl -L -o typos.tar.gz - - tar -zxvf typos.tar.gz ./typos - - ./typos - failure: ignore + - npm install --global vercel@latest + - vercel deploy --token=$VERCEL_TOKEN when: - event: [push, pull_request, manual] + event: [pull_request] - # Build Zola static files - build: - image: alpine:edge + deploy: + image: node + environment: + VERCEL_TOKEN: + from_secret: vercel_token + VERCEL_ORG_ID: + from_secret: vercel_org_id + VERCEL_PROJECT_ID: + from_secret: vercel_project_id commands: - - apk add zola - - zola build - when: - event: [push, pull_request, manual] - - publish: - image: bitnami/git - # Must be set in Woodpecker configuration - # mail: Your email address used by Codeberg - # codeberg_token: Codeberg access token with "write:repository" permission - secrets: [mail, codeberg_token] - commands: - # Configure Git - - git config --global user.email $MAIL - - git config --global user.name "Woodpecker CI" - # Clone the output branch - - git clone --branch pages https://$CODEBERG_TOKEN@codeberg.org/$CI_REPO.git $CI_REPO_NAME - # Enter the output branch - - cd $CI_REPO_NAME - # Remove old files - - git rm -r "*" || true # Don't fail if there's nothing to remove - # Copy the output of the build step - - cp -ar ../public/. . - # Copy .domains in place (Duckquill specific. you should just place it in ./static/) - - cp ../.domains . - # Commit and push all static files with the source commit hash - - git add --all - - git commit -m "Woodpecker CI ${CI_COMMIT_SHA} [SKIP CI]" --allow-empty - - git push + - npm install --global vercel@latest + - vercel deploy --prod --token=$VERCEL_TOKEN when: event: [push, manual] diff --git a/CHANGELOG.md b/CHANGELOG.md index d618bf2..7c82ce2 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -5,14 +5,31 @@ All notable changes to this project will be documented in this file. The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.1.0/), and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html). -## [Unreleased](https://codeberg.org/daudix/duckquill/compare/v6.0.0...main) +## [Unreleased](https://codeberg.org/daudix/duckquill/compare/v6.1.1...main) + +## [v6.1.1](https://codeberg.org/daudix/duckquill/compare/v6.1.0...v6.1.1) + +### Fixed + +- Fix translation of table of contents heading. + +## [v6.1.0](https://codeberg.org/daudix/duckquill/compare/v6.0.0...v6.1.0) + +### Added + +- Add `toc_sidebar` page/section variable for turning table of contents to a sidebar. ### Changed - Don't scale down article cards when clicking on tags in them. - Improve performance of the page when navbar is hidden by using the `config.extra.nav.auto_hide` config variable. +- Improve tab title generation. - Replace `config.extra.debug_*` config variables with variables under the `config.extra.debug` section. +### Fixed + +- Fix navbar not scrolling with content on mobile (#109). + ## [6.0.0](https://codeberg.org/daudix/duckquill/compare/v5.4.0...v6.0.0) ### Added diff --git a/config.toml b/config.toml index 13142a4..0f03ba1 100644 --- a/config.toml +++ b/config.toml @@ -181,7 +181,7 @@ csp = [ [extra.nav] # Whether to automatically hide nav when not hovered or focused -auto_hide = true +# auto_hide = true # Whether to show the Atom/RSS feed button in the nav show_feed = true # Whether to show the manual theme switcher in the nav diff --git a/content/_index.md b/content/_index.md index 24fa96f..575440f 100644 --- a/content/_index.md +++ b/content/_index.md @@ -66,7 +66,7 @@ It is highly recommended to switch from the `main` branch to the latest release: ```bash cd themes/duckquill -git checkout tags/v6.0.0 +git checkout tags/v6.1.1 ``` Then, enable it in your `config.toml`: @@ -80,7 +80,7 @@ To update the theme, simply switch to a new tag: ```bash git submodule update --remote --merge cd themes/duckquill -git checkout tags/v6.0.0 +git checkout tags/v6.1.1 ``` {% alert(important=true) %} @@ -111,6 +111,7 @@ Configuration variables from `config.toml` that can be set/overriden per page/se - `toc`: Enables table of contents. Only first 2 levels of headings are listed. - `toc_inline`: Whether to render inline table of contents at the top of all pages, in addition to floating quick navigation buttons. - `toc_ordered`: Whether to use numbered (ordered) list for table of contents. +- `toc_sidebar`: Whether to display table of contents as a sidebar (useful for long pages). Other variables: diff --git a/content/mods/index.md b/content/mods/index.md index 30436bc..505e24d 100644 --- a/content/mods/index.md +++ b/content/mods/index.md @@ -2,6 +2,7 @@ title = "Mods" [extra] toc = true +toc_sidebar = true +++ Mods enhance/change some Duckquill visuals. They are updated alongside Duckquill to ensure that you don't need to manually update them every release. diff --git a/i18n/zh-Hans.toml b/i18n/zh-Hans.toml index 33c40b9..f784fd7 100644 --- a/i18n/zh-Hans.toml +++ b/i18n/zh-Hans.toml @@ -53,7 +53,7 @@ minutes_read = "阅读需要 $NUMBER 分钟" more_matches = "$MATCHES 更多匹配" next = "下一篇" no_comments = "目前没有评论 :/" -note = "注意" +note = "附注" one_posts = "共有 $NUMBER 篇文章" one_tags = "共有 $NUMBER 个标签" open_post = "打开帖子" diff --git a/sass/_footer.scss b/sass/_footer.scss index 7ff0354..27a6ea9 100644 --- a/sass/_footer.scss +++ b/sass/_footer.scss @@ -1,4 +1,5 @@ #site-footer { + grid-area: footer; margin-block-end: 2rem; text-align: center; diff --git a/sass/_general.scss b/sass/_general.scss index 676ea09..8eb32a7 100644 --- a/sass/_general.scss +++ b/sass/_general.scss @@ -13,6 +13,10 @@ body { text-wrap: pretty; display: grid; // Put footer at the bottom for short pages, such as the 404 grid-template-rows: auto minmax(auto, 1fr) auto; // Header, stuff, footer + grid-template-areas: + "nav" + "main" + "footer"; margin: 0; background-color: var(--bg-color); min-height: 100vh; @@ -20,6 +24,21 @@ body { line-height: 1.5; font-family: var(--font-system-ui), var(--font-emoji); overflow-wrap: break-word; + + &:has(#sidebar) { + grid-template-columns: 1fr min(var(--container-width), 90%) 1fr; + grid-template-areas: + "nav nav nav" + "sidebar main ." + "footer footer footer"; + @media only screen and (max-width: 1200px) { + grid-template-areas: + "nav nav nav" + ". sidebar ." + ". main ." + "footer footer footer"; + } + } } // Style text selection to use accent color @@ -67,7 +86,52 @@ main { width: min(var(--container-width), 90%); } +#sidebar { + display: flex; + position: sticky; + top: 0; + grid-area: sidebar; + opacity: 0.2; + transition: var(--transition); + padding: 1rem; + height: 100vh; + + &:hover { + opacity: 1; + } + + @media only screen and (max-width: 1200px) { + position: static; + opacity: 1; + margin-block-start: 4.25rem; + margin-block-end: -4.25rem; + padding: 0; + height: auto; + } + + & > div { + --mask: linear-gradient(to bottom, + transparent, + black 1rem, + black calc(100% - 1rem), + transparent); + -webkit-mask-image: var(--mask); + flex: 1; + mask-image: var(--mask); + overflow: auto; + } + + & + main { + grid-area: main; + margin: 0; + margin-block-start: 4.25rem; + margin-block-end: 4rem; + width: auto; + } +} + @media (prefers-reduced-motion) { + *, *::before, *::after { diff --git a/sass/_nav.scss b/sass/_nav.scss index 85ea491..1db2958 100644 --- a/sass/_nav.scss +++ b/sass/_nav.scss @@ -64,6 +64,7 @@ #site-nav { position: sticky; + grid-area: nav; z-index: 999; margin: 1rem auto 0; inset-block-start: 1rem; @@ -72,6 +73,11 @@ border-radius: 1.625rem; max-width: min(var(--container-width), 90%); + @media only screen and (max-width: 480px) { + position: relative; + margin: 0 auto; + } + &::before { -webkit-backdrop-filter: var(--blur); position: absolute; diff --git a/sass/style.scss b/sass/style.scss index 1a04494..9e9590f 100644 --- a/sass/style.scss +++ b/sass/style.scss @@ -1,5 +1,5 @@ /*! - * Duckquill v6.0.0 (https://duckquill.daudix.one) + * Duckquill v6.1.1 (https://duckquill.daudix.one) * Copyright 2024 David "Daudix" Lapshin * Licensed under MIT (https://codeberg.org/daudix/duckquill/src/branch/main/LICENSE) */ diff --git a/screenshot.png b/screenshot.png index aebd7d8..d3e91c5 100644 Binary files a/screenshot.png and b/screenshot.png differ diff --git a/templates/base.html b/templates/base.html index 45d9216..bbec753 100644 --- a/templates/base.html +++ b/templates/base.html @@ -15,6 +15,13 @@ {%- if config.extra.nav.links %} {% include "partials/nav.html" %} {%- endif %} + {%- if page.extra.toc_sidebar or section.extra.toc_sidebar -%} + + {%- endif -%}
{% block custom %}{% endblock custom %} {% block content %}{% endblock content %} diff --git a/templates/page.html b/templates/page.html index acc84b1..1cdcdac 100644 --- a/templates/page.html +++ b/templates/page.html @@ -3,6 +3,8 @@ {% block content %}

{{ page.title }}

{%- include "partials/statements.html" -%} +{%- if page.extra.toc and not page.extra.toc_sidebar -%} {%- include "partials/toc.html" -%} +{%- endif -%} {{ page.content | safe }} {% endblock content %} diff --git a/templates/partials/articles.html b/templates/partials/articles.html index 58cf023..92180b4 100644 --- a/templates/partials/articles.html +++ b/templates/partials/articles.html @@ -60,7 +60,6 @@ {%- endfor -%} {%- endif %} - {%- endif -%} diff --git a/templates/partials/title.html b/templates/partials/title.html index 22e3f14..8d8897f 100644 --- a/templates/partials/title.html +++ b/templates/partials/title.html @@ -1,7 +1,35 @@ -{%- if page.title -%} - {{- page.title }} {{ config.extra.title_separator | default(value="-") }} {{ config.title -}} -{%- elif section.title -%} - {{- section.title }} {{ config.extra.title_separator | default(value="-") }} {{ config.title -}} +{# Taken from https://github.com/welpo/tabi/blob/69713c973c11d7646c8fe56476261d96cc1978d8/templates/partials/title.html #} + +{#- Setup -#} +{%- set suffix = config.title | safe -%} +{%- set custom_separator = config.extra.title_separator | default(value="-") -%} +{%- set separator = " " ~ custom_separator ~ " " -%} + +{#- Get the base path for the current language -#} +{%- if lang != config.default_language %} + {%- set base_path = "/" ~ lang ~ "/" %} {%- else -%} - {{- config.title -}} + {%- set base_path = "/" %} +{%- endif %} + +{%- if current_path and current_path == base_path -%} + {%- set prefix = "" -%} + {%- set separator = "" -%} +{% elif title %} + {%- set prefix = title -%} +{% elif section.title -%} + {%- set prefix = section.title -%} +{% elif page.title %} + {%- set prefix = page.title -%} +{% elif term.name %} + {#- Individual tags -#} + {%- set prefix = term.name -%} +{% elif taxonomy.name %} + {#- List of tags -#} + {%- set prefix = macros_translate::translate(key=taxonomy.name, language_strings=language_strings) | capitalize -%} +{% else %} + {%- set prefix = "404" %} {%- endif -%} + +{#- Return the final concatenated string -#} +{{- prefix ~ separator ~ suffix -}} diff --git a/templates/partials/toc.html b/templates/partials/toc.html index db918ee..8e269ee 100644 --- a/templates/partials/toc.html +++ b/templates/partials/toc.html @@ -12,7 +12,7 @@ {%- if page.extra.toc or section.extra.toc -%} {%- if toc | length > 0 -%} -

{{ macros_translate::translate(key="toc", default="Table of Contents", language_strings=language_strings) }}

+

{{ macros_translate::translate(key="table_of_contents", default="Table of Contents", language_strings=language_strings) }}

<{{ list_element }}> {%- for h1 in toc -%}
  • diff --git a/templates/section.html b/templates/section.html index 2cd488f..c5aded2 100644 --- a/templates/section.html +++ b/templates/section.html @@ -3,6 +3,8 @@ {% block content %}

    {{ section.title }}

    {%- include "partials/statements.html" -%} +{%- if section.extra.toc and not section.extra.toc_sidebar -%} {%- include "partials/toc.html" -%} +{%- endif -%} {{ section.content | safe }} {% endblock content %}