Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chore: bump docsy and hugo fix templating issue #2714

Merged
merged 3 commits into from
Feb 28, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .github/workflows/hugo.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ jobs:
build:
runs-on: ubuntu-latest
env:
HUGO_VERSION: 0.125.4
HUGO_VERSION: 0.145.0
steps:
- name: Install Hugo CLI
run: |
Expand Down
2 changes: 1 addition & 1 deletion docs/go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,4 @@ module github.com/google/docsy-example

go 1.12

require github.com/google/docsy v0.10.0 // indirect
require github.com/google/docsy v0.11.0 // indirect
3 changes: 3 additions & 0 deletions docs/go.sum
Original file line number Diff line number Diff line change
@@ -1,9 +1,12 @@
github.com/FortAwesome/Font-Awesome v0.0.0-20240108205627-a1232e345536/go.mod h1:IUgezN/MFpCDIlFezw3L8j83oeiIuYoj28Miwr/KUYo=
github.com/FortAwesome/Font-Awesome v0.0.0-20240402185447-c0f460dca7f7/go.mod h1:IUgezN/MFpCDIlFezw3L8j83oeiIuYoj28Miwr/KUYo=
github.com/FortAwesome/Font-Awesome v0.0.0-20240716171331-37eff7fa00de/go.mod h1:IUgezN/MFpCDIlFezw3L8j83oeiIuYoj28Miwr/KUYo=
github.com/google/docsy v0.9.1 h1:+jqges1YCd+yHeuZ1BUvD8V8mEGVtPxULg5j/vaJ984=
github.com/google/docsy v0.9.1/go.mod h1:saOqKEUOn07Bc0orM/JdIF3VkOanHta9LU5Y53bwN2U=
github.com/google/docsy v0.10.0 h1:6tMDacPwAyRWNCfvsn/9qGOZDQ8b0aRzjRZvnZPY5dg=
github.com/google/docsy v0.10.0/go.mod h1:c0nIAqmRTOuJ01F85U/wJPQtc3Zj9N58Kea9bOT2AJc=
github.com/google/docsy v0.11.0 h1:QnV40cc28QwS++kP9qINtrIv4hlASruhC/K3FqkHAmM=
github.com/google/docsy v0.11.0/go.mod h1:hGGW0OjNuG5ZbH5JRtALY3yvN8ybbEP/v2iaK4bwOUI=
github.com/twbs/bootstrap v5.2.3+incompatible h1:lOmsJx587qfF7/gE7Vv4FxEofegyJlEACeVV+Mt7cgc=
github.com/twbs/bootstrap v5.2.3+incompatible/go.mod h1:fZTSrkpSf0/HkL0IIJzvVspTt1r9zuf7XlZau8kpcY0=
github.com/twbs/bootstrap v5.3.3+incompatible/go.mod h1:fZTSrkpSf0/HkL0IIJzvVspTt1r9zuf7XlZau8kpcY0=
68 changes: 68 additions & 0 deletions docs/layouts/partials/scripts/mermaid.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,68 @@
<!--TODO remove it with new docy release (next after 0.11.0)-->
{{ $version := .Site.Params.mermaid.version | default "latest" -}}

{{ $cdnurl := printf "https://cdn.jsdelivr.net/npm/mermaid@%s/dist/mermaid.esm.min.mjs" $version -}}
{{ with try (resources.GetRemote $cdnurl) -}}
{{ with .Err -}}
{{ errorf "Could not retrieve mermaid script from CDN. Reason: %s." . -}}
{{ end -}}
{{ else -}}
{{ errorf "Invalid Mermaid version %s, could not retrieve this version from CDN." $version -}}
{{ end -}}

<script type="module" async>
import mermaid from "{{ $cdnurl }}";

(function ($) {
if ($('.mermaid').length == 0) {
mermaid.initialize({ startOnLoad: false });
return;
}

var params = {{ with .Site.Params.mermaid }}{{ . | jsonify | safeJS }}{{ else }}{}{{- end }};

// Site params are stored with lowercase keys; lookup correct casing
// from Mermaid default config.
var norm = function (defaultConfig, params) {
var result = {};
for (const key in defaultConfig) {
const keyLower = key.toLowerCase();
if (defaultConfig.hasOwnProperty(key) && params.hasOwnProperty(keyLower)) {
if (typeof defaultConfig[key] === "object") {
result[key] = norm(defaultConfig[key], params[keyLower]);
} else {
result[key] = params[keyLower];
}
}
}
return result;
};

var settings = norm(mermaid.mermaidAPI.defaultConfig, params);
settings.startOnLoad = true;
if ($('html[data-bs-theme="dark"]').length) {
settings.theme = 'dark';
}
mermaid.initialize(settings);

// Handle light/dark mode theme changes
const lightDarkModeThemeChangeHandler = function (mutationsList, observer) {
for (const mutation of mutationsList) {
if (mutation.type === 'attributes' && mutation.attributeName === 'data-bs-theme') {
// Mermaid doesn't currently support reinitialization, see
// https://github.com/mermaid-js/mermaid/issues/1945. Until then,
// just reload the page.
location.reload();
}
}
};

const observer = new MutationObserver(lightDarkModeThemeChangeHandler);
observer.observe(document.documentElement, {
attributes: true,
attributeFilter: ['data-bs-theme']
});
// observer.disconnect();

})(jQuery);
</script>
8 changes: 4 additions & 4 deletions docs/package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "docsy-example-site",
"version": "0.9.1",
"version.next": "0.9.2-dev.0-unreleased",
"name": "java-operator-sdk",
"version": "0.10.0",
"version.next": "0.10.1-dev.0-unreleased",
"description": "Example site that uses Docsy theme for technical documentation.",
"repository": "github:google/docsy-example",
"homepage": "https://javaoperatorsdk.io",
Expand Down Expand Up @@ -34,7 +34,7 @@
"update:pkg:hugo": "npm install --save-dev --save-exact hugo-extended@latest"
},
"devDependencies": {
"autoprefixer": "^10.4.19",
"autoprefixer": "^10.4.20",
"cross-env": "^7.0.3",
"hugo-extended": "0.125.4",
"postcss-cli": "^11.0.0"
Expand Down