From 9433f9a07dfb6efec61e75c141c7cd6dc96c721d Mon Sep 17 00:00:00 2001 From: Gabriel Arazas Date: Tue, 16 Jul 2024 18:37:40 +0800 Subject: [PATCH] wrapper-manager-fds/docs: update Hugo config --- docs/assets/js/site.js | 49 ++++++++++++++++++++++++++++++++ docs/config/_default/config.toml | 4 +++ docs/config/_default/markup.toml | 13 ++------- docs/config/_default/module.toml | 31 +++++++++++++------- 4 files changed, 76 insertions(+), 21 deletions(-) create mode 100644 docs/assets/js/site.js diff --git a/docs/assets/js/site.js b/docs/assets/js/site.js new file mode 100644 index 0000000..52edafe --- /dev/null +++ b/docs/assets/js/site.js @@ -0,0 +1,49 @@ +(function() { + // Set up shop for QoL code listing features. + var codeListings = document.querySelectorAll("main .listingblock > .content, main .literalblock > .content"); + + for (elem of codeListings) { + var parent = elem.parentElement; + + var fullscreenButton = document.createElement("button"); + fullscreenButton.classList.add("listingblock__fullscreen-btn"); + fullscreenButton.ariaLabel = "{{ T "fullscreenButtonAriaLabel" }}"; + fullscreenButton.title = "{{ T "fullscreenButtonLabel" }}"; + fullscreenButton.ariaDescription = "{{ T "fullscreenButtonDescription" }}"; + fullscreenButton.innerHTML = `{{- partial "components/heroicon.html" (dict "id" "arrows-pointing-out") | safeHTML }}`; + + fullscreenButton.addEventListener("click", (event) => { + const { target } = event; + const parent = target.closest(".listingblock") || target.closest(".literalblock"); + if (!document.fullscreenElement) { + parent.requestFullscreen(); + } else if (document.exitFullscreen) { + document.exitFullscreen(); + } + }); + + var copyButton = document.createElement("button"); + copyButton.classList.add("listingblock__copy-btn"); + copyButton.ariaLabel = "{{ T "copyButtonAriaLabel" }}"; + copyButton.title = "{{ T "copyButtonLabel" }}"; + copyButton.ariaDescription = "{{ T "copyButtonDescription" }}"; + copyButton.innerHTML = `{{- partial "components/heroicon.html" (dict "id" "clipboard") }}`; + + copyButton.addEventListener("click", (event) => { + const { target } = event; + const parent = target.closest(".listingblock"); + const codeListing = parent.querySelector(".content"); + navigator.clipboard.writeText(codeListing.textContent.trim()); + }); + + var buttonRow = document.createElement("div"); + buttonRow.classList.add("listingblock__btn-row"); + + if (parent.classList.contains("listingblock")) { + buttonRow.appendChild(copyButton); + } + + buttonRow.appendChild(fullscreenButton); + parent.appendChild(buttonRow); + } +})() diff --git a/docs/config/_default/config.toml b/docs/config/_default/config.toml index 5582940..af33a31 100644 --- a/docs/config/_default/config.toml +++ b/docs/config/_default/config.toml @@ -11,3 +11,7 @@ allow = [ "^go$", "^asciidoctor$", ] +osEnv = [ '^LAST_COMMIT_DATE$' ] + +[security.funcs] +getenv = [ "^LAST_COMMIT_DATE$" ] diff --git a/docs/config/_default/markup.toml b/docs/config/_default/markup.toml index cc07770..b562157 100644 --- a/docs/config/_default/markup.toml +++ b/docs/config/_default/markup.toml @@ -17,18 +17,11 @@ linkcss = true cache-uri = true reproducible = true stem = "latexmath" +env-hugo = true -avatarsdir = "/nixos-config/icons/avatars" +avatarsdir = "/wrapper-manager-fds/icons/avatars" avatarstype = "svg" icons = "image" -iconsdir = "/nixos-config/icons/asciidoctor" +iconsdir = "/wrapper-manager-fds/icons/asciidoctor" icontype = "svg" - -# Project-wide attributes to be used. -github-repo = "foo-dogsquared/nixos-config" -canonical-flake-url = "github:foo-dogsquared/nixos-config" -canonical-source-repo = "https://github.com/foo-dogsquared/nixos-config" -canonical-flake-url-tarball-master = "https://github.com/foo-dogsquared/nixos-config/archive/master.tar.gz" -canonical-flake-url-tarball-specific = "https://github.com/foo-dogsquared/nixos-config/archive/35c27749c55077727529f412dade862e4deb2ae8.tar.gz" -devos-link = "https://github.com/divnix/digga/tree/580fc57ffaaf9cf3a582372235759dccfe44ac92/examples/devos" diff --git a/docs/config/_default/module.toml b/docs/config/_default/module.toml index 9538f4e..dc9b7ae 100644 --- a/docs/config/_default/module.toml +++ b/docs/config/_default/module.toml @@ -1,14 +1,5 @@ -[[imports]] -path = "github.com/foo-dogsquared/hugo-theme-more-contentful" - [[imports]] path = "github.com/foo-dogsquared/website" -ignoreConfig = true -ignoreImports = true - -[[imports.mounts]] -source = "assets/svg/avatars/" -target = "static/icons/avatars/" [[imports.mounts]] source = "assets/scss/" @@ -19,8 +10,26 @@ source = "assets/css/" target = "assets/css/" [[imports.mounts]] -source = "layouts/partials/" -target = "layouts/partials/" +source = "layouts/partials" +target = "layouts/partials" +excludeFiles = [ "footer.html" ] + +[[imports.mounts]] +source = "layouts/_default" +target = "layouts/_default" +includeFiles = [ "baseof.html" ] + +[[imports.mounts]] +source = "assets/svg/avatars/" +target = "static/icons/avatars/" + +[[imports.mounts]] +source = "assets/svg/avatars/" +target = "assets/svg/avatars/" + +[[imports.mounts]] +source = "i18n/" +target = "i18n/" [[imports.mounts]] source = "data/more-contentful/themes/"