除归档 其他页面基本完工

This commit is contained in:
小赵同学 committed 2024-07-11 16:08:51 +08:00
1 parent 764a4a2676
commit a216eeb04b
143 files changed
+6523 -945

No files matched your search

+7
View File
@@ -0,0 +1,7 @@
{{ define "main" }}
<h1
class="absolute inset-x-8 bottom-20 top-0 flex items-center justify-center text-9xl"
>
404
</h1>
{{ end }}
+53
View File
@@ -0,0 +1,53 @@
<!doctype html>
{{ $.Scratch.Delete "bg_color" }}<!---->
{{ $.Scratch.Delete "social_list" }}<!---->
{{ $.Scratch.Delete "avatar_url" }}<!---->
<!-- bg_color -->
{{ $color_map := dict "linen" "#faf8f1" "wheat" "#f8f5d7" "gray" "#fbfbfb"
"light" "#fff" }}<!---->
{{ $.Scratch.Set "bg_color" (index $color_map (site.Params.color | default
(print "linen"))) }}<!---->
{{ $bg_color := $.Scratch.Get "bg_color" }}<!---->
<!-- social_list -->
{{ $social_params := slice "twitter" "github" "instagram" "linkedin" "mastodon"
"threads" "rss" }}<!---->
{{ range $social_params }}<!---->
{{ if isset site.Params . }}<!---->
{{ $.Scratch.Add "social_list" (slice .) }}<!---->
{{ end }}<!---->
{{ end }}<!---->
<!-- avatar_url -->
{{ if site.Params.avatar }}<!---->
{{ if in site.Params.avatar "http" }}<!---->
{{ $.Scratch.Set "avatar_url" site.Params.avatar }}<!---->
{{ else }}<!---->
{{ $official_cdn := "https://www.gravatar.com/avatar/" }}<!---->
{{ $cdn := (site.Params.gravatarCdn | default $official_cdn) }}<!---->
{{ $md5 := (md5 site.Params.avatar) }}<!---->
{{ $avatar_url := print $cdn $md5 "?s=160&d=identicon" }}<!---->
{{ $.Scratch.Set "avatar_url" $avatar_url }}<!---->
{{ end }}<!---->
{{ end }}<!---->
<html
class="not-ready lg:text-base"
style="--bg: {{ $bg_color }}"
lang="{{ or site.LanguageCode site.Language.Lang }}"
>
{{ partial "head.html" . }}
<body class="text-black duration-200 ease-out dark:text-white">
{{ partial "header.html" . }}
<main
class="prose prose-neutral relative mx-auto min-h-[calc(100%-9rem)] max-w-3xl px-8 pb-16 pt-12 dark:prose-invert"
>
{{ block "main" . }}{{ end }}
</main>
{{ partial "footer.html" . }}
</body>
</html>
+78
View File
@@ -0,0 +1,78 @@
{{ define "main" }}
<!-- Tag Title -->
{{ if and .Title (eq .Type "tags") }}
<h1 class="mb-16">#{{ .Title }}</h1>
{{ end }}
<!-- $pages -->
{{ $pages := union .RegularPages .Sections }}<!---->
{{ if .IsHome }}<!---->
{{ $pages = where site.RegularPages "Type" "in" site.Params.mainSections }}<!---->
{{ end }}
<!-- Articles -->
{{ $paginator := .Paginate $pages }} {{ range $index, $page := $paginator.Pages
}}<!---->
<!-- avatar -->
{{ if and $.IsHome (eq $paginator.PageNumber 1) (eq $index 0) }}<!---->
{{ $avatar_url := $.Scratch.Get "avatar_url" }}<!---->
{{ if or $avatar_url site.Params.name }}
<div class="-mt-2 mb-16 flex items-center">
{{ if $avatar_url }}
<div
class="mr-5 shrink-0 rounded-full border-[0.5px] border-black/10 bg-white/50 p-3 shadow dark:bg-white/[15%]"
>
<img
class="my-0 aspect-square w-16 rounded-full !bg-black/5 hover:animate-spin dark:!bg-black/80"
src="{{ $avatar_url }}"
alt="{{ site.Params.name | default site.Title }}"
/>
</div>
{{ end }}<!---->
{{ if site.Params.name }}
<div>
<h1 class="mb-2 mt-3 text-[1.6rem] font-bold">{{ site.Params.name }}</h1>
<div class="break-words">
{{ site.Params.bio | default (print `A personal blog by `
site.Params.name) }}
</div>
</div>
{{ end }}
</div>
{{ end }}<!---->
{{ end }}
<section class="relative my-10 first-of-type:mt-0 last-of-type:mb-0">
{{ if gt .Weight 0 }}
<span
class="mb-2 ml-px inline-block text-[0.8rem] font-medium uppercase tracking-wider text-[#ff3b2d] opacity-70"
>Featured</span
>
{{ end }}
<h2 class="!my-0 pb-1 font-bold !leading-none">{{ .Title }}</h2>
<time class="text-sm antialiased opacity-60"
>{{ .Date | time.Format ":date_medium" }}</time
>
<a class="absolute inset-0 text-[0]" href="{{ .Permalink }}">{{ .Title }}</a>
</section>
{{ end }}
<!-- Main Nav -->
{{ if gt $paginator.TotalPages 1 }}
<nav class="mt-16 flex">
{{ if $paginator.HasPrev }}
<a class="btn" href="{{ $paginator.Prev.URL }}">← {{ i18n "prev_page" }}</a>
{{ end }}<!---->
{{ if $paginator.HasNext }}
<a class="btn ml-auto" href="{{ $paginator.Next.URL }}"
>{{ i18n "next_page" }} →</a
>
{{ end }}
</nav>
{{ end }}<!---->
{{ end }}
+130
View File
@@ -0,0 +1,130 @@
{{ define "main" }}
<article>
<header class="mb-16">
<h1 class="!my-0 pb-2.5">{{ .Title }}</h1>
{{ if ne .Type "page" }}
<div class="text-sm antialiased opacity-60">
{{ if .Date }}
<time>{{ .Date | time.Format ":date_medium" }}</time>
{{ end }}<!---->
{{ $single_author := or .Params.Author site.Author.name }}
<!---->
{{ if $single_author }}
<span class="mx-1">&middot;</span>
<span>{{ $single_author }}</span>
{{ end }}
</div>
{{ end }}
</header>
<section>{{ .Content }}</section>
<!-- Post Tags -->
{{ if .Params.tags }}
<footer class="mt-12 flex flex-wrap">
{{ range .Params.tags }} {{ $href := print (absURL "tags/") (urlize .) }}
<a
class="mb-1.5 mr-1.5 rounded-lg bg-black/[3%] px-5 py-1.5 no-underline dark:bg-white/[8%]"
href="{{ $href }}"
>{{ . }}</a
>
{{ end }}
</footer>
{{ end }}
<!-- Post Nav -->
{{ if not site.Params.disablePostNavigation }}<!---->
{{ $pages := where site.RegularPages "Type" "in" site.Params.mainSections }}<!---->
{{ if and (gt (len $pages) 1) (in $pages . ) }}
<nav class="mt-24 flex rounded-lg bg-black/[3%] text-lg dark:bg-white/[8%]">
{{ with $pages.Next . }}
<a
class="flex w-1/2 items-center rounded-l-md p-6 pr-3 font-semibold no-underline hover:bg-black/[2%] dark:hover:bg-white/[3%]"
href="{{ .Permalink }}"
><span class="mr-1.5">←</span><span>{{ .Name }}</span></a
>
{{ end }}<!---->
{{ with $pages.Prev . }}
<a
class="ml-auto flex w-1/2 items-center justify-end rounded-r-md p-6 pl-3 font-semibold no-underline hover:bg-black/[2%] dark:hover:bg-white/[3%]"
href="{{ .Permalink }}"
><span>{{ .Name }}</span><span class="ml-1.5">→</span></a
>
{{ end }}
</nav>
{{ end }}<!---->
{{ end }}
<!-- Disqus -->
{{ if and site.DisqusShortname (not (eq .Params.comments false)) }}
<div class="mt-24" id="disqus_thread"></div>
<script>
const disqusShortname = '{{ site.DisqusShortname }}';
const script = document.createElement('script');
script.src = 'https://' + disqusShortname + '.disqus.com/embed.js';
script.setAttribute('data-timestamp', +new Date());
document.head.appendChild(script);
</script>
{{ end }}
<!-- GraphComment -->
{{ if and site.Params.graphCommentId (not (eq .Params.comments false)) }}
<div class="mt-24" id="graphcomment"></div>
<script type="text/javascript">
var __semio__params = {
graphcommentId: '{{ site.Params.graphCommentId }}',
behaviour: {
// uid: "...",
},
// configure your variables here
};
function __semio__onload() {
__semio__gc_graphlogin(__semio__params);
}
(function () {
var gc = document.createElement('script');
gc.type = 'text/javascript';
gc.async = true;
gc.onload = __semio__onload;
gc.defer = true;
gc.src =
'https://integration.graphcomment.com/gc_graphlogin.js?' + Date.now();
(
document.getElementsByTagName('head')[0] ||
document.getElementsByTagName('body')[0]
).appendChild(gc);
})();
</script>
{{ end }}
<!-- mermaid -->
{{- partial "mermaid.html" . -}}
<!-- giscus comment -->
{{ if and site.Params.giscus.repo (not (eq .Params.comments false)) }}
<div class="giscus mt-24"></div>
<script
src="https://giscus.app/client.js"
data-repo="{{ site.Params.giscus.repo }}"
data-repo-id="{{ site.Params.giscus.repoId }}"
data-category="{{ site.Params.giscus.category }}"
data-category-id="{{ site.Params.giscus.categoryId }}"
data-mapping="{{ site.Params.giscus.mapping | default (print `pathname`) }}"
data-strict="{{ site.Params.giscus.strict | default (print `1`) }}"
data-reactions-enabled="{{ site.Params.giscus.reactionsEnabled | default (print `0`) }}"
data-emit-metadata="{{ site.Params.giscus.emitMetadata | default (print `0`) }}"
data-input-position="{{ site.Params.giscus.inputPosition | default (print `top`) }}"
data-theme="{{ site.Params.giscus.theme | default (print `light`) }}"
data-lang="{{ site.Params.giscus.lang | default (print `en`) }}"
data-loading="{{ site.Params.giscus.loading | default (print `lazy`) }}"
crossorigin="anonymous"
async
></script>
{{ end }}
</article>
{{ end }}
+18
View File
@@ -0,0 +1,18 @@
<footer
class="opaco mx-auto flex h-[4.5rem] max-w-3xl items-center px-8 text-[0.9em] opacity-60"
>
<div class="mr-auto">
&copy; {{ now.Year }}
<a class="link" href="{{ `` | absURL }}">{{ site.Title }}</a>
</div>
<a class="link mx-6" href="https://gohugo.io/" rel="noopener" target="_blank"
>Powered by Hugo️️</a
>️
<a
class="link"
href="https://github.com/nanxiaobei/hugo-paper"
rel="noopener"
target="_blank"
>✎ Paper</a
>
</footer>
+106
View File
@@ -0,0 +1,106 @@
<head>
<meta charset="utf-8" />
<meta http-equiv="X-UA-Compatible" content="IE=edge" />
<meta
name="viewport"
content="width=device-width, initial-scale=1, shrink-to-fit=no"
/>
<!-- Title -->
<title>{{ if not .IsHome }}{{ .Title }} - {{ end }}{{ site.Title }}</title>
<!-- Meta -->
<meta name="theme-color" />
<!-- Author -->
{{ $site_author := or site.Author.name site.Params.name site.Title }}
<!---->
{{ if eq .Kind "page" }}
<meta name="description" content="{{ .Summary }}" />
<meta name="author" content="{{ or .Params.author $site_author }}" />
{{ else }}
<!---->
<meta
name="description"
content="{{ site.Params.description | default (print `A personal blog`) }}"
/>
<meta name="author" content="{{ $site_author }}" />
{{ end }}
<!-- CSS & JS -->
{{ $main := resources.Get "main.css" }}
<!---->
{{ $custom := resources.Get "custom.css" }}
<!---->
{{ $css := slice $main $custom | resources.Concat "main.css" | minify }}
<link rel="preload stylesheet" as="style" href="{{ $css.Permalink }}" />
<!-- Dark Icon -->
{{ $dark_icon := "theme.png" }}
<!---->
{{ if site.Params.monoDarkIcon }}{{ $dark_icon = "theme.svg" }}{{ end }}
<!---->
<link rel="preload" as="image" href="{{ $dark_icon | absURL }}" />
<!-- Avatar -->
{{ $avatar_url := $.Scratch.Get "avatar_url" }}
<!---->
{{ if $avatar_url }}
<link rel="preload" as="image" href="{{ $avatar_url }}" />
{{ end }}
<!---->
<!-- Social List -->
{{ range $.Scratch.Get "social_list" }}
<link rel="preload" as="image" href="{{ printf `%s.svg` . | absURL }}" />
{{ end }}
<!---->
<!-- Highlight JS -->
{{ if and .IsPage (not site.Params.disableHLJS) }}
<script
defer
src="{{ `highlight.min.js` | absURL }}"
onload="hljs.initHighlightingOnLoad();"
></script>
{{ end }}
<!-- Math -->
{{ if or .Params.math site.Params.math }}
<!---->
{{ partial "math.html" . }}
<!---->
{{ end }}
<!---->
<!-- Favicon -->
<link rel="icon" href="{{ site.Params.favicon | default `favicon.ico` | absURL }}" />
<link rel="apple-touch-icon" href="{{ site.Params.appleTouchIcon | default `apple-touch-icon.png` | absURL }}" />
<!-- Generator -->
{{ hugo.Generator }}
<!-- Production -->
{{ if or hugo.IsProduction (eq site.Params.env "production") }}
<!---->
{{ template "_internal/google_analytics.html" . }}
<!---->
{{ template "_internal/schema.html" . }}
<!---->
{{ template "_internal/opengraph.html" . }}
<!---->
{{ template "_internal/twitter_cards.html" . }}
<!-- RSS -->
{{ range .AlternativeOutputFormats }}
<link
rel="{{ .Rel }}"
type="{{ .MediaType.Type }}"
href="{{ .Permalink }}"
title="{{ site.Title }}"
/>
{{ end }}
<!-- Canonical -->
<link rel="canonical" href="{{ .Permalink }}" />
{{ end }}
<!---->
</head>
+100
View File
@@ -0,0 +1,100 @@
<header class="mx-auto flex h-[4.5rem] max-w-3xl px-8 lg:justify-center">
<div class="relative z-50 mr-auto flex items-center">
<a
class="-translate-x-[1px] -translate-y-[1px] text-2xl font-semibold"
href="{{ `` | absURL }}"
>{{ site.Title }}</a
>
<div
class="btn-dark text-[0] ml-4 h-6 w-6 shrink-0 cursor-pointer {{ if site.Params.monoDarkIcon }}[background:url(./theme.svg)_left_center/cover_no-repeat] dark:invert{{ else }}[background:url(./theme.png)_left_center/_auto_theme('spacing.6')_no-repeat] [transition:_background-position_0.4s_steps(5)]{{ end }} dark:[background-position:right]"
role="button"
aria-label="Dark"
></div>
</div>
<div
class="btn-menu relative z-50 -mr-8 flex h-[4.5rem] w-[5rem] shrink-0 cursor-pointer flex-col items-center justify-center gap-2.5 lg:hidden"
role="button"
aria-label="Menu"
></div>
{{ $bg_color := $.Scratch.Get "bg_color" }}<!---->
<script>
// base
const htmlClass = document.documentElement.classList;
setTimeout(() => {
htmlClass.remove('not-ready');
}, 10);
// mobile menu
const btnMenu = document.querySelector('.btn-menu');
btnMenu.addEventListener('click', () => {
htmlClass.toggle('open');
});
// dark theme
const metaTheme = document.querySelector('meta[name="theme-color"]');
const lightBg = '{{ $bg_color }}'.replace(/"/g, '');
const setDark = (isDark) => {
metaTheme.setAttribute('content', isDark ? '#000' : lightBg);
htmlClass[isDark ? 'add' : 'remove']('dark');
localStorage.setItem('dark', isDark);
};
// init
const darkScheme = window.matchMedia('(prefers-color-scheme: dark)');
if (htmlClass.contains('dark')) {
setDark(true);
} else {
const darkVal = localStorage.getItem('dark');
setDark(darkVal ? darkVal === 'true' : darkScheme.matches);
}
// listen system
darkScheme.addEventListener('change', (event) => {
setDark(event.matches);
});
// manual switch
const btnDark = document.querySelector('.btn-dark');
btnDark.addEventListener('click', () => {
setDark(localStorage.getItem('dark') !== 'true');
});
</script>
<div
class="nav-wrapper fixed inset-x-0 top-full z-40 flex h-full select-none flex-col justify-center pb-16 duration-200 dark:bg-black lg:static lg:h-auto lg:flex-row lg:!bg-transparent lg:pb-0 lg:transition-none"
>
{{ $url := .RelPermalink }}<!---->
{{ with site.Menus.main }}
<nav class="lg:ml-12 lg:flex lg:flex-row lg:items-center lg:space-x-6">
{{ range . }}
<a
class="block text-center text-2xl leading-[5rem] lg:text-base lg:font-normal"
href="{{ .URL }}"
>{{ .Name }}</a
>
{{ end }}
</nav>
{{ end }}<!---->
{{ with $.Scratch.Get "social_list" }}
<nav
class="mt-12 flex justify-center space-x-10 dark:invert lg:ml-12 lg:mt-0 lg:items-center lg:space-x-6"
>
{{ range . }}<!---->
<a
class="h-8 w-8 text-[0] [background:var(--url)_center_center/cover_no-repeat] lg:h-6 lg:w-6"
style="--url: url(./{{ . }}.svg)"
href="{{ if eq . `rss` }}{{ `index.xml` | absURL }}{{ else if eq . `mastodon` }}{{ index site.Params . }}{{ else }}https://{{ . }}{{ if eq . `threads` }}.net{{ else }}.com{{ end }}/{{ if eq . `linkedin` }}in/{{ end }}{{ index site.Params . }}{{ end }}"
target="_blank"
rel="{{ if eq . `rss` }}alternate{{ else }}me{{ end }}"
>
{{ . }}
</a>
{{ end }}<!---->
</nav>
{{ end }}<!---->
</div>
</header>
+39
View File
@@ -0,0 +1,39 @@
{{ if site.Params.localKatex }}
<link rel="stylesheet" href="{{ "katex.min.css" | relURL }}"/>
<script defer src="{{ "katex.min.js" | relURL }}"></script>
<script defer src="{{ "auto-render.min.js" | relURL }}"></script>
{{ else }}
<link
rel="stylesheet"
href="https://cdn.jsdelivr.net/npm/katex@0.16.7/dist/katex.min.css"
integrity="sha384-3UiQGuEI4TTMaFmGIZumfRPtfKQ3trwQE2JgosJxCnGmQpL/lJdjpcHkaaFwHlcI"
crossorigin="anonymous"
/>
<script
defer
src="https://cdn.jsdelivr.net/npm/katex@0.16.7/dist/katex.min.js"
integrity="sha384-G0zcxDFp5LWZtDuRMnBkk3EphCK1lhEf4UEyEM693ka574TZGwo4IWwS6QLzM/2t"
crossorigin="anonymous"
></script>
<script
defer
src="https://cdn.jsdelivr.net/npm/katex@0.16.7/dist/contrib/auto-render.min.js"
integrity="sha384-+VBxd3r6XgURycqtZ117nYw44OOcIax56Z4dCRWbxyPt0Koah1uHoK0o4+/RRE05"
crossorigin="anonymous"
></script>
{{ end }}
<script>
document.addEventListener('DOMContentLoaded', () =>
renderMathInElement(document.body, {
// customised options
// • auto-render specific keys, e.g.:
delimiters: [
{ left: '$$', right: '$$', display: true },
{ left: '$', right: '$', display: false },
],
// • rendering keys, e.g.:
throwOnError: false,
}),
);
</script>
@@ -0,0 +1,20 @@
<!-- mermaid.html -->
{{ if .Params.mermaid }}
<script type="module">
import mermaid from 'https://cdn.jsdelivr.net/npm/mermaid/dist/mermaid.esm.min.mjs';
mermaid.initialize({ startOnLoad: true });
</script>
<script>
Array.from(document.getElementsByClassName('language-mermaid')).forEach(
(el) => {
el.parentElement.outerHTML = `<div class="mermaid">${el.innerHTML}</div>`;
},
);
</script>
<style>
.mermaid svg {
display: block;
margin: auto;
}
</style>
{{ end }}
@@ -0,0 +1,10 @@
<!---->{{ if not (.Get "summary") }}
<!---->{{ errorf "missing param 'summary': %s" .Position }}
<!---->{{ else if not (.Get "content") }}{{ warnf "missing param 'content': %s"
.Position }}
<!---->{{ end }}
<details {{ if (eq (.Get `openByDefault`) true) }}open="true" {{ end }}>
<summary markdown="span">{{ .Get "summary" | markdownify }}</summary>
{{ .Get "content" | markdownify }}
</details>