From bce6be90883b107285faa56acf0081b54daa3aa9 Mon Sep 17 00:00:00 2001 From: Richard-Qin-X Date: Sat, 8 Aug 2026 21:30:23 +0800 Subject: Initialize personal website --- layouts/partials/document-view.html | 19 +++++++++++++++++++ layouts/partials/footer.html | 11 +++++++++++ layouts/partials/header.html | 7 +++++++ layouts/partials/primary-nav.html | 8 ++++++++ layouts/partials/recent.html | 23 +++++++++++++++++++++++ layouts/partials/series-nav.html | 35 +++++++++++++++++++++++++++++++++++ layouts/partials/toc.html | 7 +++++++ 7 files changed, 110 insertions(+) create mode 100644 layouts/partials/document-view.html create mode 100644 layouts/partials/footer.html create mode 100644 layouts/partials/header.html create mode 100644 layouts/partials/primary-nav.html create mode 100644 layouts/partials/recent.html create mode 100644 layouts/partials/series-nav.html create mode 100644 layouts/partials/toc.html (limited to 'layouts/partials') 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 -}} + +{{- 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 @@ + 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 @@ + 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 @@ + 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" -}} +
+

RECENT

+
    + {{- range $items }} +
  1. + + [{{ .kind }}] + {{ .page.LinkTitle }} +
  2. + {{- end }} +
+
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" }} +

{{ $page.CurrentSection.LinkTitle }} {{ printf "%02d/%d" $position (len $pages) }}

+ {{- else if eq $mode "navigation" }} + + {{- 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 `]` .Content -}} +{{- if gt (len $headings) 4 }} +
+

CONTENTS

+ {{ .TableOfContents }} +
+{{- end -}} -- cgit v1.2.3