Misc adjustments

This commit is contained in:
Bjørn Erik Pedersen 2025-02-08 16:30:00 +01:00
parent eb5842566f
commit 5accec5f16
41 changed files with 288 additions and 181 deletions

View File

@ -4,7 +4,7 @@
[codespell]
# Comma separated list of dirs to be skipped.
skip = _vendor,.cspell.json
skip = _vendor,.cspell.json,chroma.css,chroma_dark.css
# Comma separated list of words to be ignored. Words must be lowercased.
ignore-words-list = abl,edn,te,ue,trys,januar,womens,crossreferences

View File

@ -11,10 +11,14 @@
@apply text-gray-400;
}
.highlight code {
@apply text-sm;
}
.content {
@apply prose prose-stone max-w-none dark:prose-invert dark:text-slate-400;
@apply prose prose-sm sm:prose-base prose-stone max-w-none dark:prose-invert dark:text-slate-200;
/* headings */
@apply prose-h6:font-bold;
@apply prose-h4:font-bold prose-h5:font-bold prose-h6:font-bold;
/* lead */
@apply prose-lead:text-slate-500 prose-lead:text-xl prose-lead:mt-2 sm:prose-lead:mt-4 prose-lead:leading-relaxed dark:prose-lead:text-slate-400;
/* links */
@ -23,12 +27,16 @@
/* pre */
@apply prose-pre:text-gray-800 prose-pre:border-1 prose-pre:border-gray-100 prose-pre:bg-light dark:prose-pre:bg-dark dark:prose-pre:ring-1 dark:prose-pre:ring-slate-300/10;
/* code */
@apply prose-code:px-0.5 prose-code:text-gray-900 prose-code:dark:text-gray-300 border-none;
@apply prose-code:px-0.5 prose-code:text-gray-500 prose-code:dark:text-gray-300 border-none;
@apply prose-code:before:hidden prose-code:after:hidden prose-code:font-mono;
/* tables */
@apply prose-table:border-2 prose-table:border-gray-100 prose-table:dark:border-gray-800 prose-table:relative prose-table:overflow-scroll prose-table:prose-th:font-bold prose-table:prose-th:bg-blue-500 dark:prose-table:prose-th:bg-blue-500/50 prose-table:prose-th:p-2 prose-table:prose-td:p-2 prose-table:prose-th:text-white;
/* hr */
@apply dark:prose-hr:border-slate-800;
h6 + * {
@apply mt-2;
}
}
/* This will not match highlighting inside e.g. the code-toggle shortcode. */

View File

