treefmt: fix config, add prettier-plugin-go-template
This commit is contained in:
parent
6ccec6f792
commit
9e8f680c52
10 changed files with 137 additions and 85 deletions
|
|
@ -1,14 +1,19 @@
|
||||||
{{ define "main" }} {{ .Content }} {{ $pages := .Paginate (where
|
{{ define "main" }}
|
||||||
.Site.RegularPages "Type" "ne" "page") }} {{ range $pages.Pages }}
|
{{ .Content }}
|
||||||
<a href="{{ .RelPermalink }}" style="display: block">
|
{{ $pages := .Paginate (where
|
||||||
<div class="list">
|
.Site.RegularPages "Type" "ne" "page")
|
||||||
{{ $dateMachine := .Date | time.Format "2006-01-02T15:04:05-07:00" }} {{
|
}}
|
||||||
$dateHuman := .Date | time.Format "2006-01-02" }}
|
{{ range $pages.Pages }}
|
||||||
<time datetime="{{ $dateMachine }}">{{ $dateHuman }}</time>
|
<a href="{{ .RelPermalink }}" style="display: block">
|
||||||
|
<div class="list">
|
||||||
|
{{ $dateMachine := .Date | time.Format "2006-01-02T15:04:05-07:00" }}
|
||||||
|
{{ $dateHuman := .Date | time.Format "2006-01-02" }}
|
||||||
|
<time datetime="{{ $dateMachine }}">{{ $dateHuman }}</time>
|
||||||
|
|
||||||
<h2>{{ .Title }}</h2>
|
<h2>{{ .Title }}</h2>
|
||||||
|
|
||||||
<p class="lead">{{ .Description }}</p>
|
<p class="lead">{{ .Description }}</p>
|
||||||
</div>
|
</div>
|
||||||
</a>
|
</a>
|
||||||
{{ end }} {{ end }}
|
{{ end }}
|
||||||
|
{{ end }}
|
||||||
|
|
|
||||||
|
|
@ -1,13 +1,16 @@
|
||||||
{{ define "main" }} {{ .Content }} {{ range .Pages }}
|
{{ define "main" }}
|
||||||
<a href="{{ .RelPermalink }}" style="display: block">
|
{{ .Content }}
|
||||||
<div class="list">
|
{{ range .Pages }}
|
||||||
{{ $dateMachine := .Date | time.Format "2006-01-02T15:04:05-07:00" }} {{
|
<a href="{{ .RelPermalink }}" style="display: block">
|
||||||
$dateHuman := .Date | time.Format "2006-01-02" }}
|
<div class="list">
|
||||||
<time datetime="{{ $dateMachine }}">{{ $dateHuman }}</time>
|
{{ $dateMachine := .Date | time.Format "2006-01-02T15:04:05-07:00" }}
|
||||||
|
{{ $dateHuman := .Date | time.Format "2006-01-02" }}
|
||||||
|
<time datetime="{{ $dateMachine }}">{{ $dateHuman }}</time>
|
||||||
|
|
||||||
<h2>{{ .Title }}</h2>
|
<h2>{{ .Title }}</h2>
|
||||||
|
|
||||||
<p class="lead">{{ .Description }}</p>
|
<p class="lead">{{ .Description }}</p>
|
||||||
</div>
|
</div>
|
||||||
</a>
|
</a>
|
||||||
{{ end }} {{ end }}
|
{{ end }}
|
||||||
|
{{ end }}
|
||||||
|
|
|
||||||
|
|
@ -1,14 +1,15 @@
|
||||||
{{ define "main" }}
|
{{ define "main" }}
|
||||||
<article>
|
<article>
|
||||||
{{ $dateMachine := .Lastmod | time.Format "2006-01-02T15:04:05-07:00" }} {{
|
{{ $dateMachine := .Lastmod | time.Format "2006-01-02T15:04:05-07:00" }}
|
||||||
$dateHuman := .Lastmod | time.Format "2006-01-02" }}
|
{{ $dateHuman := .Lastmod | time.Format "2006-01-02" }}
|
||||||
<time datetime="{{ $dateMachine }}">{{ $dateHuman }}</time>
|
<time datetime="{{ $dateMachine }}">{{ $dateHuman }}</time>
|
||||||
<br />
|
<br />
|
||||||
|
|
||||||
<h1>{{ .Title }}</h1>
|
<h1>{{ .Title }}</h1>
|
||||||
|
|
||||||
<p class="lead">{{ .Description }}</p>
|
<p class="lead">{{ .Description }}</p>
|
||||||
|
|
||||||
{{ .Content }}
|
{{ .Content }}
|
||||||
</article>
|
</article>
|
||||||
{{ partial "terms.html" (dict "taxonomy" "tags" "page" .) }} {{ end }}
|
{{ partial "terms.html" (dict "taxonomy" "tags" "page" .) }}
|
||||||
|
{{ end }}
|
||||||
|
|
|
||||||
|
|
@ -5,10 +5,18 @@
|
||||||
<meta name="author" content="Jan Kremer" />
|
<meta name="author" content="Jan Kremer" />
|
||||||
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
|
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
|
||||||
<title>
|
<title>
|
||||||
{{ if .IsHome }}{{ site.Title }}{{ else }}{{ printf "%s – %s" .Title
|
{{ if .IsHome }}
|
||||||
site.Title }}{{ end }}
|
{{ site.Title }}
|
||||||
|
{{ else }}
|
||||||
|
{{ printf "%s – %s" .Title
|
||||||
|
site.Title
|
||||||
|
}}
|
||||||
|
{{ end }}
|
||||||
</title>
|
</title>
|
||||||
{{ partialCached "head/css.html" . }} {{ partialCached "head/js.html" . }} {{
|
{{ partialCached "head/css.html" . }} {{ partialCached "head/js.html" . }}
|
||||||
partial "head/analytics.html" . }} {{ with .OutputFormats.Get "rss" -}} {{
|
{{ partial "head/analytics.html" . }}
|
||||||
printf `<link rel="%q" type="%q" href="%q" title="%q" />` .Rel .MediaType.Type
|
{{ with .OutputFormats.Get "rss" -}}
|
||||||
.Permalink site.Title | safeHTML }} {{ end }}
|
{{ printf `<link rel="%q" type="%q" href="%q" title="%q" />` .Rel .MediaType.Type
|
||||||
|
.Permalink site.Title | safeHTML
|
||||||
|
}}
|
||||||
|
{{ end }}
|
||||||
|
|
|
||||||
|
|
@ -1,7 +1,7 @@
|
||||||
{{ if hugo.IsProduction }}
|
{{ if hugo.IsProduction }}
|
||||||
<script
|
<script
|
||||||
data-goatcounter="https://jankremer.goatcounter.com/count"
|
data-goatcounter="https://jankremer.goatcounter.com/count"
|
||||||
async
|
async
|
||||||
src="//gc.zgo.at/count.js"
|
src="//gc.zgo.at/count.js"
|
||||||
></script>
|
></script>
|
||||||
{{ end }}
|
{{ end }}
|
||||||
|
|
|
||||||
|
|
@ -1,11 +1,16 @@
|
||||||
{{- with resources.Get "css/main.css" }} {{- if eq hugo.Environment
|
{{- with resources.Get "css/main.css" }}
|
||||||
"development" }}
|
{{- if eq hugo.Environment
|
||||||
<link rel="stylesheet" href="{{ .RelPermalink }}" />
|
"development"
|
||||||
{{- else }} {{- with . | minify | fingerprint }}
|
}}
|
||||||
<link
|
<link rel="stylesheet" href="{{ .RelPermalink }}" />
|
||||||
rel="stylesheet"
|
{{- else }}
|
||||||
href="{{ .RelPermalink }}"
|
{{- with . | minify | fingerprint }}
|
||||||
integrity="{{ .Data.Integrity }}"
|
<link
|
||||||
crossorigin="anonymous"
|
rel="stylesheet"
|
||||||
/>
|
href="{{ .RelPermalink }}"
|
||||||
{{- end }} {{- end }} {{- end }}
|
integrity="{{ .Data.Integrity }}"
|
||||||
|
crossorigin="anonymous"
|
||||||
|
/>
|
||||||
|
{{- end }}
|
||||||
|
{{- end }}
|
||||||
|
{{- end }}
|
||||||
|
|
|
||||||
|
|
@ -1,11 +1,18 @@
|
||||||
{{- with resources.Get "js/main.js" }} {{- if eq hugo.Environment "development"
|
{{- with resources.Get "js/main.js" }}
|
||||||
}} {{- with . | js.Build }}
|
{{- if eq hugo.Environment "development" }}
|
||||||
<script src="{{ .RelPermalink }}"></script>
|
{{- with . | js.Build }}
|
||||||
{{- end }} {{- else }} {{- $opts := dict "minify" true }} {{- with . | js.Build
|
<script src="{{ .RelPermalink }}"></script>
|
||||||
$opts | fingerprint }}
|
{{- end }}
|
||||||
<script
|
{{- else }}
|
||||||
src="{{ .RelPermalink }}"
|
{{- $opts := dict "minify" true }}
|
||||||
integrity="{{- .Data.Integrity }}"
|
{{- with . | js.Build
|
||||||
crossorigin="anonymous"
|
$opts | fingerprint
|
||||||
></script>
|
}}
|
||||||
{{- end }} {{- end }} {{- end }}
|
<script
|
||||||
|
src="{{ .RelPermalink }}"
|
||||||
|
integrity="{{- .Data.Integrity }}"
|
||||||
|
crossorigin="anonymous"
|
||||||
|
></script>
|
||||||
|
{{- end }}
|
||||||
|
{{- end }}
|
||||||
|
{{- end }}
|
||||||
|
|
|
||||||
|
|
@ -1,12 +1,12 @@
|
||||||
{{- /*
|
{{- /*
|
||||||
Renders a menu for the given menu ID.
|
Renders a menu for the given menu ID.
|
||||||
|
|
||||||
@context {page} page The current page.
|
@context {page} page The current page.
|
||||||
@context {string} menuID The menu ID.
|
@context {string} menuID The menu ID.
|
||||||
|
|
||||||
@example: {{ partial "menu.html" (dict "menuID" "main" "page" .) }}
|
@example: {{ partial "menu.html" (dict "menuID" "main" "page" .)
|
||||||
|
}}
|
||||||
*/}}
|
*/}}
|
||||||
|
|
||||||
{{- $page := .page }}
|
{{- $page := .page }}
|
||||||
{{- $menuID := .menuID }}
|
{{- $menuID := .menuID }}
|
||||||
|
|
||||||
|
|
@ -24,7 +24,7 @@ Renders a menu for the given menu ID.
|
||||||
{{- $attrs := dict "href" .URL }}
|
{{- $attrs := dict "href" .URL }}
|
||||||
{{- if $page.IsMenuCurrent .Menu . }}
|
{{- if $page.IsMenuCurrent .Menu . }}
|
||||||
{{- $attrs = merge $attrs (dict "class" "active" "aria-current" "page") }}
|
{{- $attrs = merge $attrs (dict "class" "active" "aria-current" "page") }}
|
||||||
{{- else if $page.HasMenuCurrent .Menu .}}
|
{{- else if $page.HasMenuCurrent .Menu . }}
|
||||||
{{- $attrs = merge $attrs (dict "class" "ancestor" "aria-current" "true") }}
|
{{- $attrs = merge $attrs (dict "class" "ancestor" "aria-current" "true") }}
|
||||||
{{- end }}
|
{{- end }}
|
||||||
{{- $name := .Name }}
|
{{- $name := .Name }}
|
||||||
|
|
@ -40,7 +40,8 @@ Renders a menu for the given menu ID.
|
||||||
{{- printf " %s=%q" $k $v | safeHTMLAttr }}
|
{{- printf " %s=%q" $k $v | safeHTMLAttr }}
|
||||||
{{- end }}
|
{{- end }}
|
||||||
{{- end -}}
|
{{- end -}}
|
||||||
>{{ $name }}</a>
|
>{{ $name }}</a
|
||||||
|
>
|
||||||
{{- with .Children }}
|
{{- with .Children }}
|
||||||
<ul>
|
<ul>
|
||||||
{{- partial "inline/menu/walk.html" (dict "page" $page "menuEntries" .) }}
|
{{- partial "inline/menu/walk.html" (dict "page" $page "menuEntries" .) }}
|
||||||
|
|
|
||||||
|
|
@ -1,13 +1,17 @@
|
||||||
{{- /* For a given taxonomy, renders a list of terms assigned to the page.
|
{{- /* For a given taxonomy, renders a list of terms assigned to the page.
|
||||||
@context {page} page The current page. @context {string} taxonomy The taxonony.
|
@context {page} page The current page. @context {string} taxonomy The taxonony.
|
||||||
@example: {{ partial "terms.html" (dict "taxonomy" "tags" "page" .) }} */}} {{-
|
@example: {{ partial "terms.html" (dict "taxonomy" "tags" "page" .)
|
||||||
$page := .page }} {{- $taxonomy := .taxonomy }} {{- with $page.GetTerms
|
}}
|
||||||
$taxonomy }} {{- $label := (index . 0).Parent.LinkTitle }}
|
*/}} {{- $page := .page }} {{- $taxonomy := .taxonomy }}
|
||||||
<div class="tags">
|
{{- with $page.GetTerms
|
||||||
<ul>
|
$taxonomy
|
||||||
{{- range . }}
|
}}
|
||||||
<li><a href="{{ .RelPermalink }}">{{ .LinkTitle }}</a></li>
|
{{- $label := (index . 0).Parent.LinkTitle }}
|
||||||
{{- end }}
|
<div class="tags">
|
||||||
</ul>
|
<ul>
|
||||||
</div>
|
{{- range . }}
|
||||||
|
<li><a href="{{ .RelPermalink }}">{{ .LinkTitle }}</a></li>
|
||||||
|
{{- end }}
|
||||||
|
</ul>
|
||||||
|
</div>
|
||||||
{{- end }}
|
{{- end }}
|
||||||
|
|
|
||||||
20
treefmt.nix
20
treefmt.nix
|
|
@ -1,9 +1,27 @@
|
||||||
|
{ pkgs, ... }:
|
||||||
{
|
{
|
||||||
projectRootFile = "flake.nix";
|
projectRootFile = "flake.nix";
|
||||||
programs = {
|
programs = {
|
||||||
nixfmt.enable = true;
|
nixfmt.enable = true;
|
||||||
gofmt.enable = true;
|
gofmt.enable = true;
|
||||||
taplo.enable = true;
|
taplo.enable = true;
|
||||||
prettier.enable = true;
|
prettier = {
|
||||||
|
enable = true;
|
||||||
|
settings = {
|
||||||
|
plugins = [
|
||||||
|
"${pkgs.prettier-plugin-go-template}/lib/node_modules/prettier-plugin-go-template/lib/index.js"
|
||||||
|
];
|
||||||
|
overrides = [
|
||||||
|
{
|
||||||
|
files = [ "*.html" ];
|
||||||
|
options.parser = "go-template";
|
||||||
|
}
|
||||||
|
];
|
||||||
|
};
|
||||||
|
};
|
||||||
};
|
};
|
||||||
|
settings.global.excludes = [
|
||||||
|
"public/**"
|
||||||
|
"static/**"
|
||||||
|
];
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue