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/_default/_markup/render-image.html | 5 ++++ layouts/_default/baseof.html | 23 +++++++++++++++++ layouts/baseof.html | 23 +++++++++++++++++ layouts/home.html | 8 ++++++ layouts/home.rss.xml | 21 +++++++++++++++ layouts/journal/list.html | 19 ++++++++++++++ layouts/journal/single.html | 37 +++++++++++++++++++++++++++ layouts/links/list.html | 9 +++++++ layouts/notes/list.html | 41 ++++++++++++++++++++++++++++++ layouts/notes/single.html | 20 +++++++++++++++ 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 +++++ layouts/projects/list.html | 9 +++++++ 18 files changed, 325 insertions(+) create mode 100644 layouts/_default/_markup/render-image.html create mode 100644 layouts/_default/baseof.html create mode 100644 layouts/baseof.html create mode 100644 layouts/home.html create mode 100644 layouts/home.rss.xml create mode 100644 layouts/journal/list.html create mode 100644 layouts/journal/single.html create mode 100644 layouts/links/list.html create mode 100644 layouts/notes/list.html create mode 100644 layouts/notes/single.html 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 create mode 100644 layouts/projects/list.html (limited to 'layouts') 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 -}} +{{ .PlainText }} 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 @@ + +{{- $pageLang := default "en" .Params.lang -}} +{{- $description := site.Params.description -}} +{{- with .Params.description }}{{ $description = . }}{{ end -}} + + + + + {{ if .IsHome }}{{ site.Title }}{{ else }}{{ .Title }} | {{ site.Title }}{{ end }} + + + + + + + + {{ partial "header.html" . }} +
+ {{ block "main" . }}{{ end }} +
+ {{ partial "footer.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 @@ + +{{- $pageLang := default "en" .Params.lang -}} +{{- $description := site.Params.description -}} +{{- with .Params.description }}{{ $description = . }}{{ end -}} + + + + + {{ if .IsHome }}{{ site.Title }}{{ else }}{{ .Title }} | {{ site.Title }}{{ end }} + + + + + + + + {{ partial "header.html" . }} +
+ {{ block "main" . }}{{ end }} +
+ {{ partial "footer.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" }} +
+

{{ site.Title }}

+

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 email.

+ {{ partial "primary-nav.html" . }} + {{ partial "recent.html" . }} +
+{{ 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 "" | safeHTML }} + + + {{ site.Title }} + {{ .Permalink }} + {{ site.Params.description }} + en + + {{- range $pages }} + + {{ .Title }} + {{ .Permalink }} + {{ .Permalink }} + {{ .Date.Format "Mon, 02 Jan 2006 15:04:05 -0700" }} + {{ .Content | transform.XMLEscape | safeHTML }} + + {{- end }} + + 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" }} +
+
+

{{ .Title }}

+ {{ partial "document-view.html" . }} +
+ {{ .Content }} + {{- $pages := where site.RegularPages "Section" "journal" -}} + {{- $pages = $pages.ByDate.Reverse -}} +
    + {{- range $pages }} +
  1. + + {{ .LinkTitle }} +
  2. + {{- end }} +
+
+{{ 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" }} +
+
+

{{ .RelPermalink }}

+

{{ .Title }}

+
+
published
+ {{- with .Params.updated }} +
updated
+ {{- end }} +
license
{{ .Params.license }}
+
+ {{ partial "document-view.html" . }} +
+ {{ .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 }} + + {{- end }} +
+{{ 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" }} +
+
+

{{ .Title }}

+ {{ partial "document-view.html" . }} +
+ {{ .Content }} +
+{{ 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" }} +
+
+

{{ .Title }}

+ {{ partial "document-view.html" . }} +
+ {{ .Content }} + {{- if eq .File.Path "notes/_index.md" }} + {{- with .RegularPages.ByTitle }} +
+

STANDALONE NOTES

+
    + {{- range . }} +
  • {{ .LinkTitle }}
  • + {{- end }} +
+
+ {{- end }} + {{- with .Sections.ByTitle }} +
+

SERIES

+
    + {{- range . }} +
  • {{ .LinkTitle }}{{ with .Params.description }} — {{ . }}{{ end }}
  • + {{- end }} +
+
+ {{- end }} + {{- else }} +
    + {{- range $index, $page := .RegularPages.ByWeight }} +
  1. + {{ printf "%02d" (add $index 1) }} + {{ $page.LinkTitle }} + updated {{ time.Format "2006-01-02" $page.Params.updated }} +
  2. + {{- end }} +
+ {{- end }} +
+{{ 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" }} +
+
+

{{ .RelPermalink }}

+

{{ .Title }}

+ {{- with .Params.series }}{{ partial "series-nav.html" (dict "page" $ "mode" "position") }}{{ end }} +
+ {{- with .Params.created }} +
created
+ {{- end }} +
updated
+
license
{{ .Params.license }}
+
+ {{ partial "document-view.html" . }} +
+ {{ partial "toc.html" . }} + {{ .Content }} + {{- with .Params.series }}{{ partial "series-nav.html" (dict "page" $ "mode" "navigation") }}{{ end }} +
+{{ 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 -}} + +{{- 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 -}} 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" }} +
+
+

{{ .Title }}

+ {{ partial "document-view.html" . }} +
+ {{ .Content }} +
+{{ end }} -- cgit v1.2.3