Skip to content

Commit

Permalink
style: format with prettier
Browse files Browse the repository at this point in the history
  • Loading branch information
maolonglong committed Dec 7, 2023
1 parent 0dd2cb8 commit fff14a2
Show file tree
Hide file tree
Showing 17 changed files with 211 additions and 133 deletions.
7 changes: 5 additions & 2 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,8 +1,11 @@
.direnv/
node_modules/
public/
resources/

.DS_Store
.hugo_build.lock
package-lock.json
result
result-*

.hugo_build.lock
yarn.lock
12 changes: 12 additions & 0 deletions .prettierrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
{
"plugins": ["prettier-plugin-go-template"],
"overrides": [
{
"files": ["*.html"],
"options": {
"parser": "go-template"
}
}
],
"goTemplateBracketSpacing": true
}
4 changes: 2 additions & 2 deletions layouts/404.html
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{{ define "title" }}404{{ end }}

{{ define "main" }}
<h1>404</h1>
<h2>ʕノ•ᴥ•ʔノ ︵ ┻━┻</h2>
<h1>404</h1>
<h2>ʕノ•ᴥ•ʔノ ︵ ┻━┻</h2>
{{ end }}
1 change: 1 addition & 0 deletions layouts/_default/_markup/render-codeblock.html
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
<!-- https://github.com/jmooring/hugo-testing/blob/hugo-forum-topic-40998/layouts/_default/_markup/render-codeblock-katex.html -->
{{ .Page.Store.Set "hasCodeBlock" true }}


<!-- https://www.veriphor.com/articles/code-block-render-hooks/ -->
{{ $result := transform.HighlightCodeBlock . }}
{{ $result.Wrapped }}
104 changes: 54 additions & 50 deletions layouts/_default/baseof.html
Original file line number Diff line number Diff line change
@@ -1,56 +1,60 @@
<!DOCTYPE html>
<!doctype html>
<html lang="{{ with .Site.LanguageCode }}{{ . }}{{ else }}en{{ end }}">
<head>
<meta http-equiv="X-Clacks-Overhead" content="GNU Terry Pratchett" />
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
{{- partial "favicon.html" . -}}
<title>{{- block "title" . }}{{ with .Title }}{{ . }} | {{ end }}{{ .Site.Title }}{{- end }}</title>

{{- partial "seo_tags.html" . -}}
<meta name="referrer" content="no-referrer-when-downgrade" />

{{ $simple := resources.Get "simple.css" | minify }}
<link href="{{ $simple.RelPermalink }}" rel="stylesheet">

{{ $style := resources.Get "style.css" | minify }}
<link href="{{ $style.RelPermalink }}" rel="stylesheet">

{{ if (.Page.Store.Get "hasCodeBlock") }}
{{ $syntax := resources.Get "syntax.css" | minify }}
<link href="{{ $syntax.RelPermalink }}" rel="stylesheet">
{{ end }}

{{ with .Params.style }}
{{ $extra := resources.Get . | minify }}
<link href="{{ $extra.RelPermalink }}" rel="stylesheet">
{{ end }}

{{ with .OutputFormats.Get "rss" -}}
{{ printf `<link rel="%s" type="%s" href="%s" title="%s" />` .Rel .MediaType.Type .Permalink $.Site.Title | safeHTML }}
{{ end -}}

<!-- A partial to be overwritten by the user.
<head>
<meta http-equiv="X-Clacks-Overhead" content="GNU Terry Pratchett" />
<meta charset="utf-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
{{- partial "favicon.html" . -}}
<title>
{{- block "title" . }}
{{ with .Title }}{{ . }} |{{ end }}{{ .Site.Title }}
{{- end }}
</title>

{{- partial "seo_tags.html" . -}}
<meta name="referrer" content="no-referrer-when-downgrade" />

{{ $simple := resources.Get "simple.css" | minify }}
<link href="{{ $simple.RelPermalink }}" rel="stylesheet" />

{{ $style := resources.Get "style.css" | minify }}
<link href="{{ $style.RelPermalink }}" rel="stylesheet" />

{{ if (.Page.Store.Get "hasCodeBlock") }}
{{ $syntax := resources.Get "syntax.css" | minify }}
<link href="{{ $syntax.RelPermalink }}" rel="stylesheet" />
{{ end }}

{{ with .Params.style }}
{{ $extra := resources.Get . | minify }}
<link href="{{ $extra.RelPermalink }}" rel="stylesheet" />
{{ end }}

{{ with .OutputFormats.Get "rss" -}}
{{ printf `<link rel="%s" type="%s" href="%s" title="%s" />` .Rel .MediaType.Type .Permalink $.Site.Title | safeHTML }}
{{ end -}}


<!-- A partial to be overwritten by the user.
Simply place a custom_head.html into
your local /layouts/partials-directory -->
{{- partial "custom_head.html" . -}}
</head>

<body>
<header>
{{ partial "header.html" . }}
</header>
<main>
{{ block "main" . }}{{ end }}
</main>
<footer>
{{ partial "footer.html" . }}
</footer>

<!-- A partial to be overwritten by the user.
{{- partial "custom_head.html" . -}}
</head>

<body>
<header>
{{ partial "header.html" . }}
</header>
<main>
{{ block "main" . }}{{ end }}
</main>
<footer>
{{ partial "footer.html" . }}
</footer>

<!-- A partial to be overwritten by the user.
Simply place a custom_body.html into
your local /layouts/partials-directory -->
{{- partial "custom_body.html" . -}}
</body>

{{- partial "custom_body.html" . -}}
</body>
</html>
76 changes: 37 additions & 39 deletions layouts/_default/list.html
Original file line number Diff line number Diff line change
@@ -1,44 +1,42 @@
{{ define "main" }}
<content>
{{ if .Data.Singular }}
<h3>Filtering for "{{ .Title }}"</h3>
<small>
<a href="{{ relURL "blog" }}">Remove filter</a>
</small>
{{ end }}
{{ if or .Paginator.HasPrev .Paginator.HasNext }}
{{- partial "pagination.html" . -}}
{{ end }}
<ul class="blog-posts">
{{ range .Paginator.Pages }}
<li>
<span>
<i>
<time datetime='{{ .Date.Format "2006-01-02" }}' pubdate>
{{ .Date.Format (default "2006-01-02" .Site.Params.dateFormat) }}
</time>
</i>
</span>
{{ if .Params.link }}
<a href="{{ .Params.link }}" target="_blank">{{ .Title }} ↪</a>
<content>
{{ if .Data.Singular }}
<h3>Filtering for "{{ .Title }}"</h3>
<small>
<a href="{{ relURL "blog" }}">Remove filter</a>
</small>
{{ end }}
{{ if or .Paginator.HasPrev .Paginator.HasNext }}
{{- partial "pagination.html" . -}}
{{ end }}
<ul class="blog-posts">
{{ range .Paginator.Pages }}
<li>
<span>
<i>
<time datetime="{{ .Date.Format "2006-01-02" }}" pubdate>
{{ .Date.Format (default "2006-01-02" .Site.Params.dateFormat) }}
</time>
</i>
</span>
{{ if .Params.link }}
<a href="{{ .Params.link }}" target="_blank">{{ .Title }} ↪</a>
{{ else }}
<a href="{{ .Permalink }}">{{ .Title }}</a>
{{ end }}
</li>
{{ else }}
<a href="{{ .Permalink }}">{{ .Title }}</a>
<li>No posts yet</li>
{{ end }}
</li>
{{ else }}
<li>
No posts yet
</li>
</ul>
{{ if not .Data.Singular }}
<small>
<div>
{{ range .Site.Taxonomies.tags }}
<a href="{{ .Page.Permalink }}">#{{ .Page.Title }}</a>&nbsp;&nbsp;
{{ end }}
</div>
</small>
{{ end }}
</ul>
{{ if not .Data.Singular }}
<small>
<div>
{{ range .Site.Taxonomies.tags }}
<a href="{{ .Page.Permalink }}">#{{ .Page.Title }}</a>&nbsp;&nbsp;
{{ end }}
</div>
</small>
{{ end }}
</content>
</content>
{{ end }}
48 changes: 25 additions & 23 deletions layouts/_default/single.html
Original file line number Diff line number Diff line change
@@ -1,26 +1,28 @@
{{ define "main" }}
{{ if eq .Type "blog" }}{{ if not .Params.menu }}
<!-- <h1>{{ .Title }}</h1> -->
<p>
<i>
<time datetime='{{ .Date.Format "2006-01-02" }}' pubdate>
{{ .Date.Format (default "2006-01-02" .Site.Params.dateFormat) }}
</time>
</i>
</p>
{{ end }}{{ end }}
{{ if and (gt .WordCount 400 ) (.Params.toc) }}
<details>
<summary>Table of contents</summary>
{{ .TableOfContents }}
</details>
{{ end }}
<content>
{{ .Content }}
</content>
<p>
{{ range (.GetTerms "tags") }}
<a href="{{ .Permalink }}">#{{ .LinkTitle }}</a>&nbsp;&nbsp;
{{ if eq .Type "blog" }}
{{ if not .Params.menu }}
<!-- <h1>{{ .Title }}</h1> -->
<p>
<i>
<time datetime="{{ .Date.Format "2006-01-02" }}" pubdate>
{{ .Date.Format (default "2006-01-02" .Site.Params.dateFormat) }}
</time>
</i>
</p>
{{ end }}
{{ end }}
{{ if and (gt .WordCount 400 ) (.Params.toc) }}
<details>
<summary>Table of contents</summary>
{{ .TableOfContents }}
</details>
{{ end }}
</p>
<content>
{{ .Content }}
</content>
<p>
{{ range (.GetTerms "tags") }}
<a href="{{ .Permalink }}">#{{ .LinkTitle }}</a>&nbsp;&nbsp;
{{ end }}
</p>
{{ end }}
2 changes: 1 addition & 1 deletion layouts/index.html
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
{{ define "main" }}
{{ .Content }}
{{ .Content }}
{{ end }}
2 changes: 1 addition & 1 deletion layouts/partials/custom_body.html
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
<!-- A partial to be overwritten by the user.
<!-- A partial to be overwritten by the user.
Simply place a custom_body.html into
your local /layouts/partials-directory -->
3 changes: 2 additions & 1 deletion layouts/partials/favicon.html
Original file line number Diff line number Diff line change
@@ -1,2 +1,3 @@
{{ with .Site.Params.favicon }}
<link rel="shortcut icon" href="{{ absURL . }}" />{{ end }}
<link rel="shortcut icon" href="{{ absURL . }}" />
{{ end }}
5 changes: 4 additions & 1 deletion layouts/partials/footer.html
Original file line number Diff line number Diff line change
@@ -1 +1,4 @@
{{ if not .Site.Params.hideMadeWithLine }}Made with <a href="https://github.com/maolonglong/hugo-simple/">Hugo ʕ•ᴥ•ʔ Simple</a>{{ end }}
{{ if not .Site.Params.hideMadeWithLine }}
Made with
<a href="https://github.com/maolonglong/hugo-simple/">Hugo ʕ•ᴥ•ʔ Simple</a>
{{ end }}
2 changes: 1 addition & 1 deletion layouts/partials/header.html
Original file line number Diff line number Diff line change
Expand Up @@ -2,5 +2,5 @@

<h1>{{ .Title }}</h1>
{{ with .Description }}
<p>{{ . }}</p>
<p>{{ . }}</p>
{{ end }}
9 changes: 6 additions & 3 deletions layouts/partials/nav.html
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
{{ $currentPage := . -}}
{{ range .Site.Menus.main.ByWeight }}
<a href="{{ .URL }}" {{ if eq $currentPage .Page }} class="current"{{ end }}>{{ .Name }}</a>
{{ end }}
<a href='{{ absURL "index.xml" }}'>RSS</a>
<a
href="{{ .URL }}"
{{ if eq $currentPage .Page }}class="current"{{ end }}
>{{ .Name }}</a
>
{{ end }} <a href="{{ absURL "index.xml" }}">RSS</a>
16 changes: 11 additions & 5 deletions layouts/partials/pagination.html
Original file line number Diff line number Diff line change
@@ -1,12 +1,18 @@
<div class="pagination">
<a {{ if .Paginator.HasPrev }}href="{{ .Paginator.Prev.URL }}"{{ else }}style="visibility: hidden;"{{ end }}>
<a
{{ if .Paginator.HasPrev }}
href="{{ .Paginator.Prev.URL }}"
{{ else }}
style="visibility: hidden;"
{{ end }}
>
<span></span>
<span>Newer posts</span>
</a>
{{ if .Paginator.HasNext }}
<a href="{{ .Paginator.Next.URL }}">
<span>Older posts</span>
<span></span>
</a>
<a href="{{ .Paginator.Next.URL }}">
<span>Older posts</span>
<span></span>
</a>
{{ end }}
</div>
Loading

0 comments on commit fff14a2

Please sign in to comment.