diff options
Diffstat (limited to 'layouts')
| -rw-r--r-- | layouts/_default/_markup/render-image.html | 5 | ||||
| -rw-r--r-- | layouts/_default/baseof.html | 23 | ||||
| -rw-r--r-- | layouts/baseof.html | 23 | ||||
| -rw-r--r-- | layouts/home.html | 8 | ||||
| -rw-r--r-- | layouts/home.rss.xml | 21 | ||||
| -rw-r--r-- | layouts/journal/list.html | 19 | ||||
| -rw-r--r-- | layouts/journal/single.html | 37 | ||||
| -rw-r--r-- | layouts/links/list.html | 9 | ||||
| -rw-r--r-- | layouts/notes/list.html | 41 | ||||
| -rw-r--r-- | layouts/notes/single.html | 20 | ||||
| -rw-r--r-- | layouts/partials/document-view.html | 19 | ||||
| -rw-r--r-- | layouts/partials/footer.html | 11 | ||||
| -rw-r--r-- | layouts/partials/header.html | 7 | ||||
| -rw-r--r-- | layouts/partials/primary-nav.html | 8 | ||||
| -rw-r--r-- | layouts/partials/recent.html | 23 | ||||
| -rw-r--r-- | layouts/partials/series-nav.html | 35 | ||||
| -rw-r--r-- | layouts/partials/toc.html | 7 | ||||
| -rw-r--r-- | layouts/projects/list.html | 9 |
18 files changed, 325 insertions, 0 deletions
diff --git a/layouts/_default/_markup/render-image.html b/layouts/_default/_markup/render-image.html new file mode 100644 index 0000000..a24e27e --- /dev/null +++ b/layouts/_default/_markup/render-image.html @@ -0,0 +1,5 @@ +{{- $source := .Destination -}} +{{- with .Page.Resources.GetMatch .Destination -}} + {{- $source = .RelPermalink -}} +{{- end -}} +<img src="{{ $source | safeURL }}" alt="{{ .PlainText }}"{{ with .Title }} title="{{ . }}"{{ end }}> diff --git a/layouts/_default/baseof.html b/layouts/_default/baseof.html new file mode 100644 index 0000000..edc5cbe --- /dev/null +++ b/layouts/_default/baseof.html @@ -0,0 +1,23 @@ +<!doctype html> +{{- $pageLang := default "en" .Params.lang -}} +{{- $description := site.Params.description -}} +{{- with .Params.description }}{{ $description = . }}{{ end -}} +<html lang="{{ $pageLang }}"> +<head> + <meta charset="utf-8"> + <meta name="viewport" content="width=device-width, initial-scale=1"> + <title>{{ if .IsHome }}{{ site.Title }}{{ else }}{{ .Title }} | {{ site.Title }}{{ end }}</title> + <meta name="description" content="{{ $description }}"> + <link rel="canonical" href="{{ .Permalink }}"> + <link rel="alternate" type="application/rss+xml" title="{{ site.Title }} Journal" href="{{ "rss.xml" | absURL }}"> + <link rel="stylesheet" href="{{ "style.css" | relURL }}"> + <link rel="icon" href="{{ "favicon.ico" | relURL }}" sizes="any"> +</head> +<body> + {{ partial "header.html" . }} + <main id="main-content"> + {{ block "main" . }}{{ end }} + </main> + {{ partial "footer.html" . }} +</body> +</html> diff --git a/layouts/baseof.html b/layouts/baseof.html new file mode 100644 index 0000000..edc5cbe --- /dev/null +++ b/layouts/baseof.html @@ -0,0 +1,23 @@ +<!doctype html> +{{- $pageLang := default "en" .Params.lang -}} +{{- $description := site.Params.description -}} +{{- with .Params.description }}{{ $description = . }}{{ end -}} +<html lang="{{ $pageLang }}"> +<head> + <meta charset="utf-8"> + <meta name="viewport" content="width=device-width, initial-scale=1"> + <title>{{ if .IsHome }}{{ site.Title }}{{ else }}{{ .Title }} | {{ site.Title }}{{ end }}</title> + <meta name="description" content="{{ $description }}"> + <link rel="canonical" href="{{ .Permalink }}"> + <link rel="alternate" type="application/rss+xml" title="{{ site.Title }} Journal" href="{{ "rss.xml" | absURL }}"> + <link rel="stylesheet" href="{{ "style.css" | relURL }}"> + <link rel="icon" href="{{ "favicon.ico" | relURL }}" sizes="any"> +</head> +<body> + {{ partial "header.html" . }} + <main id="main-content"> + {{ block "main" . }}{{ end }} + </main> + {{ partial "footer.html" . }} +</body> +</html> diff --git a/layouts/home.html b/layouts/home.html new file mode 100644 index 0000000..c93aafb --- /dev/null +++ b/layouts/home.html @@ -0,0 +1,8 @@ +{{ define "main" }} + <article class="home-page" lang="en"> + <h1>{{ site.Title }}</h1> + <p class="home-intro">I'm an undergraduate at the School of Information, Renmin University of China, and a free software advocate. My current interests are MLSys, compilers, and operating systems. You can reach me by <a href="mailto:{{ site.Params.email }}">email</a>.</p> + {{ partial "primary-nav.html" . }} + {{ partial "recent.html" . }} + </article> +{{ end }} diff --git a/layouts/home.rss.xml b/layouts/home.rss.xml new file mode 100644 index 0000000..8ec9c25 --- /dev/null +++ b/layouts/home.rss.xml @@ -0,0 +1,21 @@ +{{- $pages := where site.RegularPages "Section" "journal" -}} +{{- $pages = $pages.ByDate.Reverse -}} +{{ printf "<?xml version=\"1.0\" encoding=\"utf-8\" standalone=\"yes\"?>" | safeHTML }} +<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom"> + <channel> + <title>{{ site.Title }}</title> + <link>{{ .Permalink }}</link> + <description>{{ site.Params.description }}</description> + <language>en</language> + <atom:link href="{{ "rss.xml" | absURL }}" rel="self" type="application/rss+xml" /> + {{- range $pages }} + <item> + <title>{{ .Title }}</title> + <link>{{ .Permalink }}</link> + <guid isPermaLink="true">{{ .Permalink }}</guid> + <pubDate>{{ .Date.Format "Mon, 02 Jan 2006 15:04:05 -0700" }}</pubDate> + <description>{{ .Content | transform.XMLEscape | safeHTML }}</description> + </item> + {{- end }} + </channel> +</rss> diff --git a/layouts/journal/list.html b/layouts/journal/list.html new file mode 100644 index 0000000..dd486ac --- /dev/null +++ b/layouts/journal/list.html @@ -0,0 +1,19 @@ +{{ define "main" }} + <article lang="{{ default "en" .Params.lang }}"> + <header class="document-header"> + <h1>{{ .Title }}</h1> + {{ partial "document-view.html" . }} + </header> + {{ .Content }} + {{- $pages := where site.RegularPages "Section" "journal" -}} + {{- $pages = $pages.ByDate.Reverse -}} + <ol class="document-list journal-list"> + {{- range $pages }} + <li> + <time datetime="{{ .Date.Format "2006-01-02" }}">{{ .Date.Format "2006-01-02" }}</time> + <a href="{{ .RelPermalink }}" lang="{{ .Params.lang }}">{{ .LinkTitle }}</a> + </li> + {{- end }} + </ol> + </article> +{{ end }} diff --git a/layouts/journal/single.html b/layouts/journal/single.html new file mode 100644 index 0000000..d687be1 --- /dev/null +++ b/layouts/journal/single.html @@ -0,0 +1,37 @@ +{{ define "main" }} + <article lang="{{ .Params.lang }}"> + <header class="document-header"> + <p class="document-path">{{ .RelPermalink }}</p> + <h1>{{ .Title }}</h1> + <dl class="document-meta"> + <div><dt>published</dt><dd><time datetime="{{ .Date.Format "2006-01-02" }}">{{ .Date.Format "2006-01-02" }}</time></dd></div> + {{- with .Params.updated }} + <div><dt>updated</dt><dd><time datetime="{{ time.Format "2006-01-02" . }}">{{ time.Format "2006-01-02" . }}</time></dd></div> + {{- end }} + <div><dt>license</dt><dd>{{ .Params.license }}</dd></div> + </dl> + {{ partial "document-view.html" . }} + </header> + {{ .Content }} + {{- $pages := where site.RegularPages "Section" "journal" -}} + {{- $pages = $pages.ByDate -}} + {{- $currentIndex := -1 -}} + {{- range $index, $candidate := $pages -}} + {{- if eq $candidate.RelPermalink $.RelPermalink }}{{ $currentIndex = $index }}{{ end -}} + {{- end -}} + {{- if ge $currentIndex 0 }} + <nav class="document-navigation journal-navigation" aria-label="Journal chronology"> + <ul> + {{- if gt $currentIndex 0 }} + {{- $previous := index $pages (sub $currentIndex 1) }} + <li class="previous-link"><span class="navigation-label">previous</span><a rel="prev" href="{{ $previous.RelPermalink }}">← {{ $previous.LinkTitle }}</a></li> + {{- end }} + {{- if lt (add $currentIndex 1) (len $pages) }} + {{- $next := index $pages (add $currentIndex 1) }} + <li class="next-link"><span class="navigation-label">next</span><a rel="next" href="{{ $next.RelPermalink }}">{{ $next.LinkTitle }} →</a></li> + {{- end }} + </ul> + </nav> + {{- end }} + </article> +{{ end }} diff --git a/layouts/links/list.html b/layouts/links/list.html new file mode 100644 index 0000000..752538b --- /dev/null +++ b/layouts/links/list.html @@ -0,0 +1,9 @@ +{{ define "main" }} + <article lang="{{ default "en" .Params.lang }}"> + <header class="document-header"> + <h1>{{ .Title }}</h1> + {{ partial "document-view.html" . }} + </header> + {{ .Content }} + </article> +{{ end }} diff --git a/layouts/notes/list.html b/layouts/notes/list.html new file mode 100644 index 0000000..86deddb --- /dev/null +++ b/layouts/notes/list.html @@ -0,0 +1,41 @@ +{{ define "main" }} + <article lang="{{ default "en" .Params.lang }}"> + <header class="document-header"> + <h1>{{ .Title }}</h1> + {{ partial "document-view.html" . }} + </header> + {{ .Content }} + {{- if eq .File.Path "notes/_index.md" }} + {{- with .RegularPages.ByTitle }} + <section aria-labelledby="standalone-title"> + <h2 id="standalone-title">STANDALONE NOTES</h2> + <ul class="document-list"> + {{- range . }} + <li><time datetime="{{ time.Format "2006-01-02" .Params.updated }}">{{ time.Format "2006-01-02" .Params.updated }}</time> <a href="{{ .RelPermalink }}" lang="{{ .Params.lang }}">{{ .LinkTitle }}</a></li> + {{- end }} + </ul> + </section> + {{- end }} + {{- with .Sections.ByTitle }} + <section aria-labelledby="series-title"> + <h2 id="series-title">SERIES</h2> + <ul class="document-list"> + {{- range . }} + <li><a href="{{ .RelPermalink }}" lang="{{ .Params.lang }}">{{ .LinkTitle }}</a>{{ with .Params.description }} — {{ . }}{{ end }}</li> + {{- end }} + </ul> + </section> + {{- end }} + {{- else }} + <ol class="document-list series-chapter-list"> + {{- range $index, $page := .RegularPages.ByWeight }} + <li> + <span class="chapter-number">{{ printf "%02d" (add $index 1) }}</span> + <a href="{{ $page.RelPermalink }}" lang="{{ $page.Params.lang }}">{{ $page.LinkTitle }}</a> + <span class="list-updated">updated {{ time.Format "2006-01-02" $page.Params.updated }}</span> + </li> + {{- end }} + </ol> + {{- end }} + </article> +{{ end }} diff --git a/layouts/notes/single.html b/layouts/notes/single.html new file mode 100644 index 0000000..ec3545a --- /dev/null +++ b/layouts/notes/single.html @@ -0,0 +1,20 @@ +{{ define "main" }} + <article lang="{{ .Params.lang }}"> + <header class="document-header"> + <p class="document-path">{{ .RelPermalink }}</p> + <h1>{{ .Title }}</h1> + {{- with .Params.series }}{{ partial "series-nav.html" (dict "page" $ "mode" "position") }}{{ end }} + <dl class="document-meta"> + {{- with .Params.created }} + <div><dt>created</dt><dd><time datetime="{{ time.Format "2006-01-02" . }}">{{ time.Format "2006-01-02" . }}</time></dd></div> + {{- end }} + <div><dt>updated</dt><dd><time datetime="{{ time.Format "2006-01-02" .Params.updated }}">{{ time.Format "2006-01-02" .Params.updated }}</time></dd></div> + <div><dt>license</dt><dd>{{ .Params.license }}</dd></div> + </dl> + {{ partial "document-view.html" . }} + </header> + {{ partial "toc.html" . }} + {{ .Content }} + {{- with .Params.series }}{{ partial "series-nav.html" (dict "page" $ "mode" "navigation") }}{{ end }} + </article> +{{ end }} diff --git a/layouts/partials/document-view.html b/layouts/partials/document-view.html new file mode 100644 index 0000000..5bfc7b6 --- /dev/null +++ b/layouts/partials/document-view.html @@ -0,0 +1,19 @@ +{{- if .File -}} + {{- $rawURL := "" -}} + {{- if .IsPage -}} + {{- $htmlBase := strings.TrimSuffix ".html" .RelPermalink -}} + {{- $rawURL = printf "%s/index.md" $htmlBase -}} + {{- else if .IsSection -}} + {{- $rawURL = printf "%s_index.md" .RelPermalink -}} + {{- end -}} + {{- $gitBase := strings.TrimSuffix "/" site.Params.gitBase -}} + {{- $gitURL := printf "%s/content/%s" $gitBase .File.Path -}} + <nav class="document-view" aria-label="Document formats"> + <span>view:</span> + <a href="{{ .RelPermalink }}" aria-current="page">html</a> + <span aria-hidden="true">·</span> + <a href="{{ $rawURL }}">raw .md</a> + <span aria-hidden="true">·</span> + <a href="{{ $gitURL }}">git</a> + </nav> +{{- end -}} diff --git a/layouts/partials/footer.html b/layouts/partials/footer.html new file mode 100644 index 0000000..ac89098 --- /dev/null +++ b/layouts/partials/footer.html @@ -0,0 +1,11 @@ +<footer class="site-footer"> + <nav aria-label="Site information"> + <a href="{{ "/rss.xml" | relURL }}">rss</a> + <span aria-hidden="true">·</span> + <a href="{{ site.Params.sourceURL }}">source</a> + <span aria-hidden="true">·</span> + <a href="mailto:{{ site.Params.email }}">email</a> + </nav> + <p>Code: GPL-3.0-or-later<br>Content: {{ site.Params.contentLicense }}</p> + <p>No JavaScript <span aria-hidden="true">·</span> No Cookies <span aria-hidden="true">·</span> No Tracking<br>Best viewed with any browser.</p> +</footer> diff --git a/layouts/partials/header.html b/layouts/partials/header.html new file mode 100644 index 0000000..813713f --- /dev/null +++ b/layouts/partials/header.html @@ -0,0 +1,7 @@ +<header class="site-header"> + <a class="skip-link" href="#main-content">Skip to content</a> + <a class="site-identity" href="{{ "/" | relURL }}">{{ site.Params.identity }}</a> + {{- if not .IsHome }} + {{ partial "primary-nav.html" . }} + {{- end }} +</header> diff --git a/layouts/partials/primary-nav.html b/layouts/partials/primary-nav.html new file mode 100644 index 0000000..8be0124 --- /dev/null +++ b/layouts/partials/primary-nav.html @@ -0,0 +1,8 @@ +<nav class="site-nav" aria-label="Primary"> + <a href="{{ "/journal/" | relURL }}"{{ if eq .Section "journal" }} aria-current="page"{{ end }}>journal/</a> + <a href="{{ "/notes/" | relURL }}"{{ if eq .Section "notes" }} aria-current="page"{{ end }}>notes/</a> + <a href="{{ "/projects/" | relURL }}"{{ if eq .Section "projects" }} aria-current="page"{{ end }}>projects/</a> + <a href="{{ "/links/" | relURL }}"{{ if eq .Section "links" }} aria-current="page"{{ end }}>links/</a> + <a href="{{ "/about.txt" | relURL }}">about.txt</a> + <a href="{{ "/now.txt" | relURL }}">now.txt</a> +</nav> diff --git a/layouts/partials/recent.html b/layouts/partials/recent.html new file mode 100644 index 0000000..47c8332 --- /dev/null +++ b/layouts/partials/recent.html @@ -0,0 +1,23 @@ +{{- $items := slice -}} +{{- range where site.RegularPages "Section" "journal" -}} + {{- $items = $items | append (dict "page" . "kind" "journal" "sortDate" (.Date.Format "2006-01-02")) -}} +{{- end -}} +{{- range where site.RegularPages "Section" "notes" -}} + {{- $page := . -}} + {{- with $page.Params.recent -}} + {{- $items = $items | append (dict "page" $page "kind" "note" "sortDate" (time.Format "2006-01-02" .)) -}} + {{- end -}} +{{- end -}} +{{- $items = sort $items "sortDate" "desc" -}} +<section class="recent" aria-labelledby="recent-title"> + <h2 id="recent-title">RECENT</h2> + <ol class="document-list"> + {{- range $items }} + <li> + <time datetime="{{ .sortDate }}">{{ .sortDate }}</time> + <span class="document-kind">[{{ .kind }}]</span> + <a href="{{ .page.RelPermalink }}" lang="{{ .page.Params.lang }}">{{ .page.LinkTitle }}</a> + </li> + {{- end }} + </ol> +</section> diff --git a/layouts/partials/series-nav.html b/layouts/partials/series-nav.html new file mode 100644 index 0000000..c88055c --- /dev/null +++ b/layouts/partials/series-nav.html @@ -0,0 +1,35 @@ +{{- $page := .page -}} +{{- $mode := .mode -}} +{{- $pages := where $page.CurrentSection.RegularPages.ByWeight "Params.series" $page.Params.series -}} +{{- $currentIndex := -1 -}} +{{- range $index, $candidate := $pages -}} + {{- if eq $candidate.RelPermalink $page.RelPermalink -}} + {{- $currentIndex = $index -}} + {{- end -}} +{{- end -}} +{{- if ge $currentIndex 0 -}} + {{- $position := add $currentIndex 1 -}} + {{- if eq $mode "position" }} + <p class="series-position"><a href="{{ $page.CurrentSection.RelPermalink }}">{{ $page.CurrentSection.LinkTitle }}</a> <span aria-hidden="true">·</span> {{ printf "%02d/%d" $position (len $pages) }}</p> + {{- else if eq $mode "navigation" }} + <nav class="document-navigation series-navigation" aria-label="{{ $page.CurrentSection.LinkTitle }} chapters"> + <ul> + <li class="series-previous"{{ if eq $currentIndex 0 }} aria-hidden="true"{{ end }}> + {{- if gt $currentIndex 0 }} + {{- $previous := index $pages (sub $currentIndex 1) }} + <span class="navigation-label">previous</span> + <a rel="prev" href="{{ $previous.RelPermalink }}">← {{ printf "%02d. %s" (sub $position 1) $previous.LinkTitle }}</a> + {{- end }} + </li> + <li class="series-index-link"><a href="{{ $page.CurrentSection.RelPermalink }}">↑ {{ $page.CurrentSection.LinkTitle }}</a></li> + <li class="series-next"{{ if eq $position (len $pages) }} aria-hidden="true"{{ end }}> + {{- if lt $position (len $pages) }} + {{- $next := index $pages $position }} + <span class="navigation-label">next</span> + <a rel="next" href="{{ $next.RelPermalink }}">{{ printf "%02d. %s" (add $position 1) $next.LinkTitle }} →</a> + {{- end }} + </li> + </ul> + </nav> + {{- end -}} +{{- end -}} diff --git a/layouts/partials/toc.html b/layouts/partials/toc.html new file mode 100644 index 0000000..4db9a6f --- /dev/null +++ b/layouts/partials/toc.html @@ -0,0 +1,7 @@ +{{- $headings := findRE `<h[23][ >]` .Content -}} +{{- if gt (len $headings) 4 }} + <section class="table-of-contents" aria-labelledby="contents-title"> + <h2 id="contents-title">CONTENTS</h2> + {{ .TableOfContents }} + </section> +{{- end -}} diff --git a/layouts/projects/list.html b/layouts/projects/list.html new file mode 100644 index 0000000..752538b --- /dev/null +++ b/layouts/projects/list.html @@ -0,0 +1,9 @@ +{{ define "main" }} + <article lang="{{ default "en" .Params.lang }}"> + <header class="document-header"> + <h1>{{ .Title }}</h1> + {{ partial "document-view.html" . }} + </header> + {{ .Content }} + </article> +{{ end }} |
