Switch to geekblog

This commit is contained in:
2021-05-07 12:21:40 +02:00
parent c581cf96dd
commit ac750460a8
94 changed files with 2480 additions and 2 deletions
@@ -0,0 +1,18 @@
{{ $showAnchor := (and (default true .Page.Params.GeekblogAnchor) (default true .Page.Site.Params.GeekblogAnchor)) }}
{{ if $showAnchor }}
<div class="gblog-post__anchorwrap">
<h{{ .Level }} id="{{ .Anchor | safeURL }}">
{{ .Text | safeHTML }}
<a data-clipboard-text="{{ .Page.Permalink }}#{{ .Anchor | safeURL }}" class="gblog-post__anchor gblog-post__anchor--right clip" aria-label="Anchor {{ .Text | safeHTML }}" href="#{{ .Anchor | safeURL }}">
<svg class="icon link"><use xlink:href="#link"></use></svg>
</a>
</h{{ .Level }}>
</div>
{{ else }}
<div class="gblog-post__anchorwrap">
<h{{ .Level }} id="{{ .Anchor | safeURL }}">
{{ .Text | safeHTML }}
</h{{ .Level }}>
</div>
{{ end }}
@@ -0,0 +1 @@
<img src="{{ .Destination | safeURL | relURL }}" alt="{{ .Text }}" {{ with .Title}} title="{{ . }}"{{ end }} />
@@ -0,0 +1,2 @@
{{- $raw := or (hasPrefix .Text "<img") (hasPrefix .Text "<figure") -}}
<a class="gblog-post__link{{ if $raw }}--raw{{ end }}" href="{{ .Destination | safeURL }}"{{ with .Title }} title="{{ . }}"{{ end }}>{{ .Text | safeHTML }}</a>
@@ -0,0 +1,30 @@
<!DOCTYPE html>
<html itemscope itemtype="http://schema.org/WebPage" lang="{{ .Site.Language.Lang }}">
<head>
{{ partial "head/meta" . }}
<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" . }}
</head>
<body>
{{ partial "svg-icon-symbols" . }}
<div class="wrapper">
{{ partial "site-header" . }}
<main class="gblog-page container">
{{ template "main" . }}
</main>
{{ partial "site-footer" . }}
</div>
{{ partial "foot" . }}
</body>
</html>
@@ -0,0 +1,71 @@
{{ printf `<?xml version="1.0" encoding="utf-8"?>` | safeHTML }} {{/* ref: https://validator.w3.org/feed/docs/atom.html */}}
<feed xmlns="http://www.w3.org/2005/Atom"{{ with .Site.Language.Lang }} xml:lang="{{ . }}"{{ end }}>
<generator uri="https://gohugo.io/" version="{{ hugo.Version }}">Hugo</generator>
{{- $title := .Site.Title -}}
{{- with .Title -}}
{{- if (not (eq . $title)) -}}
{{- $title = printf `%s on %s` . $title -}}
{{- end -}}
{{- end -}}
{{ printf `<title type="html"><![CDATA[%s]]></title>` $title | safeHTML }}
{{ with .Site.Params.subtitle }}
{{ printf `<subtitle type="html"><![CDATA[%s]]></subtitle>` . | safeHTML }}
{{ end }}
{{ $output_formats := .OutputFormats }}
{{ range $output_formats -}}
{{- $rel := (or (and (eq "atom" (.Name | lower)) "self") "alternate") -}}
{{ with $output_formats.Get .Name }}
{{ printf `<link href=%q rel=%q type=%q title=%q />` .Permalink $rel .MediaType.Type .Name | safeHTML }}
{{- end -}}
{{- end }}
<updated>{{ now.Format "2006-01-02T15:04:05-07:00" | safeHTML }}</updated>
{{ with .Site.Params.GeekblogAuthor -}}
{{ with index $.Site.Data.authors . }}
<author>
<name>{{ .name }}</name>
{{ with .email }}
<email>{{ . }}</email>
{{ end -}}
</author>
{{ end }}
{{- end }}
<id>{{ .Permalink }}</id>
{{- $pages := where .RegularPages "Type" "in" .Site.Params.mainSections -}}
{{- if (eq .Kind "home") -}}
{{- $pages = where .Site.RegularPages "Type" "in" .Site.Params.mainSections -}}
{{- end -}}
{{- range $pages }}
{{ $page := . }}
<entry>
{{ printf `<title type="html"><![CDATA[%s]]></title>` .Title | safeHTML }}
<link href="{{ .Permalink }}?utm_source=atom_feed" rel="alternate" type="text/html" {{ with .Site.Language.Lang }} hreflang="{{ . }}"{{ end }} />
<id>{{ .Permalink }}</id>
{{ with .Params.authors -}}
{{- range sort . -}}
{{ $author := index $.Site.Data.authors . }}
<author>
<name>{{ $author.name }}</name>
</author>
{{- end -}}
{{- end }}
<published>{{ .Date.Format "2006-01-02T15:04:05-07:00" | safeHTML }}</published>
<updated>{{ .Lastmod.Format "2006-01-02T15:04:05-07:00" | safeHTML }}</updated>
{{ $desc := .Description | default "" }}
{{ $description := (cond (eq "" $desc) "" (printf "<blockquote>%s</blockquote>" ($desc | $.Page.RenderString))) }}
{{ printf `<content type="html"><![CDATA[%s%s]]></content>` $description .Content | safeHTML }}
{{ with .Site.Taxonomies }}
{{ range $taxo,$_ := . }} <!-- Defaults taxos: "tags", "categories" -->
{{ with $page.Param $taxo }}
{{ $taxo_list := . }} <!-- $taxo_list will be the tags/categories list -->
{{ with $.Site.GetPage (printf "/%s" $taxo) }}
{{ $taxonomy_page := . }}
{{ range $taxo_list }} <!-- Below, assuming pretty URLs -->
<category scheme="{{ printf "%s%s" $taxonomy_page.Permalink (. | urlize) }}" term="{{ (. | urlize) }}" label="{{ . }}" />
{{ end }}
{{ end }}
{{ end }}
{{ end }}
{{ end }}
</entry>
{{ end }}
</feed>
@@ -0,0 +1,99 @@
{{ define "main" }}
{{ $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 }}
<article class="gblog-post">
<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</a>
{{ end }}
</div>
<footer class="gblog-post__footer">
<span class="no-wrap">
<svg class="icon date"><use xlink:href="#date"></use></svg>
<span class="gblog-post__tag">
<time datetime="{{ .Lastmod.Format "2006-01-02T15:04:05Z07:00" | safeHTML }}">
{{ if .Lastmod.After (.Date.AddDate 0 0 1) }}
Updated on
{{ end }}
{{ .Lastmod.Format "Jan 2, 2006" }}
</time>
</span>
</span>
<span class="no-wrap">
<svg class="icon timer"><use xlink:href="#timer"></use></svg>
<span class="gblog-post__tag">{{ .ReadingTime }} min read</span>
</span>
{{ if .Params.weight }}
<span class="no-wrap">
<svg class="icon pin"><use xlink:href="#pin"></use></svg>
<span class="gblog-post__tag">Pinned</span>
</span>
{{ end }}
{{ $ac := 0 }}
{{ with .Params.authors }}
{{ range sort . }}
{{ $author := index $.Site.Data.authors . }}
{{ with $.Site.GetPage (printf "/authors/%s" . | urlize) }}
{{ if eq $ac 0 }}
<span class="no-wrap">
<svg class="icon person"><use xlink:href="#person"></use></svg>
{{ template "post-author" dict "name" $author.name "page" . }}
</span>
{{ else }}
{{ template "post-author" dict "name" $author.name "page" . }}
{{ end }}
{{ end }}
{{ $ac = (add $ac 1) }}
{{ end }}
{{ end }}
{{ $tc := 0 }}
{{ with .Params.tags }}
{{ range sort . }}
{{ $name := . }}
{{ with $.Site.GetPage (printf "/tags/%s" $name | urlize) }}
{{ if eq $tc 0 }}
<span class="no-wrap">
<svg class="icon bookmarks"><use xlink:href="#bookmarks"></use></svg>
{{ template "post-tag" dict "name" $name "page" . }}
</span>
{{ else }}
{{ template "post-tag" dict "name" $name "page" . }}
{{ end }}
{{ end }}
{{ $tc = (add $tc 1) }}
{{ end }}
{{ end }}
</footer>
</article>
{{ end }}
{{ partial "pagination.html" . }}
{{ end }}
{{ define "post-tag" }}
<span class="gblog-post__tag gblog-button">
<a class="gblog-button__link" href="{{ .page.RelPermalink }}" title="All posts tagged with '{{ .name }}'">{{ .name }}</a>
</span>
{{ end }}
{{ define "post-author" }}
<span class="gblog-post__tag gblog-button">
<a class="gblog-button__link" href="{{ .page.RelPermalink }}" title="All posts of this author">{{ .name }}</a>
</span>
{{ end }}
@@ -0,0 +1,57 @@
{{- $title := .Site.Title -}}
{{- with .Title -}}
{{- if (not (eq . $title)) -}}
{{- $title = printf `%s on %s` . $title -}}
{{- end -}}
{{- end -}}
{
"version": "https://jsonfeed.org/version/1.1",
"title": {{ $title | jsonify }},
{{- with .Site.Params.subtitle }}
"description": {{ . | jsonify }},
{{- end }}
"home_page_url" : "{{ .Site.BaseURL }}",
{{- with .OutputFormats.Get "json" }}
"feed_url" : "{{ .Permalink }}",
{{- end }}
{{- with .Site.Params.GeekblogAuthor -}}
{{ with index $.Site.Data.authors . }}
"authors" : [
{
"name" : "{{ .name }}"{{ with .url }},
"url": "{{ . }}"{{ end }}{{ with .avatar }},
"avatar": "{{ . }}"{{ end }}
}
],
{{- end }}
{{- end }}
"items" : [
{{- $pages := where .RegularPages "Type" "in" .Site.Params.mainSections -}}
{{- if (eq .Kind "home") -}}
{{- $pages = where .Site.RegularPages "Type" "in" .Site.Params.mainSections -}}
{{- end -}}
{{- $len := (len $pages) }}
{{- range $i, $page := $pages }}
{
"title" : {{ .Title | jsonify }},
"date_published" : {{ (.Date.Format "2006-01-02T15:04:05Z07:00") | jsonify }},
"date_modified" : {{ (.Lastmod.Format "2006-01-02T15:04:05Z07:00") | jsonify }},
"id" : "{{ .Permalink }}",
"url" : "{{ .Permalink }}",
{{- with .Params.authors -}}
"authors" : [
{{- $authors := (sort .) }}
{{- $authors_len := (len $authors) }}
{{- range $i, $element := $authors -}}
{{- $author := index $.Site.Data.authors $element }}
{
"name" : "{{ $author.name }}"
}{{ if ne (add $i 1) $authors_len }},{{ end }}
{{- end }}
],
{{- end }}
"content_html" : {{ .Content | jsonify }}
}{{ if ne (add $i 1) $len }},{{ end }}
{{- end }}
]
}
@@ -0,0 +1,45 @@
{{ 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 }}
<h1>{{ partial "title" . }}</h1>
{{ if or (eq .Type (default "posts" .Site.Params.GeekblogContentSection)) (eq .Type "post") }}
<div class="gblog-post__meta">
<span class="no-wrap">
<svg class="icon date"><use xlink:href="#date"></use></svg>
<span class="gblog-post__tag">
<time datetime="{{ .Lastmod.Format "2006-01-02T15:04:05Z07:00" | safeHTML }}">
{{ if ne (.Lastmod.Format "2006-01-02") (.Date.Format "2006-01-02") }}
Updated on
{{ end }}
{{ .Lastmod.Format "Jan 2, 2006" }}
</time>
</span>
</span>
<span class="no-wrap">
<svg class="icon timer"><use xlink:href="#timer"></use></svg>
<span class="gblog-post__tag">{{ .ReadingTime }} min read</span>
</span>
</div>
{{ end }}
</header>
<section class="gblog-markdown">
{{ partial "content" . }}
</section>
</article>
{{ end }}