refactor: standardize all Hugo templates — consistent landmark structure
All templates now follow: body > nav > article > header + content + footer Removed: - <hgroup> (redundant, header+h1+p serves same purpose) - <main> (article is the content landmark) - role="main" on article (incorrect ARIA) - header block in baseof (header now inside article) Standardized: default, docs, essay, notes, console, page, list, index. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
This commit is contained in:
parent
080acfebb7
commit
21524b4b25
10 changed files with 156 additions and 258 deletions
|
|
@ -5,10 +5,9 @@
|
|||
</head>
|
||||
<body>
|
||||
{{ partial "nav.html" . }}
|
||||
{{ block "header" . }}{{ end }}
|
||||
{{ block "content" . }}{{ end }}
|
||||
<footer>
|
||||
<small><a href="/">{{ .Site.Title }}</a> · {{ now.Format "2006" }}</small>
|
||||
<a href="/">{{ .Site.Title }}</a> · {{ now.Format "2006" }}
|
||||
</footer>
|
||||
</body>
|
||||
</html>
|
||||
|
|
|
|||
|
|
@ -1,24 +1,26 @@
|
|||
{{ define "header" }}
|
||||
{{ define "content" }}
|
||||
<article>
|
||||
<header>
|
||||
<h1>{{ .Title }}</h1>
|
||||
{{ with .Description }}<p>{{ . }}</p>{{ end }}
|
||||
{{- with .Description }}
|
||||
<p>{{ . }}</p>
|
||||
{{- end }}
|
||||
</header>
|
||||
{{ end }}
|
||||
|
||||
{{ define "content" }}
|
||||
<article role="main">
|
||||
<section>
|
||||
{{ .Content }}
|
||||
|
||||
{{ range .Pages }}
|
||||
<article>
|
||||
<header>
|
||||
<h2><a href="{{ .Permalink }}">{{ .Title }}</a></h2>
|
||||
{{- if not .Date.IsZero }}
|
||||
<p data-text="dim">
|
||||
<time datetime="{{ .Date.Format "2006-01-02" }}">{{ .Date.Format "January 2006" }}</time>
|
||||
</p>
|
||||
{{- end }}
|
||||
</header>
|
||||
{{ with .Summary }}<p>{{ . }}</p>{{ end }}
|
||||
{{- with .Description }}<p>{{ . }}</p>{{ end }}
|
||||
</article>
|
||||
{{ end }}
|
||||
</section>
|
||||
</article>
|
||||
{{ end }}
|
||||
|
|
|
|||
|
|
@ -1,23 +1,39 @@
|
|||
{{ define "header" }}
|
||||
<header>
|
||||
{{ with .Type }}<p data-text="eyebrow">{{ . }}</p>{{ end }}
|
||||
<p data-text="dim">
|
||||
<time datetime="{{ .Date.Format "2006-01-02" }}">{{ .Date.Format "January 2006" }}</time>
|
||||
{{ with .Params.author }} · {{ . }}{{ end }}
|
||||
</p>
|
||||
{{ with .Params.tags }}
|
||||
<p>{{ range . }}<a href="/tags/{{ . }}" data-text="tag">#{{ . }}</a> {{ end }}</p>
|
||||
{{ end }}
|
||||
</header>
|
||||
{{ end }}
|
||||
|
||||
{{ define "content" }}
|
||||
<article role="main">
|
||||
<article>
|
||||
<header>
|
||||
<h1>{{ .Title }}</h1>
|
||||
{{- with .Description }}
|
||||
<p>{{ . }}</p>
|
||||
{{- end }}
|
||||
{{- if or (not .Date.IsZero) .Params.author }}
|
||||
<p data-text="dim">
|
||||
{{- if not .Date.IsZero -}}
|
||||
<time datetime="{{ .Date.Format "2006-01-02" }}">{{ .Date.Format "January 2, 2006" }}</time>
|
||||
{{- end -}}
|
||||
{{- if and (not .Date.IsZero) .Params.author }} · {{ end -}}
|
||||
{{- with .Params.author }}{{ . }}{{ end -}}
|
||||
</p>
|
||||
{{- end }}
|
||||
{{- with .GetTerms "tags" }}
|
||||
<nav aria-label="Tags">
|
||||
{{- range . }}
|
||||
<a href="{{ .Permalink }}">#{{ .Name }}</a>
|
||||
{{- end }}
|
||||
</nav>
|
||||
{{- end }}
|
||||
</header>
|
||||
|
||||
{{ .Content }}
|
||||
{{ with .Params.footer }}
|
||||
|
||||
{{- if or .PrevInSection .NextInSection }}
|
||||
<footer>
|
||||
<small>{{ . }}</small>
|
||||
{{- with .PrevInSection }}
|
||||
<a href="{{ .RelPermalink }}" rel="prev"><span aria-hidden="true">←</span> {{ .LinkTitle }}</a>
|
||||
{{- end }}
|
||||
{{- with .NextInSection }}
|
||||
<a href="{{ .RelPermalink }}" rel="next">{{ .LinkTitle }} <span aria-hidden="true">→</span></a>
|
||||
{{- end }}
|
||||
</footer>
|
||||
{{ end }}
|
||||
{{- end }}
|
||||
</article>
|
||||
{{ end }}
|
||||
|
|
|
|||
|
|
@ -1,51 +1,12 @@
|
|||
{{ define "header" }}
|
||||
<header>
|
||||
{{- if .Description -}}
|
||||
<hgroup>
|
||||
<h1>{{ .Title }}</h1>
|
||||
<p>{{ .Description }}</p>
|
||||
</hgroup>
|
||||
{{- else -}}
|
||||
<h1>{{ .Title }}</h1>
|
||||
{{- end }}
|
||||
</header>
|
||||
{{ end }}
|
||||
|
||||
{{ define "content" }}
|
||||
<section data-layout="console">
|
||||
|
||||
<nav aria-label="Documentation" data-nav="sidebar">
|
||||
{{- $menu := index .Site.Menus "docs" -}}
|
||||
{{- if $menu -}}
|
||||
{{- range $menu -}}
|
||||
{{- if .HasChildren -}}
|
||||
<h3>{{ .Name }}</h3>
|
||||
<ul>
|
||||
{{- range .Children -}}
|
||||
<li>
|
||||
<a href="{{ .URL }}"
|
||||
{{- if eq (relURL .URL) $.RelPermalink }} aria-current="page"{{ end -}}>
|
||||
{{- .Name -}}
|
||||
</a>
|
||||
</li>
|
||||
{{- end -}}
|
||||
</ul>
|
||||
{{- else -}}
|
||||
<ul>
|
||||
<li>
|
||||
<a href="{{ .URL }}"
|
||||
{{- if eq (relURL .URL) $.RelPermalink }} aria-current="page"{{ end -}}>
|
||||
{{- .Name -}}
|
||||
</a>
|
||||
</li>
|
||||
</ul>
|
||||
{{- end -}}
|
||||
{{- end -}}
|
||||
{{- else -}}
|
||||
{{- with .CurrentSection -}}
|
||||
{{- $top := .FirstSection -}}
|
||||
{{- range $top.Sections.ByWeight -}}
|
||||
<h3>{{ .Title }}</h3>
|
||||
<ul>
|
||||
{{- range .RegularPages -}}
|
||||
{{- range .RegularPages.ByWeight -}}
|
||||
<li>
|
||||
<a href="{{ .RelPermalink }}"
|
||||
{{- if eq .RelPermalink $.RelPermalink }} aria-current="page"{{ end -}}>
|
||||
|
|
@ -55,33 +16,22 @@
|
|||
{{- end -}}
|
||||
</ul>
|
||||
{{- end -}}
|
||||
{{- end -}}
|
||||
</nav>
|
||||
|
||||
<article>
|
||||
{{ .Content }}
|
||||
<header>
|
||||
<h1>{{ .Title }}</h1>
|
||||
{{- with .Description }}
|
||||
<p>{{ . }}</p>
|
||||
{{- end }}
|
||||
</header>
|
||||
|
||||
{{- if or .PrevInSection .NextInSection -}}
|
||||
<footer data-role="prev-next">
|
||||
{{- with .NextInSection -}}
|
||||
<a href="{{ .RelPermalink }}" rel="prev">
|
||||
<span aria-hidden="true">←</span> Previous
|
||||
<span>{{ .LinkTitle }}</span>
|
||||
</a>
|
||||
{{- end -}}
|
||||
{{- with .PrevInSection -}}
|
||||
<a href="{{ .RelPermalink }}" rel="next">
|
||||
Next <span aria-hidden="true">→</span>
|
||||
<span>{{ .LinkTitle }}</span>
|
||||
</a>
|
||||
{{- end -}}
|
||||
</footer>
|
||||
{{- end -}}
|
||||
{{ .Content }}
|
||||
</article>
|
||||
|
||||
{{- with .TableOfContents -}}
|
||||
<aside data-toc>
|
||||
<h3>On this page</h3>
|
||||
<h3>{{ i18n "onThisPage" | default "On this page" }}</h3>
|
||||
{{ . }}
|
||||
</aside>
|
||||
{{- end -}}
|
||||
|
|
|
|||
|
|
@ -1,16 +1,3 @@
|
|||
{{ define "header" }}
|
||||
<header>
|
||||
{{- if .Description -}}
|
||||
<hgroup>
|
||||
<h1>{{ .Title }}</h1>
|
||||
<p>{{ .Description }}</p>
|
||||
</hgroup>
|
||||
{{- else -}}
|
||||
<h1>{{ .Title }}</h1>
|
||||
{{- end }}
|
||||
</header>
|
||||
{{ end }}
|
||||
|
||||
{{ define "content" }}
|
||||
<section data-layout="docs">
|
||||
|
||||
|
|
@ -32,20 +19,25 @@
|
|||
</nav>
|
||||
|
||||
<article>
|
||||
<header>
|
||||
<h1>{{ .Title }}</h1>
|
||||
{{- with .Description }}
|
||||
<p>{{ . }}</p>
|
||||
{{- end }}
|
||||
</header>
|
||||
|
||||
{{ .Content }}
|
||||
|
||||
{{- if or .PrevInSection .NextInSection -}}
|
||||
<footer data-role="prev-next">
|
||||
<footer>
|
||||
{{- with .NextInSection -}}
|
||||
<a href="{{ .RelPermalink }}" rel="prev">
|
||||
<span aria-hidden="true">←</span> Previous
|
||||
<span>{{ .LinkTitle }}</span>
|
||||
<span aria-hidden="true">←</span> {{ .LinkTitle }}
|
||||
</a>
|
||||
{{- end -}}
|
||||
{{- with .PrevInSection -}}
|
||||
<a href="{{ .RelPermalink }}" rel="next">
|
||||
Next <span aria-hidden="true">→</span>
|
||||
<span>{{ .LinkTitle }}</span>
|
||||
{{ .LinkTitle }} <span aria-hidden="true">→</span>
|
||||
</a>
|
||||
{{- end -}}
|
||||
</footer>
|
||||
|
|
|
|||
|
|
@ -1,38 +1,38 @@
|
|||
{{ define "header" }}
|
||||
{{ define "content" }}
|
||||
<article data-paper>
|
||||
<header>
|
||||
{{- with .Params.eyebrow }}<p data-text="eyebrow">{{ . }}</p>{{ end }}
|
||||
<h1>{{ .Title }}</h1>
|
||||
{{ with .Description }}<p data-abstract>{{ . }}</p>{{ end }}
|
||||
{{- $hasDate := not .Date.IsZero -}}
|
||||
{{- $hasAuthor := .Params.author -}}
|
||||
{{- if or $hasDate $hasAuthor -}}
|
||||
{{- with .Params.abstract }}
|
||||
<p data-abstract>{{ . }}</p>
|
||||
{{- end }}
|
||||
{{- if or (not .Date.IsZero) .Params.author }}
|
||||
<p data-byline>
|
||||
{{- if $hasDate -}}
|
||||
{{- if not .Date.IsZero -}}
|
||||
<time datetime="{{ .Date.Format "2006-01-02" }}">{{ .Date.Format "January 2, 2006" }}</time>
|
||||
{{- end -}}
|
||||
{{- if and $hasDate $hasAuthor }} · {{ end -}}
|
||||
{{- if and (not .Date.IsZero) .Params.author }} · {{ end -}}
|
||||
{{- with .Params.author }}{{ . }}{{ end -}}
|
||||
</p>
|
||||
{{- end }}
|
||||
{{- with .GetTerms "tags" }}
|
||||
<nav data-role="tag-cloud" aria-label="Tags">
|
||||
{{- range . }}
|
||||
<a href="{{ .Permalink }}" data-tag="{{ .Name }}">{{ .Name }}</a>
|
||||
<a href="{{ .Permalink }}">{{ .Name }}</a>
|
||||
{{- end }}
|
||||
</nav>
|
||||
{{- end }}
|
||||
</header>
|
||||
{{ end }}
|
||||
|
||||
{{ define "content" }}
|
||||
<article role="main">
|
||||
{{ .Content }}
|
||||
|
||||
{{- if or .PrevInSection .NextInSection }}
|
||||
<footer>
|
||||
{{- with .PrevInSection }}
|
||||
<a href="{{ .RelPermalink }}" rel="prev">← {{ .LinkTitle }}</a>
|
||||
<a href="{{ .RelPermalink }}" rel="prev"><span aria-hidden="true">←</span> {{ .LinkTitle }}</a>
|
||||
{{- end }}
|
||||
{{- with .NextInSection }}
|
||||
<a href="{{ .RelPermalink }}" rel="next">{{ .LinkTitle }} →</a>
|
||||
<a href="{{ .RelPermalink }}" rel="next">{{ .LinkTitle }} <span aria-hidden="true">→</span></a>
|
||||
{{- end }}
|
||||
</footer>
|
||||
{{- end }}
|
||||
|
|
|
|||
|
|
@ -1,28 +1,26 @@
|
|||
{{ define "title" }}{{ .Site.Title }}{{ end }}
|
||||
|
||||
{{ define "header" }}
|
||||
{{ define "content" }}
|
||||
<article>
|
||||
<header>
|
||||
<hgroup>
|
||||
<h1>{{ .Site.Title }}</h1>
|
||||
<p>{{ .Site.Params.description | default "An agent-first approach to web generation." }}</p>
|
||||
</hgroup>
|
||||
</header>
|
||||
{{ end }}
|
||||
|
||||
{{ define "content" }}
|
||||
<article role="main">
|
||||
{{ .Content }}
|
||||
|
||||
<section>
|
||||
<h2>Recent</h2>
|
||||
{{ range first 10 .Site.RegularPages }}
|
||||
<article>
|
||||
<header>
|
||||
<h3><a href="{{ .Permalink }}">{{ .Title }}</a></h3>
|
||||
{{- if not .Date.IsZero }}
|
||||
<p data-text="dim">
|
||||
<time datetime="{{ .Date.Format "2006-01-02" }}">{{ .Date.Format "January 2006" }}</time>
|
||||
{{ with .Params.eyebrow }} · {{ . }}{{ end }}
|
||||
{{- with .Params.eyebrow }} · {{ . }}{{ end }}
|
||||
</p>
|
||||
{{- end }}
|
||||
</header>
|
||||
{{ with .Summary }}<p>{{ . }}</p>{{ end }}
|
||||
{{- with .Description }}<p>{{ . }}</p>{{ end }}
|
||||
</article>
|
||||
{{ end }}
|
||||
</section>
|
||||
|
|
|
|||
|
|
@ -1,14 +1,11 @@
|
|||
{{ define "header" }}
|
||||
<header>
|
||||
<hgroup>
|
||||
<h1>{{ .Title }}</h1>
|
||||
{{ with .Description }}<p>{{ . }}</p>{{ end }}
|
||||
</hgroup>
|
||||
</header>
|
||||
{{ end }}
|
||||
|
||||
{{ define "content" }}
|
||||
<main>
|
||||
<article>
|
||||
<header>
|
||||
<h1>{{ .Title }}</h1>
|
||||
{{- with .Description }}
|
||||
<p>{{ . }}</p>
|
||||
{{- end }}
|
||||
</header>
|
||||
{{ .Content }}
|
||||
</main>
|
||||
</article>
|
||||
{{ end }}
|
||||
|
|
|
|||
|
|
@ -1,52 +1,11 @@
|
|||
{{ define "header" }}
|
||||
<header>
|
||||
{{- if .Description -}}
|
||||
<hgroup>
|
||||
<h1>{{ .Title }}</h1>
|
||||
<p>{{ .Description }}</p>
|
||||
</hgroup>
|
||||
{{- else -}}
|
||||
<h1>{{ .Title }}</h1>
|
||||
{{- end }}
|
||||
</header>
|
||||
{{ end }}
|
||||
|
||||
{{ define "content" }}
|
||||
<section data-layout="docs">
|
||||
|
||||
<nav aria-label="Notes" data-nav="sidebar">
|
||||
{{- $menuName := .Site.Params.notes_menu | default "notes" -}}
|
||||
{{- $menu := index .Site.Menus $menuName -}}
|
||||
{{- if $menu -}}
|
||||
{{- range $menu -}}
|
||||
{{- if .HasChildren -}}
|
||||
<h3>{{ .Name }}</h3>
|
||||
<ul>
|
||||
{{- range .Children -}}
|
||||
<li>
|
||||
<a href="{{ .URL }}"
|
||||
{{- if $.IsMenuCurrent $menuName . }} aria-current="page"{{ end -}}>
|
||||
{{- .Name -}}
|
||||
</a>
|
||||
</li>
|
||||
{{- end -}}
|
||||
</ul>
|
||||
{{- else -}}
|
||||
<ul>
|
||||
<li>
|
||||
<a href="{{ .URL }}"
|
||||
{{- if $.IsMenuCurrent $menuName . }} aria-current="page"{{ end -}}>
|
||||
{{- .Name -}}
|
||||
</a>
|
||||
</li>
|
||||
</ul>
|
||||
{{- end -}}
|
||||
{{- end -}}
|
||||
{{- else -}}
|
||||
{{- with .CurrentSection -}}
|
||||
<h3>{{ .Title }}</h3>
|
||||
<ul>
|
||||
{{- range .RegularPages -}}
|
||||
{{- range .RegularPages.ByWeight -}}
|
||||
<li>
|
||||
<a href="{{ .RelPermalink }}"
|
||||
{{- if eq .RelPermalink $.RelPermalink }} aria-current="page"{{ end -}}>
|
||||
|
|
@ -56,32 +15,17 @@
|
|||
{{- end -}}
|
||||
</ul>
|
||||
{{- end -}}
|
||||
{{- end -}}
|
||||
</nav>
|
||||
|
||||
<article>
|
||||
{{ .Content }}
|
||||
<header>
|
||||
<h1>{{ .Title }}</h1>
|
||||
{{- with .Description }}
|
||||
<p>{{ . }}</p>
|
||||
{{- end }}
|
||||
</header>
|
||||
|
||||
{{- $prevURL := index .Params "prev-url" -}}
|
||||
{{- $prevTitle := index .Params "prev-title" -}}
|
||||
{{- $nextURL := index .Params "next-url" -}}
|
||||
{{- $nextTitle := index .Params "next-title" -}}
|
||||
{{- if or $prevURL $nextURL -}}
|
||||
<footer data-role="prev-next">
|
||||
{{- if $prevURL -}}
|
||||
<a href="{{ $prevURL }}" rel="prev">
|
||||
<span aria-hidden="true">←</span> Previous
|
||||
<span>{{ $prevTitle }}</span>
|
||||
</a>
|
||||
{{- end -}}
|
||||
{{- if and $nextURL $nextTitle -}}
|
||||
<a href="{{ $nextURL }}" rel="next">
|
||||
Next <span aria-hidden="true">→</span>
|
||||
<span>{{ $nextTitle }}</span>
|
||||
</a>
|
||||
{{- end -}}
|
||||
</footer>
|
||||
{{- end -}}
|
||||
{{ .Content }}
|
||||
</article>
|
||||
|
||||
{{- with .TableOfContents -}}
|
||||
|
|
|
|||
|
|
@ -1,11 +1,11 @@
|
|||
{{ define "header" }}{{ end }}
|
||||
|
||||
{{ define "content" }}
|
||||
<main>
|
||||
<article>
|
||||
<header>
|
||||
<h1>{{ .Title }}</h1>
|
||||
{{- with .Description }}<p>{{ . }}</p>{{ end }}
|
||||
{{- with .Description }}
|
||||
<p>{{ . }}</p>
|
||||
{{- end }}
|
||||
</header>
|
||||
{{ .Content }}
|
||||
</main>
|
||||
</article>
|
||||
{{ end }}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue