Skip to content

Commit

Permalink
chore: enable auto-formatting for template files (#133)
Browse files Browse the repository at this point in the history
  • Loading branch information
xoxys authored Dec 30, 2021
1 parent 392708d commit b4721c0
Show file tree
Hide file tree
Showing 32 changed files with 586 additions and 388 deletions.
9 changes: 4 additions & 5 deletions .prettierignore
Original file line number Diff line number Diff line change
@@ -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
12 changes: 11 additions & 1 deletion exampleSite/content/posts/advanced/includes.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,11 +14,15 @@ Include shortcode can include files of different types. By specifying a language

{{< toc >}}

## Usage

<!-- prettier-ignore-start -->
```tpl
{{</* include file="relative/path/from/hugo/root" language="go" markdown=[false|true] */>}}
```
<!-- prettier-ignore-end -->

Attributes:
### Attributes

| Name | Usage | default |
| -------- | ----------------------------------------------------------------------------------------------------------------------------------- | --------------- |
Expand All @@ -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 >}}

<!-- prettier-ignore-start -->
```tpl
{{</* include file="/static/_includes/example.md.part" */>}}
```
<!-- prettier-ignore-end -->

<!-- prettier-ignore-start -->
<!-- spellchecker-disable -->
Expand All @@ -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.

<!-- prettier-ignore-start -->
```tpl
{{</* include file="config.yaml" language="yaml" options="linenos=table,hl_lines=5-6,linenostart=100" */>}}
```
<!-- prettier-ignore-end -->

**Code Include:**

Expand All @@ -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.

<!-- prettier-ignore-start -->
```tpl
{{</* include file="/static/_includes/example.html.part" */>}}
```
<!-- prettier-ignore-end -->

{{< include file="/static/_includes/example.html.part" type="html" >}}

Expand Down
46 changes: 23 additions & 23 deletions layouts/404.html
Original file line number Diff line number Diff line change
@@ -1,39 +1,39 @@
<!DOCTYPE html>
<html lang="{{ .Site.Language.Lang }}" class="color-toggle-hidden">

<head>
<head>
{{ partial "head/meta" . }}
<title>Lost? Don't worry</title>

{{ partial "head/favicons" . }}
{{ partial "head/others" . }}
</head>
</head>

<body>
<body>
{{ partial "svg-sprites" . }}


<div class="wrapper">
{{ partial "site-header" . }}

<main class="gblog-error flex-even">
<div class="flex align-center justify-center">
<div class="gblog-error__icon">
<svg class="icon gblog_cloud_off"><use xlink:href="#gblog_cloud_off"></use></svg>
</div>
<div class="gblog-error__message">
<div class="gblog-error__line gblog-error__title">Lost?</div>
<div class="gblog-error__line gblog-error__code">Error 404</div>
<div class="gblog-error__line gblog-error__help">
Seems like what you are looking for can't be found. Don't worry we can
bring you back to the <a class="gblog-error__link" href="{{ .Site.BaseURL }}">homepage</a>.
</div>
</div>
{{ partial "site-header" . }}


<main class="gblog-error flex-even">
<div class="flex align-center justify-center">
<div class="gblog-error__icon">
<svg class="icon gblog_cloud_off"><use xlink:href="#gblog_cloud_off"></use></svg>
</div>
<div class="gblog-error__message">
<div class="gblog-error__line gblog-error__title">Lost?</div>
<div class="gblog-error__line gblog-error__code">Error 404</div>
<div class="gblog-error__line gblog-error__help">
Seems like what you are looking for can't be found. Don't worry we can bring you back
to the <a class="gblog-error__link" href="{{ .Site.BaseURL }}">homepage</a>.
</div>
</main>
</div>
</div>
</main>

{{ partial "site-footer" . }}
{{ partial "site-footer" . }}

</div>
</body>

</body>
</html>
3 changes: 3 additions & 0 deletions layouts/_default/_markup/render-heading.html
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
{{- $showAnchor := (and (default true .Page.Params.GeekblogAnchor) (default true .Page.Site.Params.GeekblogAnchor)) -}}


<!-- prettier-ignore-start -->
{{- if $showAnchor -}}
<div class="gblog-post__anchorwrap">
<h{{ .Level }} id="{{ .Anchor | safeURL }}">
Expand All @@ -16,3 +18,4 @@
</h{{ .Level }}>
</div>
{{- end -}}
<!-- prettier-ignore-end -->
6 changes: 5 additions & 1 deletion layouts/_default/_markup/render-image.html
Original file line number Diff line number Diff line change
@@ -1,2 +1,6 @@
<img src="{{ .Destination | safeURL }}" alt="{{ .Text }}" {{ with .Title}} title="{{ . }}"{{ end }} />
<img
src="{{ .Destination | safeURL }}"
alt="{{ .Text }}"
{{ with .Title }}title="{{ . }}"{{ end }}
/>
{{- /* Drop trailing newlines */ -}}
7 changes: 6 additions & 1 deletion layouts/_default/_markup/render-link.html
Original file line number Diff line number Diff line change
@@ -1,3 +1,8 @@
{{- $raw := or (hasPrefix .Text "<img") (hasPrefix .Text "<figure") -}}
<a class="gblog-markdown__link{{ if $raw }}--raw{{ end }}" href="{{ .Destination | safeURL }}"{{ with .Title }} title="{{ . }}"{{ end }}>{{ .Text | safeHTML }}</a>
<a
class="gblog-markdown__link{{ if $raw }}--raw{{ end }}"
href="{{ .Destination | safeURL }}"
{{ with .Title }}title="{{ . }}"{{ end }}
>{{ .Text | safeHTML }}</a
>
{{- /* Drop trailing newlines */ -}}
36 changes: 23 additions & 13 deletions layouts/_default/baseof.html
Original file line number Diff line number Diff line change
@@ -1,29 +1,39 @@
<!DOCTYPE html>
<html itemscope itemtype="http://schema.org/WebPage" lang="{{ .Site.Language.Lang }}" class="color-toggle-hidden">

<head>
<html
itemscope
itemtype="http://schema.org/WebPage"
lang="{{ .Site.Language.Lang }}"
class="color-toggle-hidden"
>
<head>
{{ partial "head/meta" . }}
<title>{{ if not (eq .Kind "home") }}{{ partial "title" . }} | {{ end }}{{ .Site.Title }}</title>
<title>
{{ if not (eq .Kind "home") }}{{ partial "title" . }} |{{ end }}{{ .Site.Title }}
</title>

{{ partial "head/favicons" . }}
{{ partial "head/rel-me" . }}
{{ partial "head/microformats" . }}
{{ partial "head/others" . }}
{{ partial "head/schema.html" . }}
{{ partial "head/custom" . }}
</head>
</head>

<body>
<body>
{{ partial "svg-sprites" . }}

<div class="wrapper {{ if default false .Site.Params.GeekblogDarkModeDim }}dark-mode-dim{{ end }}">
{{ partial "site-header" . }}

<main class="gblog-page container">
{{ template "main" . }}
</main>
<div
class="wrapper {{ if default false .Site.Params.GeekblogDarkModeDim }}dark-mode-dim{{ end }}"
>
{{ partial "site-header" . }}


<main class="gblog-page container">
{{ template "main" . }}
</main>

{{ partial "site-footer" . }}
{{ partial "site-footer" . }}
</div>
</body>
</body>
</html>
49 changes: 27 additions & 22 deletions layouts/_default/list.html
Original file line number Diff line number Diff line change
@@ -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 }}
<article class="gblog-post">
<header class="gblog-post__header">
<h1><a href="{{ .RelPermalink }}">{{ partial "title" . }}</a></h1>
</header>
<header class="gblog-post__header">
<h1><a href="{{ .RelPermalink }}">{{ partial "title" . }}</a></h1>
</header>

<section class="gblog-markdown">
{{ .Summary }}
</section>
<div class="gblog-post__readmore">
{{ if .Truncated }}
<a class="flex-inline align-center fake-link" title="Read full post" href="{{ .RelPermalink }}">Read full post<i class="gblog-icon">gblog_arrow_right</i></a>
{{ end }}
</div>
<section class="gblog-markdown">
{{ .Summary }}
</section>
<div class="gblog-post__readmore">
{{ if .Truncated }}
<a
class="flex-inline align-center fake-link"
title="Read full post"
href="{{ .RelPermalink }}"
>Read full post<i class="gblog-icon">gblog_arrow_right</i></a
>
{{ end }}
</div>

