From b4721c0ce79c96a4dfddd59776ccfeefba825b77 Mon Sep 17 00:00:00 2001 From: Robert Kaussow Date: Thu, 30 Dec 2021 15:55:55 +0100 Subject: [PATCH] chore: enable auto-formatting for template files (#133) --- .prettierignore | 9 +- .../content/posts/advanced/includes.md | 12 +- layouts/404.html | 46 ++++---- layouts/_default/_markup/render-heading.html | 3 + layouts/_default/_markup/render-image.html | 6 +- layouts/_default/_markup/render-link.html | 7 +- layouts/_default/baseof.html | 36 +++--- layouts/_default/list.html | 49 ++++---- layouts/_default/single.html | 54 ++++----- layouts/partials/head/custom.html | 2 +- layouts/partials/head/favicons.html | 23 +++- layouts/partials/head/meta.html | 26 ++--- layouts/partials/head/others.html | 76 +++++++++--- layouts/partials/head/schema.html | 3 +- layouts/partials/menu-extra.html | 59 ++++++---- layouts/partials/metadata.html | 73 ++++++------ layouts/partials/microformats/opengraph.html | 80 +++++++++---- .../partials/microformats/twitter_cards.html | 50 ++++---- layouts/partials/pagination.html | 19 +-- layouts/partials/site-footer.html | 110 +++++++++--------- layouts/partials/site-header.html | 108 +++++++++-------- layouts/partials/svg-sprites.html | 4 +- layouts/partials/title.html | 8 +- layouts/shortcodes/button.html | 11 +- layouts/shortcodes/columns.html | 6 +- layouts/shortcodes/icon.html | 2 +- layouts/shortcodes/img.html | 56 ++++----- layouts/shortcodes/include.html | 11 +- layouts/shortcodes/mermaid.html | 8 +- layouts/shortcodes/tab.html | 2 +- layouts/shortcodes/tabs.html | 10 +- layouts/shortcodes/toc.html | 5 +- 32 files changed, 586 insertions(+), 388 deletions(-) diff --git a/.prettierignore b/.prettierignore index 7c439ecf..d0e19f2e 100644 --- a/.prettierignore +++ b/.prettierignore @@ -1,10 +1,9 @@ -*.html .drone.yml search*.js _normalize.css list.json.json -.lighthouseci/ -themes/ -static/js/ -src/favicon/ +/.lighthouseci/ +/themes/ +/static/js/ +/src/favicon/ LICENSE diff --git a/exampleSite/content/posts/advanced/includes.md b/exampleSite/content/posts/advanced/includes.md index f5642f0f..2fab9ea0 100644 --- a/exampleSite/content/posts/advanced/includes.md +++ b/exampleSite/content/posts/advanced/includes.md @@ -14,11 +14,15 @@ Include shortcode can include files of different types. By specifying a language {{< toc >}} +## Usage + + ```tpl {{}} ``` + -Attributes: +### Attributes | Name | Usage | default | | -------- | ----------------------------------------------------------------------------------------------------------------------------------- | --------------- | @@ -38,9 +42,11 @@ If no other options are specified, files will be rendered as Markdown using the If you include markdown files that should not get a menu entry, place them outside the content folder or exclude them otherwise. {{< /hint >}} + ```tpl {{}} ``` + @@ -52,9 +58,11 @@ If you include markdown files that should not get a menu entry, place them outsi This method can be used to include source code files and keep them automatically up to date. + ```tpl {{}} ``` + **Code Include:** @@ -70,9 +78,11 @@ This method can be used to include source code files and keep them automatically HTML content will be filtered by the `safeHTML` filter and added to the rendered page output. + ```tpl {{}} ``` + {{< include file="/static/_includes/example.html.part" type="html" >}} diff --git a/layouts/404.html b/layouts/404.html index 2f260c9a..10359779 100644 --- a/layouts/404.html +++ b/layouts/404.html @@ -1,39 +1,39 @@ - - + {{ partial "head/meta" . }} Lost? Don't worry {{ partial "head/favicons" . }} {{ partial "head/others" . }} - + - + {{ partial "svg-sprites" . }} +
- {{ partial "site-header" . }} - -
-
-
- -
-
-
Lost?
-
Error 404
-
- Seems like what you are looking for can't be found. Don't worry we can - bring you back to the homepage. -
-
+ {{ partial "site-header" . }} + + +
+
+
+ +
+
+
Lost?
+
Error 404
+
+ Seems like what you are looking for can't be found. Don't worry we can bring you back + to the homepage.
-
+
+
+ - {{ partial "site-footer" . }} + {{ partial "site-footer" . }} - - + diff --git a/layouts/_default/_markup/render-heading.html b/layouts/_default/_markup/render-heading.html index 66beaf3e..945c52b0 100644 --- a/layouts/_default/_markup/render-heading.html +++ b/layouts/_default/_markup/render-heading.html @@ -1,5 +1,7 @@ {{- $showAnchor := (and (default true .Page.Params.GeekblogAnchor) (default true .Page.Site.Params.GeekblogAnchor)) -}} + + {{- if $showAnchor -}}
@@ -16,3 +18,4 @@
{{- end -}} + diff --git a/layouts/_default/_markup/render-image.html b/layouts/_default/_markup/render-image.html index 51501777..99a31136 100644 --- a/layouts/_default/_markup/render-image.html +++ b/layouts/_default/_markup/render-image.html @@ -1,2 +1,6 @@ -{{ .Text }} +{{ .Text }} {{- /* Drop trailing newlines */ -}} diff --git a/layouts/_default/_markup/render-link.html b/layouts/_default/_markup/render-link.html index 0b1de0c5..2a13b7b9 100644 --- a/layouts/_default/_markup/render-link.html +++ b/layouts/_default/_markup/render-link.html @@ -1,3 +1,8 @@ {{- $raw := or (hasPrefix .Text "{{ .Text | safeHTML }} +{{ .Text | safeHTML }} {{- /* Drop trailing newlines */ -}} diff --git a/layouts/_default/baseof.html b/layouts/_default/baseof.html index d00aa982..869315c9 100644 --- a/layouts/_default/baseof.html +++ b/layouts/_default/baseof.html @@ -1,9 +1,15 @@ - - - + + {{ partial "head/meta" . }} - {{ if not (eq .Kind "home") }}{{ partial "title" . }} | {{ end }}{{ .Site.Title }} + + {{ if not (eq .Kind "home") }}{{ partial "title" . }} |{{ end }}{{ .Site.Title }} + {{ partial "head/favicons" . }} {{ partial "head/rel-me" . }} @@ -11,19 +17,23 @@ {{ partial "head/others" . }} {{ partial "head/schema.html" . }} {{ partial "head/custom" . }} - + - + {{ partial "svg-sprites" . }} -
- {{ partial "site-header" . }} -
- {{ template "main" . }} -
+
+ {{ partial "site-header" . }} + + +
+ {{ template "main" . }} +
- {{ partial "site-footer" . }} + {{ partial "site-footer" . }}
- + diff --git a/layouts/_default/list.html b/layouts/_default/list.html index c31de0b2..77915c7a 100644 --- a/layouts/_default/list.html +++ b/layouts/_default/list.html @@ -1,29 +1,34 @@ {{ define "main" }} - {{ $pages := where .RegularPages "Type" "in" .Site.Params.mainSections }} - {{ if (eq .Kind "home") }} - {{ $pages = where .Site.RegularPages "Type" "in" .Site.Params.mainSections }} - {{ end }} + {{ $pages := where .RegularPages "Type" "in" .Site.Params.mainSections }} + {{ if (eq .Kind "home") }} + {{ $pages = where .Site.RegularPages "Type" "in" .Site.Params.mainSections }} + {{ end }} - {{ $paginator := .Paginate $pages }} - {{ range $paginator.Pages }} + {{ $paginator := .Paginate $pages }} + {{ range $paginator.Pages }} - {{ end }} - {{ partial "pagination.html" . }} + {{ end }} + {{ partial "pagination.html" . }} {{ end }} diff --git a/layouts/_default/single.html b/layouts/_default/single.html index 1f6d56c2..4bf06541 100644 --- a/layouts/_default/single.html +++ b/layouts/_default/single.html @@ -1,31 +1,33 @@ {{ define "main" }} -
-
- {{ $source := ($.Resources.ByType "image").GetMatch "{*feature*,*cover*,*thumbnail*}" }} - {{ with $source }} -
- - {{ $featured := .Fill (printf "910x280 %s" (default "Smart" .Params.anchor)) }} - - {{ default $.Title .Params.description }} - - {{ with $source.Params.credits }} - Credits: {{ . | $.Page.RenderString | safeHTML }} - {{ end }} -
- {{ end }} +
+
+ {{ $source := ($.Resources.ByType "image").GetMatch "{*feature*,*cover*,*thumbnail*}" }} + {{ with $source }} +
+ + {{ $featured := .Fill (printf "910x280 %s" (default "Smart" .Params.anchor)) }} + + {{ default $.Title .Params.description }} + + {{ with $source.Params.credits }} + Credits: {{ . | $.Page.RenderString | safeHTML }} + {{ end }} +
+ {{ end }} -

{{ partial "title" . }}

-
- {{ if or (eq .Type (default "posts" .Site.Params.GeekblogContentSection)) (eq .Type "post") }} - - {{ end }} +

{{ partial "title" . }}

+
+ + {{ if or (eq .Type (default "posts" .Site.Params.GeekblogContentSection)) (eq .Type "post") }} + + {{ end }} + -
- {{ partial "content" . }} -
-
+
+ {{ partial "content" . }} +
+ {{ end }} diff --git a/layouts/partials/head/custom.html b/layouts/partials/head/custom.html index c4397a8e..44862c7b 100644 --- a/layouts/partials/head/custom.html +++ b/layouts/partials/head/custom.html @@ -1 +1 @@ - + diff --git a/layouts/partials/head/favicons.html b/layouts/partials/head/favicons.html index 79cba229..41bac470 100644 --- a/layouts/partials/head/favicons.html +++ b/layouts/partials/head/favicons.html @@ -1,4 +1,19 @@ - - - - + + + + diff --git a/layouts/partials/head/meta.html b/layouts/partials/head/meta.html index 6cde04c0..bdca2fd9 100644 --- a/layouts/partials/head/meta.html +++ b/layouts/partials/head/meta.html @@ -1,26 +1,26 @@ - - + + {{ $description := default (default .Site.Title .Site.Params.description) (default .Summary .Description) }} {{ $keywords := default .Site.Params.Keywords .Keywords }} {{ $authors := default (slice .Site.Params.GeekblogAuthor) .Params.authors }} {{ with $description }} - + {{ end }} {{ with $keywords }} - + {{ end }} {{ with $authors }} - {{ $list := slice }} - {{ range sort . }} - {{ with . }} - {{ $author := index $.Site.Data.authors . }} - {{ $list = $list | append $author.name }} - {{ end }} + {{ $list := slice }} + {{ range sort . }} + {{ with . }} + {{ $author := index $.Site.Data.authors . }} + {{ $list = $list | append $author.name }} {{ end }} + {{ end }} - {{ with $list }} - - {{ end }} + {{ with $list }} + + {{ end }} {{ end }} diff --git a/layouts/partials/head/others.html b/layouts/partials/head/others.html index c9ef838a..637a4a96 100644 --- a/layouts/partials/head/others.html +++ b/layouts/partials/head/others.html @@ -1,27 +1,77 @@ - - - + + + - - + + - - + + - - + + - - + + {{ with .OutputFormats.Get "atom" }} - {{ printf `` .Rel .MediaType.Type .Permalink $.Site.Title | safeHTML }} + {{ printf `` .Rel .MediaType.Type .Permalink $.Site.Title | safeHTML }} {{ end }} {{ if (default false $.Site.Params.GeekblogOverwriteHTMLBase) }} - + {{ end }} {{ printf "" "Made with Geekblog theme https://github.com/thegeeklab/hugo-geekblog" | safeHTML }} diff --git a/layouts/partials/head/schema.html b/layouts/partials/head/schema.html index a914c8aa..22f3b002 100644 --- a/layouts/partials/head/schema.html +++ b/layouts/partials/head/schema.html @@ -1,6 +1,5 @@ {{ if .IsHome -}} -{{ $thumbnail := default (default "brand.svg" .Site.Params.logo) (index (default slice .Site.Params.images) 0) | absURL }} - -{{ .Page.Scratch.Set "mermaid" true }} + + {{ .Page.Scratch.Set "mermaid" true }} {{ end }} -
+
+
   {{- .Inner -}}
 
diff --git a/layouts/shortcodes/tab.html b/layouts/shortcodes/tab.html index e2a207ca..4eb1b445 100644 --- a/layouts/shortcodes/tab.html +++ b/layouts/shortcodes/tab.html @@ -9,4 +9,4 @@ {{ .Parent.Scratch.Add $group (dict "Name" $name "Content" .Inner) }} {{ else }} {{ errorf "%q: 'tab' shortcode must be inside 'tabs' shortcode" .Page.Path }} -{{ end}} +{{ end }} diff --git a/layouts/shortcodes/tabs.html b/layouts/shortcodes/tabs.html index 246238a9..21f2d4af 100644 --- a/layouts/shortcodes/tabs.html +++ b/layouts/shortcodes/tabs.html @@ -2,10 +2,16 @@ {{ $id := .Get 0 }} {{ $group := printf "tabs-%s" $id }} +
{{ range $index, $tab := .Scratch.Get $group }} - + diff --git a/layouts/shortcodes/toc.html b/layouts/shortcodes/toc.html index 6cd3a18b..ef1739d5 100644 --- a/layouts/shortcodes/toc.html +++ b/layouts/shortcodes/toc.html @@ -1,5 +1,8 @@ {{ $tocLevels := default (default 6 .Site.Params.GeekblogToC) .Page.Params.GeekblogToC }} {{ if and $tocLevels .Page.TableOfContents }} -
{{ .Page.TableOfContents }}
+
+ {{ .Page.TableOfContents }} +
+
{{ end }}