Skip to content

Commit

Permalink
theme: replace output-partial by Hugo mechanisms #891
Browse files Browse the repository at this point in the history
  • Loading branch information
McShelby committed Sep 13, 2024
1 parent 88042b9 commit c1820d6
Show file tree
Hide file tree
Showing 65 changed files with 222 additions and 345 deletions.
2 changes: 1 addition & 1 deletion archetypes/chapter.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
+++
archetype = "chapter"
title = "{{ replace .Name "-" " " | title }}"
type = "chapter"
weight = 1
+++

Expand Down
2 changes: 1 addition & 1 deletion archetypes/home.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
+++
archetype = "home"
title = "{{ replace .Name "-" " " | title }}"
type = "home"
+++

This is a new home page.
2 changes: 1 addition & 1 deletion assets/css/format-print.css
Original file line number Diff line number Diff line change
Expand Up @@ -137,7 +137,7 @@ h1 + .footline{
#R-body .topbar-sidebar-divider {
border-width: 0;
}
.term-list {
article .R-taxonomy {
display: none;
}
mark.search {
Expand Down
8 changes: 4 additions & 4 deletions assets/css/variant.css
Original file line number Diff line number Diff line change
Expand Up @@ -404,21 +404,21 @@ pre:not(.mermaid) .copy-to-clipboard-button:hover {
--VARIABLE-BOX-TEXT-color: var(--VARIABLE-BOX-CAPTION-color);
}

#R-body .tags {
article .R-taxonomy.tags {
--VARIABLE-TAGS-color: var(--INTERNAL-MAIN-BG-color);
--VARIABLE-TAGS-BG-color: var(--VARIABLE-BOX-color);
}

#R-body .tags a.term-link {
article .R-taxonomy.tags a.term-link {
background-color: var(--VARIABLE-TAGS-BG-color);
color: var(--VARIABLE-TAGS-color);
}

#R-body .tags a.term-link:before {
article .R-taxonomy.tags a.term-link:before {
border-right-color: var(--VARIABLE-TAGS-BG-color);
}

#R-body .tags a.term-link:after {
article .R-taxonomy.tags a.term-link:after {
background-color: var(--VARIABLE-TAGS-color);
}

Expand Down
2 changes: 1 addition & 1 deletion exampleSite/content/_index.en.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
+++
archetype = "home"
description = "A theme for Hugo designed for documentation."
title = "Hugo Relearn Theme"
type = "home"
+++
{{% replaceRE "https://mcshelby.github.io/hugo-theme-relearn/" "" %}}
{{< include "README.md" "true" >}}
Expand Down
2 changes: 1 addition & 1 deletion exampleSite/content/_index.pir.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
+++
archetype = "home"
description = "A theme fer Cap'n Hugo designed fer documentat'n."
title = "Cap'n Hugo Relearrrn Theme"
type = "home"
+++
{{< piratify true >}}
2 changes: 1 addition & 1 deletion exampleSite/content/basics/_index.en.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
+++
archetype = "chapter"
title = "Basics"
type = "chapter"
weight = 1
+++

Expand Down
2 changes: 1 addition & 1 deletion exampleSite/content/basics/_index.pir.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
+++
archetype = "chapter"
title = "Basics"
type = "chapter"
weight = 1
+++
{{< piratify >}}
2 changes: 1 addition & 1 deletion exampleSite/content/cont/_index.en.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
+++
archetype = "chapter"
title = "Content"
type = "chapter"
weight = 2
+++

Expand Down
2 changes: 1 addition & 1 deletion exampleSite/content/cont/_index.pir.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
+++
archetype = "chapter"
title = "Rambl'n"
type = "chapter"
weight = 2
+++
{{< piratify >}}
6 changes: 3 additions & 3 deletions exampleSite/content/cont/archetypes/_index.en.md
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,8 @@ This leads to a file with the following content

````toml {title="_index.md"}
+++
archetype = "home"
title = "{{ replace .Name "-" " " | title }}"
type = "home"
+++

Lorem Ipsum.
Expand All @@ -48,8 +48,8 @@ This leads to a file with the following content

````toml {title="_index.md"}
+++
archetype = "chapter"
title = "{{ replace .Name "-" " " | title }}"
type = "chapter"
weight = 1
+++

Expand Down Expand Up @@ -96,7 +96,7 @@ Define a template file in your project at `archetypes/<kind>.md` and make sure i

````toml {title="&lt;kind&gt;.md"}
+++
archetype = "<kind>"
type = "<kind>"
+++
````

Expand Down
2 changes: 1 addition & 1 deletion exampleSite/content/dev/_index.en.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
+++
archetype = "chapter"
hidden = true
title = "Development"
type = "chapter"
weight = 4
+++

Expand Down
2 changes: 1 addition & 1 deletion exampleSite/content/dev/_index.pir.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
+++
archetype = "chapter"
hidden = true
title = "Development"
type = "chapter"
weight = 4
+++
{{< piratify >}}
4 changes: 2 additions & 2 deletions exampleSite/content/shortcodes/_index.en.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
+++
archetype = "chapter"
title = "Shortcodes"
ordersectionsby = "title"
title = "Shortcodes"
type = "chapter"
weight = 3
+++

Expand Down
4 changes: 2 additions & 2 deletions exampleSite/content/shortcodes/_index.pir.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
+++
archetype = "chapter"
title = "Shorrrtcodes"
ordersectionsby = "title"
title = "Shorrrtcodes"
type = "chapter"
weight = 3
+++
{{< piratify >}}
Original file line number Diff line number Diff line change
Expand Up @@ -4,4 +4,4 @@ tags = ["children", "non-hidden"]
title = "page 1-1-2-1"
+++

This is a plain demo child page.
This is a plain demo child page 1-1-2-1.
Original file line number Diff line number Diff line change
Expand Up @@ -4,4 +4,4 @@ tags = ["children", "non-hidden"]
title = "page 1-1-2-2"
+++

This is a plain demo child page.
This is a plain demo child page 1-1-2-2.
Original file line number Diff line number Diff line change
Expand Up @@ -4,4 +4,4 @@ tags = ["children", "non-hidden"]
title = "page 1-1-3"
+++

This is a plain demo child page.
This is a plain demo child page 1-1-3.
Original file line number Diff line number Diff line change
Expand Up @@ -4,4 +4,4 @@ tags = ["children", "non-hidden"]
title = "page 3-1"
+++

This is a plain demo child page.
This is a plain demo child page 3-1.
2 changes: 1 addition & 1 deletion exampleSite/content/shortcodes/children/test.en.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,4 +7,4 @@ title: "page X"
weight: 1
---

This is a plain demo child page.
This is a plain demo child page X.
2 changes: 1 addition & 1 deletion exampleSite/layouts/partials/menu-pre.html
Original file line number Diff line number Diff line change
@@ -1 +1 @@
{{ if (eq .Params.archetype "chapter") }}<b style="display: inline-block; font-weight: 200; padding-left: .3rem; text-align: left; width: 1.1rem;">{{ .Params.weight }}.</b> {{ end }}
{{ if (eq .Type "chapter") }}<b style="display: inline-block; font-weight: 200; padding-left: .3rem; text-align: left; width: 1.1rem;">{{ .Params.weight }}.</b> {{ end }}
10 changes: 7 additions & 3 deletions layouts/404.html
Original file line number Diff line number Diff line change
@@ -1,18 +1,22 @@
<!DOCTYPE html>
{{- partialCached "page-meta.hugo" . .RelPermalink }}
{{- .Store.Set "relearnOutputFormat" "notfound" -}}
<!DOCTYPE html>
<html lang="{{ .Page.Language.LanguageCode }}" dir="{{ .Page.Language.LanguageDirection | default (T "Reading-direction") | default "ltr" }}" itemscope itemtype="http://schema.org/Article">
<head>
{{- partial "meta.html" . }}
{{- $title := partial "pageHelper/title.hugo" (dict "page" . "fullyQualified" true "reverse" true) }}
<title>{{ $title }}</title>

{{- /* because this file can be called from literally any URL inside your project, we need to base all relative URLs to make them work */}}
<base href="{{ .Site.BaseURL }}">

{{- partialCached "favicon.html" . }}
{{- partial "stylesheet.html" . }}
{{- partial "custom-header.html" . }}
</head>
<body class="mobile-support html notfound" data-url="{{ partial "relLangPrettyUglyURL.hugo" (dict "to" .) }}">
<body class="mobile-support {{ with .Store.Get "relearnOutputFormat" }}{{ . }}{{ else }}html{{ end }}" data-url="{{ partial "relLangPrettyUglyURL.hugo" (dict "to" .) }}">
<div id="R-body" class="default-animation">
<main id="R-body-inner" class="chapter" tabindex="-1">
<main id="R-body-inner" class="highlightable chapter" tabindex="-1">
<div class="flex-block-wrapper">
<article>
<h1 id="404"><span>4</span>{{ partial "shortcodes/icon.html" (dict "page" . "icon" "far fa-frown" )}}<span>4</span></h1>
Expand Down
33 changes: 24 additions & 9 deletions layouts/partials/header.html → layouts/_default/baseof.html
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
{{- partialCached "page-meta.hugo" . .RelPermalink -}}
<!DOCTYPE html>
{{- $outputFormat := partial "output-format.hugo" . }}
{{- block "storeOutputFormat" . }}{{ end }}
{{- if eq . .Site.Sites.First.Home }}
{{- $hugoVersion := "0.126.0" }}
{{- if lt hugo.Version $hugoVersion }}
Expand All @@ -12,11 +13,10 @@
<html lang="{{ .Page.Language.LanguageCode }}" dir="{{ .Page.Language.LanguageDirection | default (T "Reading-direction") | default "ltr" }}" itemscope itemtype="http://schema.org/Article">
<head>
{{- partial "meta.html" . }}
{{- $page := . }}
{{- $link := "<link href=\"%s\" rel=\"%s\" type=\"%s\" title=\"%s\">" }}
{{- $title := partial "pageHelper/title.hugo" (dict "page" . "fullyQualified" true "reverse" true) }}
<title>{{ $title }}</title>

{{- /* multilingual stuff */}}
{{- if .IsTranslated -}}
{{- range $index, $trans := .AllTranslations }}
{{- if eq $index 0 }}
Expand All @@ -26,8 +26,11 @@
{{- end }}
{{- end }}

{{- /* output formats */}}
{{- if not (and .Title .RelPermalink (or (ne (.Scratch.Get "relearnIsHiddenStem") true) (ne .Site.Params.disableSeoHiddenPages true) ) ) }}
{{- else }}
{{- $page := . }}
{{- $link := "<link href=\"%s\" rel=\"%s\" type=\"%s\" title=\"%s\">" }}
{{- range .AlternativeOutputFormats }}
{{- if eq .Rel "canonical" }}
{{ (printf $link (partial "relLangPrettyUglyURL.hugo" (dict "to" . "abs" true)) .Rel .MediaType.Type ($title | htmlEscape)) | safeHTML }}
Expand All @@ -36,13 +39,12 @@
{{- end }}
{{- end }}
{{- end }}

{{- partialCached "favicon.html" . }}
{{- partial "stylesheet.html" . }}
{{- partial "dependencies.html" (dict "page" . "location" "header") }}
{{- partial "custom-header.html" . }}
</head>
<body class="mobile-support {{ $outputFormat }}{{- if .Site.Params.disableInlineCopyToClipBoard }} disableInlineCopyToClipboard{{ end }}{{- if .Site.Params.disableHoverBlockCopyToClipBoard }} disableHoverBlockCopyToClipBoard{{ end }}" data-url="{{ partial "relLangPrettyUglyURL.hugo" (dict "to" .) }}">
<body class="mobile-support {{ with .Store.Get "relearnOutputFormat" }}{{ . }}{{ else }}html{{ end }}{{- if .Site.Params.disableInlineCopyToClipBoard }} disableInlineCopyToClipboard{{ end }}{{- if .Site.Params.disableHoverBlockCopyToClipBoard }} disableHoverBlockCopyToClipBoard{{ end }}" data-url="{{ partial "relLangPrettyUglyURL.hugo" (dict "to" .) }}">
<div id="R-body" class="default-animation">
<div id="R-body-overlay"></div>
<nav id="R-topbar">
Expand All @@ -58,15 +60,28 @@
</ol>
{{- else }}
<span class="topbar-breadcrumbs highlightable">
{{ .Title }}
{{ partial "pageHelper/title.hugo" (dict "page" . "linkTitle" true) }}
</span>
{{- end }}
<div class="topbar-area topbar-area-end" data-area="end">
{{- partial "topbar/area/end.html" . }}
</div>
</div>
</nav>
{{- $hook := "styleclass" }}
<div id="R-main-overlay"></div>
<main id="R-body-inner" class="highlightable {{ partialCached "archetype.hugo" (dict "hook" $hook "page" . "parameter" .) .RelPermalink $hook }}" tabindex="-1">
<div class="flex-block-wrapper">
<main id="R-body-inner" class="highlightable{{ with or .Type "default" }} {{ . }}{{ end }}" tabindex="-1">
<div class="flex-block-wrapper">
{{- block "body" . }}{{ end }}
</div>
</main>
{{- partial "custom-comments.html" . }}
</div>
{{- block "menu" . }}{{ end }}
{{- $assetBusting := partialCached "assetbusting.hugo" . }}
<script src="{{"js/clipboard.min.js" | relURL}}{{ $assetBusting }}" defer></script>
<script src="{{"js/perfect-scrollbar.min.js" | relURL}}{{ $assetBusting }}" defer></script>
{{- partial "dependencies.html" (dict "page" . "location" "footer") }}
<script src="{{"js/theme.js" | relURL}}{{ $assetBusting }}" defer></script>
{{- partial "custom-footer.html" . }}
</body>
</html>
1 change: 0 additions & 1 deletion layouts/_default/index.html

This file was deleted.

10 changes: 9 additions & 1 deletion layouts/_default/list.html
Original file line number Diff line number Diff line change
@@ -1 +1,9 @@
{{- partial "_main.hugo" . }}
{{- define "storeOutputFormat" }}
{{- .Render "views/storeOutputFormat" }}
{{- end }}
{{- define "body" }}
{{- .Render "views/page" }}
{{- end }}
{{- define "menu" }}
{{- .Render "views/menu" }}
{{- end }}
10 changes: 9 additions & 1 deletion layouts/_default/single.html
Original file line number Diff line number Diff line change
@@ -1 +1,9 @@
{{- partial "_main.hugo" . }}
{{- define "storeOutputFormat" }}
{{- .Render "views/storeOutputFormat" }}
{{- end }}
{{- define "body" }}
{{- .Render "views/page" }}
{{- end }}
{{- define "menu" }}
{{- .Render "views/menu" }}
{{- end }}
38 changes: 7 additions & 31 deletions layouts/_default/taxonomy.html
Original file line number Diff line number Diff line change
@@ -1,33 +1,9 @@
{{- partialCached "page-meta.hugo" . .RelPermalink }}
{{- partial "header.html" . }}
<article>
<header class="headline">
</header>
{{- $page := . }}

{{- $title := partial "pageHelper/title.hugo" (dict "page" .) }}
<h1 id="{{ $title | plainify | anchorize }}">{{ $title }}</h1>
{{- .Content }}
{{- $lastCapital := "" }}
{{- $pages := partialCached "partials/pageHelper/taxonomyPages.html" . . }}
{{- range $pages }}
{{- $capital := substr .Title 0 1 | upper }}
{{- if ne $lastCapital $capital }}
{{- if ne $lastCapital "" }}
</ul>
{{- end }}
<h2 id="{{ $capital | plainify | anchorize }}">{{ $capital }}</h2>
<ul class="columnize">
{{- end }}
{{- /* display terms of a taxonomy */}}
<li><a href="{{ partial "relLangPrettyUglyURL.hugo" (dict "to" .Page) }}">{{ .Title }}</a> ({{ .Count }})</li>
{{- $lastCapital = $capital }}
{{- define "storeOutputFormat" }}
{{- .Render "views/storeOutputFormat" }}
{{- end }}
{{- if ne $lastCapital "" }}
</ul>
{{- define "body" }}
{{- partial "bodys/taxonomy.html" . }}
{{- end }}

<footer class="footline">
</footer>
</article>
{{- partial "footer.html" . }}
{{- define "menu" }}
{{- .Render "views/menu" }}
{{- end }}
Loading

0 comments on commit c1820d6

Please sign in to comment.