Hugo内容

This commit is contained in:
2026-02-27 11:41:19 +08:00
parent 544c97c013
commit 4f7f72b65f
37 changed files with 795 additions and 0 deletions

View File

@@ -0,0 +1 @@
<a href="{{ "" | relURL }}">{{ $.Site.Params.theme_config.back_home_text }}</a>

View File

@@ -0,0 +1,11 @@
{{ if site.Params.theme_config.isShowFooter }}
{{ $footerContent := readFile "layouts/footer.md" }}
{{ if and $footerContent (ne $footerContent "") }}
{{ $footerContent | markdownify }}
{{ else }}
{{ warnf "layouts/footer.md file is not found or empty. Falling back to default footer." }}
<footer class="site-footer">
<p>&copy; {{ now.Format "2006" }} {{ site.Title }}</p>
</footer>
{{ end }}
{{ end }}

View File

@@ -0,0 +1,22 @@
<head>
<meta charset="utf-8" />
<meta http-equiv="X-UA-Compatible" content="IE=edge" />
<meta name="viewport" content="width=device-width, initial-scale=1" />
{{ if .IsPage }} <meta name="description" content="{{ .Summary }}"> {{ end }}
<title>
{{ if not .IsHome }}
{{ .Title }}
{{ else }}
{{ $.Site.Title }}
{{ end }}
</title>
<link rel="shortcut icon" type="image/x-icon" href="{{ $.Site.Params.favicon | relURL }}" />
{{ $options := (dict "outputStyle" "compressed" "enableSourceMap" (not hugo.IsProduction)) }}
{{ $sass := resources.Get "css/main.scss" }}
{{ $style := $sass | css.Sass $options | resources.Fingerprint "sha512" }}
<link rel="stylesheet" href="{{ $style.Permalink | relURL }}" integrity="{{ $style.Data.Integrity }}" />
{{ if .Params.mathjax }} {{ partial "mathjax.html" . }} {{ end }}
</head>

View File

@@ -0,0 +1,21 @@
<script>
MathJax = {
tex: {
inlineMath: [['$', '$'], ['\\(', '\\)']],
displayMath: [['$$','$$'], ['\\[', '\\]']],
processEscapes: true,
processEnvironments: true
},
options: {
skipHtmlTags: ['script', 'noscript', 'style', 'textarea', 'pre']
}
};
window.addEventListener('load', (event) => {
document.querySelectorAll("mjx-container").forEach(function(x){
x.parentElement.classList += 'has-jax'})
});
</script>
<script src="https://cdnjs.cloudflare.com/polyfill/v3/polyfill.min.js?features=es6"></script>
<script id="MathJax-script" async src="https://cdn.jsdelivr.net/npm/mathjax@3/es5/tex-mml-chtml.js"></script>

View File

@@ -0,0 +1,19 @@
<ul>
{{- range $item := .collection -}}
<li>
{{- with $item.url -}}
<a href="{{ $item.url | relURL }}">{{ safeHTML $item.title }}</a>
{{- else -}}
{{ safeHTML $item.title }}
{{- end -}}
</li>
{{- if $item.entries }}
{{ partial "menu_item.html" (dict "context" . "collection" $item.entries) }}
{{- end -}}
{{- if $item.post_list -}}
{{ partial "post_list.html" (dict "context" . "section" $item.post_list.section "limit" $item.post_list.limit "show_more" $item.post_list.show_more "show_more_text" $item.post_list.show_more_text "show_more_url" $item.post_list.show_more_url) -}}
{{- end -}}
{{- end -}}
</ul>

View File

@@ -0,0 +1,39 @@
{{- $posts := "" -}}
{{- if .section -}}
{{- $posts = (where site.RegularPages "Section" .section) -}}
{{- else -}}
{{- if (eq .context.Kind "taxonomy") -}}
{{- $posts = .context.Pages -}}
{{- else -}}
{{- if (eq .context.Kind "term") -}}
{{- $posts = .context.Data.Pages -}}
{{- else -}}
{{- $posts = site.RegularPages }}
{{- end -}}
{{- end -}}
{{- end -}}
{{- $limit_exceeded:= "" -}}
{{- if (and .limit (gt (len $posts) .limit)) -}}
{{- $limit_exceeded = true -}}
{{- else -}}
{{- $limit_exceeded = false -}}
{{ end }}
{{- if (gt (len $posts) 0) }}
{{- if .limit }}
{{ $posts = (first .limit $posts ) }}
{{ end }}
<ul>
{{- range $post := $posts -}}
<li>
<span>{{- ($post.Date | time.Format site.Params.theme_config.date_format) }}</span>
<a href="{{ $post.Permalink | relURL }}">{{ $post.Title }}</a>
</li>
{{ end }}
{{- if and .show_more $limit_exceeded }}
<li><a href="{{ .show_more_url | relURL }}">{{ .show_more_text | default "Show more..." }}</a></li>
{{ end }}
</ul>
{{ end }}