@ -12,7 +12,7 @@ export const explorer = (Alpine) => ({
// The state of each node in the tree.
nodes: {},
// We currenty only list the sections, not regular pages, in the side bar.
// We currently only list the sections, not regular pages, in the side bar.
// This strikes me as the right balance. The pages gets listed on the section pages.
// This array is sorted by length, so we can find the longest prefix of the current page
// without having to iterate over all the keys.

View File

@ -1,12 +1,10 @@
export const navbar = (Alpine) => ({
atTop: true,
init: function () {
Alpine.bind(this.$root, this.root);
},
root: {
['@scroll.window.debounce.10ms'](event) {
this.atTop = window.scrollY < 40 ? true : false;
this.$store.nav.scroll.atTop = window.scrollY < 40 ? true : false;
},
},
});

View File

@ -16,6 +16,12 @@ export const toc = (Alpine) => ({
},
init() {
this.$watch('$store.nav.scroll.atTop', (value) => {
if (!value) return;
this.activeHeading = '';
this.$root.scrollTop = 0;
});
return this.$nextTick(() => {
let contentEl = document.getElementById('content');
if (contentEl) {

View File

@ -6,10 +6,17 @@ export function registerMagics(Alpine) {
if (!el) {
el = currentEl;
}
let lntds = el.querySelectorAll('.lntable .lntd');
if (lntds && lntds.length === 2) {
el = lntds[1];
}
// Select the element to copy.
let range = document.createRange();
range.selectNode(el);
window.getSelection().removeAllRanges();
window.getSelection().addRange(range);
// Remove the selection after some time.
setTimeout(() => {
window.getSelection().removeAllRanges();
}, 500);
// Trim whitespace.
let text = el.textContent.trim();

View File

@ -27,6 +27,10 @@ export const navStore = (Alpine) => ({
destroy() {},
scroll: {
atTop: true,
},
userSettings: {
// settings gets persisted between page navigations.
settings: Alpine.$persist({

View File

@ -4,6 +4,11 @@ import { scrollToActive } from 'js/helpers/index';
// Now we know that the browser has JS enabled.
document.documentElement.classList.remove('no-js');
// Add os-macos class to body if user is using macOS.
if (navigator.userAgent.indexOf('Mac') > -1) {
document.documentElement.classList.add('os-macos');
}
// Wait for the DOM to be ready.
document.addEventListener('DOMContentLoaded', function () {
scrollToActive('DOMContentLoaded');

View File

@ -1,6 +1,6 @@
---
title: About Hugo
linktitle: About
description: Learn about Hugo and its features, security model, and privacy protections.
categories: []
keywords: []

View File

@ -1,6 +1,6 @@
---
title: Contribute to the Hugo project
linktitle: Contribute
description: Contribute to Hugo development, documentation, and themes.
categories: []
keywords: []

View File

@ -1,6 +1,6 @@
---
title: Hugo Documentation
linkTitle: Hugo
linkTitle: Docs
description: Hugo is the world's fastest static website engine. It's written in Go (aka Golang) and developed by bep, spf13 and friends.
menu:
main:

View File

@ -1,5 +1,6 @@
---
title: External learning resources
linkTitle: External resources
description: Use these third-party resources to learn Hugo.
categories: [getting started]
keywords: [books, tutorials, learning, usage]

View File

@ -1,6 +1,6 @@
---
title: Quick reference guides
linktitle: Quick reference
description: Use these quick reference guides for quick access to key information.
categories: []
keywords: []

22
data/sponsors.toml Normal file
View File

@ -0,0 +1,22 @@
[[banners]]
name = "Linode"
link = "https://www.linode.com/"
logo = "images/sponsors/linode-logo.svg"
utm_campaign = "hugosponsor"
bgcolor = "#ffffff"
[[banners]]
name = "GoLand"
title = "The complete IDE crafted for professional Go developers."
no_query_params = true
link = "https://www.jetbrains.com/go/?utm_source=OSS&utm_medium=referral&utm_campaign=hugo"
logo = "images/sponsors/goland.svg"
bgcolor = "#f4f4f4"
[[banners]]
name = "Your Company?"
link = "https://bep.is/en/hugo-sponsor-2023-01/"
utm_campaign = "hugosponsor"
show_on_hover = true
bgcolor = "#4e4f4f"
link_attr = "style='color: #ffffff; font-weight: bold; text-decoration: none; text-align: center'"

View File

@ -14,7 +14,7 @@
</title>
<style>
[x-cloak] {
display: none;
display: none !important;
}
</style>
<meta
@ -46,7 +46,7 @@
{{ end }}
<div class="flex w-full xl:w-6xl h-full flex-auto mx-auto">
<main
class="flex-1 mx-auto lg:mx-0 w-full max-w-3x lg:max-w-3x py-8 lg:py-14 px-main">
class="flex-1 mx-auto lg:mx-0 w-full max-w-3x lg:max-w-3x pt-8 lg:pt-14 pb-20 px-main">
{{ block "main" . }}{{ end }}
</main>
{{ block "rightsidebar" . }}

View File

@ -2,7 +2,7 @@
{{ $pages := "" }}
{{ $showDate := false }}
{{ if .IsPage }}
{{/* We currently have a slightly odd content structure with no top level /docs sectin. */}}
{{/* We currently have a slightly odd content structure with no top level /docs section. */}}
{{ $pages = .CurrentSection.Pages }}
{{ else }}
{{ if eq .Section "news" }}

View File

@ -11,34 +11,38 @@
{{ $t := debug.Timer "single.categories" }}
{{ $tags := .GetTerms "categories" }}
{{ range $tags }}
{{ $text := .LinkTitle }}
{{ $class := "" }}
{{ range (slice true false ) }}
{{ $color := partial "helpers/funcs/color-from-string.html" (dict "text" $text "dark" . ) }}
{{ with $tags }}
<div class="mb-4 sm:mb-6 flex flex-wrap gap-2">
{{ range . }}
{{ $text := .LinkTitle }}
{{ $class := "" }}
{{ range (slice true false ) }}
{{ $color := partial "helpers/funcs/color-from-string.html" (dict "text" $text "dark" . "--single" "green" ) }}
{{ $prefix := "" }}
{{ if . }}
{{ $prefix = "dark:" }}
{{ $prefix := "" }}
{{ if . }}
{{ $prefix = "dark:" }}
{{ end }}
{{ $class = printf "%sbg-%s-%d %stext-%s-%d border %sborder-%s-%d"
$prefix $color.color $color.shade1
$prefix $color.color $color.shade2
$prefix $color.color $color.shade3
}}
{{ end }}
<a
href="{{ .RelPermalink }}"
class="{{ $class }} text-xs h-auto tracking-widest uppercase font-light not-prose no-underline inline-block py-1 px-3 rounded-xl shadow-xs hover:opacity-80 hover:shadow-none">
{{ .LinkTitle }}
</a>
{{ end }}
{{ $class = printf "%sbg-%s-%d %stext-%s-%d border %sborder-%s-%d"
$prefix $color.color $color.shade1
$prefix $color.color $color.shade2
$prefix $color.color $color.shade2
}}
{{ end }}
<a
href="{{ .RelPermalink }}"
class="{{ $class }} not-prose text-xs font-semibold no-underline inline-block py-1 px-2 rounded-sm uppercase last:mr-0 mr-1 hover:opacity-75 hover:shadow-none">
{{ .LinkTitle | upper }}
</a>
</div>
{{ end }}
{{ $t.Stop }}
{{ if .Params.action.signatures }}
<div class="mb-6 sm:mb-8 not-prose">
<div class="mb-4 not-prose">
{{- partial "docs/functions-signatures.html" . -}}
{{- partial "docs/functions-return-type.html" . -}}
{{- partial "docs/functions-aliases.html" . -}}
@ -56,9 +60,12 @@
{{ end }}
{{ define "rightsidebar_content" }}
{{/* in-this-section.html depends on these being reneredc first. */}}
{{ $related := partial "layouts/related.html" . }}
{{ $toc := partial "layouts/toc.html" . }}
{{ if not .Params.hide_in_this_section }}
{{ partial "layouts/in-this-section.html" . }}
{{ end }}
{{ partial "layouts/related.html" . }}
{{ partial "layouts/toc.html" . }}
{{ $related }}
{{ $toc }}
{{ end }}

View File

@ -35,7 +35,7 @@
>
{{ end }}
<div class="-my-5 mr-6 sm:mr-8 md:mr-0">
{{ partial "layouts/search/input-standalone.html" . }}
{{ partial "layouts/search/button.html" (dict "page" . "standalone" true) }}
</div>
</div>
</div>

View File

@ -5,7 +5,7 @@
{{- end }}
<p class="font-bold text-dark dark:text-light mt-2">{{ $label }}</p>
{{- range . }}
<div class="font-sm font-mono px-3 p-2 ml-4 sm:ml-8 mt-0 sm:mt-2">
<div class="font-sm font-mono ml-3 sm:ml-6 mt-0 sm:mt-1">
{{- . -}}
</div>
{{- end }}

View File

@ -1,6 +1,6 @@
{{- with .Params.action.returnType }}
<p class="font-bold text-dark dark:text-light mt-2">Returns</p>
<div class="font-sm font-mono px-3 p-2 ml-4 sm:ml-8 mt-0 sm:mt-2">
<div class="font-sm font-mono ml-3 sm:ml-6 mt-0 sm:mt-1">
{{- . -}}
</div>
{{- end -}}

View File

@ -5,7 +5,7 @@
{{- if $.Params.function.returnType }}
{{- $signature = printf "%s ⟼ %s" . $.Params.function.returnType }}
{{- end }}
<div class="font-sm font-mono px-3 p-2 ml-4 sm:ml-8 mt-0 sm:mt-2">
<div class="font-sm font-mono ml-3 sm:ml-6 mt-0 sm:mt-1">
{{- $signature -}}
</div>
{{- end }}

View File

@ -1,7 +1,11 @@
{{ $colors := slice "blue" "orange" "green" "pink" }}
{{ $shades := slice 200 300 500 }}
{{ if .dark }}
{{ $shades = slice 700 800 900 }}
{{ $colors := slice "slate" "green" "cyan" "blue" }}
{{ with .single }}
{{ $colors = slice . }}
{{ end }}
{{ $shades := slice 300 400 500 }}
{{ if not .dark }}
{{ $shades = slice 700 800 }}
{{ end }}
{{ $hash := (hash.FNV32a .text) }}
{{ $i := mod $hash (len $colors) }}
@ -9,10 +13,13 @@
{{ $color := index $colors $i }}
{{ $shade1 := index $shades $j }}
{{ $shade2 := 0 }}
{{ if gt $shade1 400 }}
{{ $shade2 = math.Min (sub $shade1 400) 100 | int }}
{{ $shade3 := 0 }}
{{ if gt $shade1 500 }}
{{ $shade2 = math.Min (sub $shade1 500) 100 | int }}
{{ $shade3 = sub $shade1 100 }}
{{ else }}
{{ $shade2 = math.Max (add $shade1 400) 800 | int }}
{{ $shade2 = math.Max (add $shade1 500) 700 | int }}
{{ $shade3 = add $shade1 200 }}
{{ end }}
{{ $res := dict "color" $color "shade1" $shade1 "shade2" $shade2 }}
{{ $res := dict "color" $color "shade1" $shade1 "shade2" $shade2 "shade3" $shade3 }}
{{ return $res }}

View File

@ -13,11 +13,11 @@
</div>
<div class="ml-3">
{{ with $title }}
<h3 class="text-base font-medium text-{{ $color }}-800">
<h3 class="text-{{ $color }}-800">
{{ . }}
</h3>
{{ end }}
<div class="mt-2 text-base">
<div class="mt-2">
<p>
{{ $text }}
</p>

View File

@ -5,11 +5,12 @@
<div
x-cloak
x-show="open"
x-transition.opacity.duration.200ms
x-transition:enter.opacity.duration.200ms
x-transition:leave.opacity.duration.300ms
x-trap.inert.noscroll="open"
@keydown.esc.window="open = false"
@click.self="open = false"
class="fixed inset-0 z-30 flex items-end justify-center bg-black/50 pb-8 backdrop-blur-md sm:items-center"
class="fixed inset-0 z-30 flex items-end justify-center bg-black/50 pb-8 backdrop-blur-xs sm:items-center"
role="dialog"
aria-modal="true"
aria-label="Modal">

View File

@ -14,12 +14,16 @@
class="truncate text-blue-600 hover:text-blue-500"
>{{ $p.LinkTitle }}</a
>
{{ template "breadcrumbs-arrow" . }}
{{ if ne $ $documentation }}
{{ template "breadcrumbs-arrow" . }}
{{ end }}
</li>
{{ end }}
{{ if ne $ $documentation }}
<li class="truncate text-gray-700 dark:text-gray-300">
{{ $.LinkTitle }}
</li>
{{ end }}
<li class="truncate text-gray-700 dark:text-gray-300">
{{ $.LinkTitle | title }}
</li>
</ol>
</nav>

View File

@ -2,12 +2,12 @@
<a
href="{{ .html_url | safeURL }}"
target="_blank"
class="font-normal tracking-tight flex items-center bg-gray-200 hover:bg-gray-300 dark:bg-gray-600 dark:hover:bg-gray-700 text-sm text-black dark:text-white h-10 border-none cursor-pointer relative py-1 px-2 rounded-md"
class="font-normal font-mono tracking-tighter flex items-center bg-gray-100 hover:bg-gray-200 dark:bg-gray-600 dark:hover:bg-gray-700 text-sm text-black dark:text-white h-10 border-none cursor-pointer relative py-1 px-2 rounded-md"
aria-label="Star on GitHub">
<svg class="mr-1 fill-gray-800 dark:fill-gray-100 w-5 h-5">
<svg class="mr-[4px] fill-gray-800 dark:fill-gray-100 w-6 h-6">
<use href="#icon--github"></use>
</svg>
<span class="hidden md:inline mr-1">Star</span>
<span class="hidden md:inline mr-[3px]">Star</span>
<span class="hidden md:inline">{{ .stargazers_count }}</span>
<span class="inline md:hidden">
{{ printf "%0.1fk" (div .stargazers_count 1000) }}

View File

@ -1,7 +1,7 @@
<header
x-data="navbar"
class="sticky top-0 z-50 bg-blue-950 flex flex-none flex-wrap items-center justify-between px-4 py-5 shadow-md shadow-slate-900/5 transition duration-500 sm:px-6 lg:px-8 dark:shadow-none"
:class="atTop ? '': 'bg-blue-950/80'">
:class="$store.nav.scroll.atTop ? '': 'bg-blue-950/80'">
<div class="relative flex basis-0 items-cente mr-2 lg:mr-8">
{{ with site.Home }}
<a
@ -36,7 +36,7 @@
{{/* Social. */}}
<div
class="hidden sm:block ml-8 h-6 fill-slate-400 group-hover:fill-slate-500 dark:group-hover:fill-slate-300">
class="hidden sm:block ml-2 sm:ml-6 h-6 fill-slate-400 group-hover:fill-slate-500 dark:group-hover:fill-slate-300">
{{ partial "layouts/header/githubstars.html" . }}
</div>
</div>

View File

@ -5,7 +5,8 @@
}}
{{ $qrBig := partial "partials/_inline/qr" (dict "page" $ "img_class" "w-64 p-4") }}
{{ $t.Stop }}
<div class="hidden lg:block cursor-pointer">
<div
class="hidden lg:block cursor-pointer outline-2 hover:outline-3 outline-blue-500">
{{ partial "layouts/blocks/modal.html" (dict "modal_button" $qr "modal_content" $qrBig "modal_title" (printf "QR code linking to %s" $.Permalink )) }}
</div>

View File

@ -1,10 +1,10 @@
<div class="ml-4 sm:ml-10 flex items-center" x-data>
<div class="ml-2 sm:ml-6 flex items-center" x-data>
<button
@click="$store.nav.userSettings.toggleColorScheme()"
aria-label="Toggle color scheme"
id="theme-toggle"
type="button"
class="inline-flex items-center p-2 bg-accent hover:bg-accent/70 dark:bg-gray-600 dark:hover:bg-gray-700 border border-transparent rounded-full shadow-sm text-white hover:text-gray-200 focus:outline-none focus:ring-2 focus:ring-offset-2 focus:ring-slate-500">
class="inline-flex cursor-pointer items-center p-2 bg-orange-600 hover:bg-orange-700 dark:bg-gray-600 dark:hover:bg-gray-700 border border-transparent rounded-full shadow-sm text-white hover:text-gray-200 focus:outline-none focus:ring-2 focus:ring-offset-2 focus:ring-slate-500">
<svg
aria-hidden="true"
class="w-3 h-3 sm:w-5 sm:h-5"

View File

@ -1,15 +1,18 @@
{{- with .CurrentSection.RegularPages }}
<h2
class="text-base font-semibold tracking-tight text-gray-600 dark:text-gray-400">
{{ "In this section" | title }}
</h2>
{{ $hasTocOrRelated := or ($.Store.Get "hasToc") ($.Store.Get "hasRelated") }}
<div
class="relative my-2
after:absolute after:bottom-0 after:left-0 after:w-full after:h-8 after:bg-gradient-to-t after:from-white dark:after:from-blue-950">
<ul
id="in-sthis-section"
class="max-h-96 pb-8 overflow-y-auto"
data-turbo-preserve-scroll-container="in-this-section">
class="overflow-y-auto {{ if $hasTocOrRelated }}
max-h-96
{{ else }}
sticky top-[8rem] max-h-[70vh]
{{ end }} relative mt-2 mb-8"
data-turbo-preserve-scroll-container="in-this-section">
<h2
class="text-base font-semibold tracking-tight text-gray-600 dark:text-gray-400">
In this section
</h2>
<ul id="in-sthis-section" class="mt-2">
{{- range . }}
<li>
<a

View File

@ -1,6 +1,6 @@
<hr class="border-t border-gray-200 dark:border-gray-800 my-10 lg:my-16" />
<div class="text-gray-800 font-semibold">
<div class="text-gray-800 dark:text-gray-300 font-semibold">
Last updated:
{{ .Lastmod.Format "January 2, 2006" }}{{ with .GitInfo }}
:

View File

@ -1,5 +1,5 @@
{{- $heading := "See also" | title }}
{{- $related := site.RegularPages.Related . | first 5 }}
{{- $heading := "See also" }}
{{- $related := slice }}
{{- if .Params.action.related }}
{{- $related = slice }}
@ -12,13 +12,18 @@
{{- warnf "The 'related' partial was unable to get page %s" . }}
{{- end }}
{{- end }}
{{- else }}
{{- $related = site.RegularPages.Related . }}
{{- end }}
{{/* Avoid repeating pages that's listed in In this section. */}}
{{- $related = $related | complement .CurrentSection.RegularPages | first 7 }}
{{- with $related }}
{{ $.Store.Set "hasRelated" true }}
<h2
class="text-base font-semibold tracking-tight text-gray-600 dark:text-gray-400">
{{ $heading }}
</h2>
<ul class="mb-10 mt-2">
<ul class="mt-2 mb-8">
{{- range . }}
<li>
<a

View File

@ -0,0 +1,19 @@
<button
{{ if .standalone }}
x-data @click="$dispatch('search-toggle')"
{{ else }}
type="button" x-show="!open" x-transition.opacity.duration.500ms
{{ end }}
class="grid cursor-pointer w-full text-gray-500 sm:w-40 lg:w-56 grid-cols-[auto_1fr_auto] items-center gap-3 rounded-md px-4 py-2 text-left text-xs/6 lg:text-sm/6 outline-1 -outline-offset-1 outline-gray-600">
<svg
class="pointer-events-none -ml-0.5 size-4 fill-slate-400 dark:fill-slate-500">
<use href="#icon--search"></use>
</svg>
Search docs<kbd
class="hidden font-sans text-xs/4 text-gray-400 dark:text-gray-400 [.os-macos_&amp;]:block"
><span class="text-gray-400/70"></span>K</kbd
><kbd
class="hidden font-sans text-xs/4 text-gray-400 not-[.os-macos_&amp;]:block dark:text-gray-400"
><span class="text-gray-400/70">Ctrl</span>&nbsp;K</kbd
>
</button>

View File

@ -1,12 +0,0 @@
<div
class="group relative flex h-12"
x-data
@click="$dispatch('search-toggle')">
<svg
class="pointer-events-none sm:absolute left-4 top-0 h-full w-5 fill-slate-400 dark:fill-slate-500">
<use href="#icon--search"></use>
</svg>
<input
class="flex-auto hidden sm:block appearance-none bg-transparent pl-12 text-slate-900 outline-none placeholder:text-slate-400 focus:w-full focus:flex-none sm:text-sm dark:text-white [&::-webkit-search-cancel-button]:hidden [&::-webkit-search-decoration]:hidden [&::-webkit-search-results-button]:hidden [&::-webkit-search-results-decoration]:hidden"
placeholder="Search the Docs..." />
</div>

View File

@ -1,15 +1,4 @@
<div x-data="search">
<div
class="group relative flex h-12"
x-show="!open"
x-transition.opacity.duration.500ms>
<svg
class="pointer-events-none lg:absolute left-4 top-0 h-full w-5 fill-slate-400 dark:fill-slate-500">
<use href="#icon--search"></use>
</svg>
<input
class="hidden lg:block flex-auto appearance-none bg-transparent pl-12 text-slate-900 outline-none placeholder:text-slate-200 focus:w-full focus:flex-none sm:text-sm dark:text-white [&::-webkit-search-cancel-button]:hidden [&::-webkit-search-decoration]:hidden [&::-webkit-search-results-button]:hidden [&::-webkit-search-results-decoration]:hidden"
placeholder="Search the Docs..." />
</div>
<div x-data="search" class="flex w-full">
{{ partial "layouts/search/button.html" (dict "page" . "standalone" false) }}
{{ partial "layouts/search/results.html" . }}
</div>

View File

@ -1,7 +1,7 @@
<div
class="fixed inset-0 overflow-hidden z-20"
:class="{'fixed': open}"
aria-label="Search the Docs"
aria-label="Search docs"
role="dialog"
aria-modal="true"
@keydown.right="$focus.next()"
@ -32,7 +32,7 @@
@click="search()"
type="search"
class="text-gray-800 dark:text-gray-100 bg-white/40 dark:bg-gray-900 shadow rounded border-0 p-3 w-full"
placeholder="Search the Docs..."
placeholder="Search docs"
x-ref="input" />
</div>
</div>

View File

@ -1,10 +1,11 @@
{{ with .Fragments.Headings }}
{{ $.Store.Set "hasToc" true }}
<div
x-data="toc"
class="sticky top-[8rem] h-screen overflow-y-auto overflow-x-hidden">
<h2
class="text-base font-semibold tracking-tight text-gray-600 dark:text-gray-400">
{{ "On this page" | title }}
On this page
</h2>
<nav class="w-56 mt-2">
<ul>

View File

@ -60,41 +60,50 @@
{{- else }}
{{- $code = $.Inner }}
{{- end }}
{{ $langs := (slice "yaml" "toml" "json") }}
<div
x-data
class="shortcode-code not-prose relative border-1 border-gray-300 dark:border-gray-900 p-0 my-2 sm:my-6 min-h-30">
<div>
<svg
class="absolute right-0 top-2 pr-3 z-30 text-blue-600 hover:text-blue-500 cursor-pointer w-10"
@click="$copy($refs[$store.nav.userSettings.settings.configFileType])">
<use href="#icon--copy"></use>
</svg>
<nav class="relative flex" aria-label="Tabs">
{{ range $i, $lang := $langs }}
<button
x-on:click="$store.nav.userSettings.settings.configFileType = '{{ index $langs $i }}'"
aria-label="{{ printf `Toggle %s` . }}"
class="p-3 text-white font-semibold dark:text-gray-300 hover:text-gray-100 dark:hover:text-gray-100 bg-blue-500 dark:bg-blue-900 hover:bg-blue-300 dark:hover:bg-slate-700 cursor-pointer relative min-w-0 flex-1 overflow-hidden text-sm no-underline text-center focus:z-10 overflow-x-auto">
<span>
{{ printf "%s.%s" $file . }}
</span>
<span
aria-hidden="true"
class="absolute inset-x-0 bottom-0 h-0.75"
:class="$store.nav.userSettings.settings.configFileType === '{{ index $langs $i }}' ? 'bg-accent dark:bg-accent-dark' : 'bg-transparent'"></span>
</button>
{{ end }}
</nav>
{{ if $code }}
{{ range $i, $lang := $langs }}
<div
class="max-h-96 overflow-y-auto"
x-ref="{{ $lang }}"
:class="$store.nav.userSettings.settings.configFileType === '{{ index $langs $i }}' ? 'block' : 'hidden'">
{{ highlight ($code | transform.Remarshal . | safeHTML) . "" }}
</div>
{{ end }}
<div x-data class="shortcode-code not-prose relative p-0 mt-2 mb-4 sm:mb-8">
<svg
class="absolute right-2 top-0 z-30 text-blue-600 hover:text-blue-500 cursor-pointer w-8"
@click="$copy($refs[$store.nav.userSettings.settings.configFileType])">
<use href="#icon--copy"></use>
</svg>
<nav class="relative flex" aria-label="Tabs">
{{ with $file }}
<div
class="flex-none text-sm px-2 content-center border-b-1 border-gray-300 dark:border-gray-700"
aria-lbabel="Filename">
{{ . }}{{ if not $fm }}.{{ end }}
</div>
{{ end }}
</div>
{{ range $i, $lang := $langs }}
{{ $isLast := eq (add $i 1) (len $langs) }}
<button
x-on:click="$store.nav.userSettings.settings.configFileType = '{{ index $langs $i }}'"
aria-label="{{ printf `Toggle %s` . }}"
class="px-3 py-2 font-semibold text-black dark:text-slate-200 border-l-1 border-t-1 {{ if $isLast }}
border-r-1
{{ end }} border-gray-300 hover:bg-gray-100 dark:hover:bg-gray-800 dark:border-gray-700 cursor-pointer relative min-w-0 flex-1 overflow-hidden text-sm no-underline text-center focus:z-10 overflow-x-auto"
:class="$store.nav.userSettings.settings.configFileType === '{{ index $langs $i }}' ? 'border-b-0 bg-light dark:bg-dark' : 'border-b-1'">
<span>
{{ . }}
</span>
</button>
{{ end }}
</nav>
{{ if $code }}
{{ range $i, $lang := $langs }}
<div
class="max-h-96 overflow-y-auto border-l-1 border-b-1 border-r-1 border-gray-300 dark:border-gray-700"
x-ref="{{ $lang }}"
x-cloak
x-transition:enter.opacity.duration.300ms
x-show="$store.nav.userSettings.settings.configFileType === '{{ index $langs $i }}'">
{{- $hCode := $code | transform.Remarshal . }}
{{- if and $fm (in (slice "toml" "yaml") .) }}
{{- $hCode = printf "%s\n%s\n%s" $placeHolder $hCode $placeHolder }}
{{- end }}
{{- $hCode = $hCode | replaceRE `\n+` "\n" }}
{{ highlight $hCode . "" | replaceRE $placeHolder (index $delimiters .) | safeHTML }}
</div>
{{ end }}
{{ end }}
</div>

View File

@ -1,20 +1,26 @@
{{ $codeLang := "go-html-template" }}
{{- $codeLang := or (.Get "lang") "" }}
<div
x-data
class="shortcode-code font-mono not-prose relative bg-gray-200 dark:bg-blue-900 text-gray-500 p-[1px] dark:text-gray-400 mt-6 mb-8">
{{- with .Get "file" -}}
<div class="san-serif text-sm inline-block leading-none pl-2 py-3">
{{ . }}
</div>
{{- end -}}
{{ if ne (.Get "copy") "false" }}
class="shortcode-code font-mono not-prose relative mt-6 mb-8 border-1 border-gray-200 bg-light">
{{ if (.Get "copy") }}
<svg
class="absolute right-0 top-2 pr-3 z-30 text-blue-600 hover:text-blue-500 cursor-pointer w-10"
class="absolute right-2 top-2 z-30 text-blue-600 hover:text-blue-500 cursor-pointer w-6 h-6"
@click="$copy($refs.code)">
<use href="#icon--copy"></use>
</svg>
{{ end }}
{{- with .Get "file" -}}
{{- if not $codeLang }}
{{- $ext := strings.TrimPrefix "." (path.Ext .) }}
{{- $codeLang = cond (eq $ext "html") "go-html-template" $ext }}
{{- end }}
<div
class="san-serif text-sm inline-block leading-none pl-2 py-3 bg-gray-100 w-full">
{{ . }}
</div>
{{- end -}}
<div class="" x-ref="code">
{{ $inner := trim .Inner "\n" | safeHTML }}
{{ if .Get "nocode" }}
@ -23,7 +29,8 @@
{{ with $codeLang }}
{{ highlight $inner . "" }}
{{ else }}
<pre><code>{{ $inner }}</code></pre>
<pre class="overflow-x-auto p-2 w-[93%]"><code>{{ $inner }}</code>
</pre>
{{ end }}
{{ end }}
</div>

View File

@ -1,23 +1,22 @@
{{- /*
Renders a "new in" button indicating the version in which a feature was added.
Renders a "new in" button indicating the version in which a feature was added.
When comparing the current version to the specified version, the "new in"
button will be hidden if any of the following conditions is true:
When comparing the current version to the specified version, the "new in"
button will be hidden if any of the following conditions is true:
- The major version difference exceeds the majorVersionDiffThreshold
- The minor version difference exceeds the minorVersionDiffThreshold
- The major version difference exceeds the majorVersionDiffThreshold
- The minor version difference exceeds the minorVersionDiffThreshold
@param {string} version The semantic version string, with or without a leading v.
@returns {template.HTML}
@param {string} version The semantic version string, with or without a leading v.
@returns {template.HTML}
@examples {{< new-in 0.100.0 />}}
@examples {{< new-in 0.100.0 /
>}}
{{< new-in 0.100.0 >}}
Some descriptive text here.
{{< /new-in >}}
{{< new-in 0.100.0 >}}
Some descriptive text here.
{{< /new-in >}}
*/}}
{{ $_hugo_config := `{ "version": 1 }` }}
{{- /* Set defaults. */}}
@ -36,14 +35,30 @@ button will be hidden if any of the following conditions is true:
{{- else }}
{{- $href := printf "https://github.com/gohugoio/hugo/releases/tag/v%s" $version }}
{{- with $.Inner }}
<aside>
<div class="admonition-content bl bw2 b--blue" >
<p>New in <a href="{{ $href }}">v{{ $version }}</a>.</p>
{{ . | $.Page.RenderString (dict "display" "block") }}
</div>
</aside>
{{ $text := printf `<p class="fon-semibold">New in <a href=%q>v%s</a>.</p>%s`
$href $version (. | $.Page.RenderString (dict "display" "block"))
}}
{{ partial "layouts/blocks/alert.html" (dict
"text" ($text | safeHTML)
"color" "green"
"icon" "exclamation"
)
}}
{{- else }}
<a class="dib f5 fw6 ba bw1 b--gray ph2 mt1" href="{{ $href }}">New in v{{ $version }}</a>
<span
class="not-prose inline-flex items-center px-2 mr-1 rounded text-sm font-medium bg-green-200 dark:bg-green-400 fill-green-600">
<svg class="mr-1.5 h-2 w-2" viewBox="0 0 8 8">
<circle cx="4" cy="4" r="3" />
</svg>
<a
class="text-green-800 dark:text-black hover:text-green-600 no-underline"
href="{{ $href }}"
target="_blank">
New in
v{{ $version }}
</a>
</span>
{{- end }}
{{- end }}
{{- else }}

View File

@ -16,7 +16,7 @@
HUGO_ENV = "production"
[context.deploy-preview]
command = "hugo --gc --minify --buildFuture -b $DEPLOY_PRIME_URL"
command = "hugo --gc --minify --buildFuture -b $DEPLOY_PRIME_URL --enableGitInfo"
[context.branch-deploy]
command = "hugo --gc --minify -b $DEPLOY_PRIME_URL"