<footer class="gblog-post__footer">
{{ partial "metadata.html" . }}
</footer>
<footer class="gblog-post__footer">
{{ partial "metadata.html" . }}
</footer>
</article>
{{ end }}
{{ partial "pagination.html" . }}
{{ end }}
{{ partial "pagination.html" . }}
{{ end }}
54 changes: 28 additions & 26 deletions layouts/_default/single.html
Original file line number Diff line number Diff line change
@@ -1,31 +1,33 @@
{{ define "main" }}
<article class="gblog-post">
<header class="gblog-post__header">
{{ $source := ($.Resources.ByType "image").GetMatch "{*feature*,*cover*,*thumbnail*}" }}
{{ with $source }}
<div class="gblog-post__feature">
<picture>
{{ $featured := .Fill (printf "910x280 %s" (default "Smart" .Params.anchor)) }}
<source srcset="{{ $featured.Permalink }}">
<img src="{{ $featured.Permalink }}" alt="{{ default $.Title .Params.description }}" >
</picture>
{{ with $source.Params.credits }}
<span>Credits: {{ . | $.Page.RenderString | safeHTML }}</span>
{{ end }}
</div>
{{ end }}
<article class="gblog-post">
<header class="gblog-post__header">
{{ $source := ($.Resources.ByType "image").GetMatch "{*feature*,*cover*,*thumbnail*}" }}
{{ with $source }}
<div class="gblog-post__feature">
<picture>
{{ $featured := .Fill (printf "910x280 %s" (default "Smart" .Params.anchor)) }}
<source srcset="{{ $featured.Permalink }}" />
<img src="{{ $featured.Permalink }}" alt="{{ default $.Title .Params.description }}" />
</picture>
{{ with $source.Params.credits }}
<span>Credits: {{ . | $.Page.RenderString | safeHTML }}</span>
{{ end }}
</div>
{{ end }}

<h1>{{ partial "title" . }}</h1>
</header>

{{ if or (eq .Type (default "posts" .Site.Params.GeekblogContentSection)) (eq .Type "post") }}
<div class="gblog-post__meta">
{{ partial "metadata.html" . }}
</div>
{{ end }}
<h1>{{ partial "title" . }}</h1>
</header>

{{ if or (eq .Type (default "posts" .Site.Params.GeekblogContentSection)) (eq .Type "post") }}
<div class="gblog-post__meta">
{{ partial "metadata.html" . }}
</div>
{{ end }}


<section class="gblog-markdown">
{{ partial "content" . }}
</section>
</article>
<section class="gblog-markdown">
{{ partial "content" . }}
</section>
</article>
{{ end }}
2 changes: 1 addition & 1 deletion layouts/partials/head/custom.html
Original file line number Diff line number Diff line change
@@ -1 +1 @@
<!-- You can add custom elements to the page header here. -->
<!-- You can add custom elements to the page header here. -->
23 changes: 19 additions & 4 deletions layouts/partials/head/favicons.html
Original file line number Diff line number Diff line change
@@ -1,4 +1,19 @@
<link rel="icon" type="image/svg+xml" href="{{ "favicon/favicon.svg" | relURL }}">
<link rel="icon" type="image/png" sizes="48x48" href="{{ "favicon/favicon-32x32.png" | relURL }}">
<link rel="icon" type="image/png" sizes="32x32" href="{{ "favicon/favicon-32x32.png" | relURL }}">
<link rel="icon" type="image/png" sizes="16x16" href="{{ "favicon/favicon-16x16.png" | relURL }}">
<link rel="icon" type="image/svg+xml" href="{{ "favicon/favicon.svg" | relURL }}" />
<link
rel="icon"
type="image/png"
sizes="48x48"
href="{{ "favicon/favicon-32x32.png" | relURL }}"
/>
<link
rel="icon"
type="image/png"
sizes="32x32"
href="{{ "favicon/favicon-32x32.png" | relURL }}"
/>
<link
rel="icon"
type="image/png"
sizes="16x16"
href="{{ "favicon/favicon-16x16.png" | relURL }}"
/>
26 changes: 13 additions & 13 deletions layouts/partials/head/meta.html
Original file line number Diff line number Diff line change
@@ -1,26 +1,26 @@
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<meta charset="UTF-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />

{{ $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 }}
<meta name="description" content="{{ . }}">
<meta name="description" content="{{ . }}" />
{{ end }}
{{ with $keywords }}
<meta name="keywords" content="{{ delimit . "," }}">
<meta name="keywords" content="{{ delimit . "," }}" />
{{ 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 }}
<meta name="author" content="{{ delimit . "," }}">
{{ end }}
{{ with $list }}
<meta name="author" content="{{ delimit . "," }}" />
{{ end }}
{{ end }}
Loading

0 comments on commit b4721c0

Please sign in to comment.