feat: use latex hugo template

This commit is contained in:
Youwen Wu 2025-06-21 02:30:42 -07:00
parent 1d12f5614d
commit 9004c27ceb
Signed by: youwen
GPG key ID: 865658ED1FE61EC3
56 changed files with 1666 additions and 2 deletions

View file

@ -0,0 +1,17 @@
<!DOCTYPE html>
<html lang="{{ .Site.LanguageCode }}">
{{- partial "head.html" . -}}
{{- if site.Params.darkmode -}}
<body class="latex-dark">
{{- else if site.Params.lightmode -}}
<body>
{{- else -}}
<body class="latex-dark-auto">
{{- end -}}
{{- partial "header.html" . -}}
<div id="content">
{{- block "main" . }}{{- end }}
</div>
{{- partial "footer.html" . -}}
</body>
</html>

View file

@ -0,0 +1,29 @@
{{ define "main" }}
<div class="container" role="main">
<div class="posts-list">
{{ if .IsHome }}
{{ $pag := .Paginate (where site.RegularPages "Type" "in" site.Params.mainSections) }}
{{ else }}
{{ $pag := .Paginator.Pages }}
{{ end }}
{{ range .Paginator.Pages }}
{{ partial "preview.html" . }}
{{ end }}
</div>
{{ if or (.Paginator.HasPrev) (.Paginator.HasNext) }}
<ul class="pager">
{{ if .Paginator.HasPrev }}
<li class="previous">
<a href="{{ .Permalink }}page/{{ .Paginator.Prev.PageNumber }}/">&larr; Newer</a>
</li>
{{ end }}
{{ if .Paginator.HasNext }}
<li class="next">
<a href="{{ .Permalink }}page/{{ .Paginator.Next.PageNumber }}/">Older &rarr;</a>
</li>
{{ end }}
</ul>
{{ end }}
</div>
{{ end }}

View file

@ -0,0 +1,25 @@
{{ define "main" }}
<div class="container" role="main">
<article class="article" class="blog-post">
<div class="postmeta">
{{ partial "postmeta.html" . }}
</div>
<br>
{{ partial "toc.html" . }}
{{ if .Params.tags }}
<div class="blog-tags">
{{ range .Params.tags }}
<a href="{{ (urlize (printf "tags/%s/" .)) | absLangURL }}">{{ . }}</a>&nbsp;
{{ end }}
</div>
{{ end }}
</article>
{{ if and (gt .WordCount 400) (.Param "backtotop") }}
{{ partial "backtotop.html" . }}
<button onclick="topFunction()" id="backtotopButton">
<i class="fa fa-angle-up"></i>
</button>
{{ end }}
</div>
{{ end }}

View file

@ -0,0 +1,16 @@
{{ define "main" }}
<div class="container" role="main">
<article class="post-preview">
{{ range .Data.Terms.Alphabetical }}
<div class="terms">
<h4 class="term-name" >
<a href="{{ .Page.Permalink }}">{{ .Page.Title }}</a>
<span class="badge">{{ .Count }}</span>
</h4>
</div>
{{ end }}
</article>
</div>
{{ end }}

View file

@ -0,0 +1,21 @@
<footer>
<div class="container">
<p class="credits copyright">
<p class="credits theme-by">
{{ if .Site.Params.Legal }}
<a href="{{ .Site.BaseURL }}legal/">{{ .Site.Params.Legal }}</a>
<br>
{{ end }}
{{ if .Site.Params.PoweredBy }}
Powered By <a href="https://gohugo.io">Hugo</a>&nbsp;/&nbsp;Theme&nbsp;<a href="https://github.com/kaisugi/HugoTeX">HugoTeX</a>
<br>
{{ end }}
{{ if .Site.Title }}
<a href="{{ .Site.BaseURL }}">{{ .Site.Title }}</a>,
{{ end }}
&copy;
{{ .Site.Lastmod.Format "2006" }}
<a href="{{ .Site.BaseURL }}about/">{{ .Site.Params.Author.name }}</a>
</p>
</div>
</footer>

View file

@ -0,0 +1,28 @@
<head>
<meta charset="utf-8" />
{{ if .Title }}
<title>{{ .Title }} - {{ .Site.Title }}</title>
{{ else }}
<title>{{ .Site.Title }}</title>
{{ end }}
{{ with .Site.Params.description }}
<meta name="description" content="{{ . }}" />
{{ end }}
{{- with .Site.Params.Author.Name }}
<meta name="author" content="{{ . }}"/>
{{- end }}
<meta http-equiv="X-UA-Compatible" content="IE=edge" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
{{ if site.Params.twittercard }}
{{ template "_internal/twitter_cards.html" . }}
{{- end }}
{{ if site.Params.opengraph }}
{{ template "_internal/opengraph.html" . }}
{{- end }}
{{ range .AlternativeOutputFormats -}}
{{ printf `<link rel="%s" type="%s" href="%s" title="%s" />` .Rel .MediaType.Type .Permalink $.Site.Title | safeHTML }}
{{ end -}}
<link rel="stylesheet" href="{{ .Site.BaseURL }}css/latex.css" />
<link rel="stylesheet" href="{{ .Site.BaseURL }}css/main.css" />
<script id="MathJax-script" async src="{{ .Site.BaseURL }}js/tex-mml-chtml.js"></script>
</head>

View file

@ -0,0 +1,42 @@
{{ if .IsHome }}
{{ if .Site.Params.homeTitle }}
{{ $.Scratch.Set "title" .Site.Params.homeTitle }}
{{ else }}
{{ $.Scratch.Set "title" .Site.Title }}
{{ end }}
{{ else }}
{{ $.Scratch.Set "title" .Title }}
{{ end }}
{{ $title := $.Scratch.Get "title" }}
{{ if $title }}
<header>
{{ partial "nav.html" . }}
<div class="intro-header">
<div class="container">
<div class="{{ .Type }}-heading">
{{ if eq .Type "list" }}
<h1>{{ if .Data.Singular }}#{{ end }}{{ .Title }}</h1>
{{ else }}
<h1>{{ with $title }}{{.}}{{ else }}<br/>{{ end }}</h1>
{{ if .IsHome }}
<p class="author">{{ with .Site.Params.Author.name }}{{.}}{{ else }}<br/>{{ end }}</p>
{{ if .Site.Params.Author.abstract }}
<div class="abstract">
<h5>Abstract</h5>
<p>
{{ .Site.Params.Author.abstract }}
</p>
</div>
{{ end }}
{{ end }}
{{ end }}
</div>
</div>
</div>
</header>
{{ else }}
<div class="intro-header"></div>
{{ end }}

22
layouts/partials/nav.html Normal file
View file

@ -0,0 +1,22 @@
<nav class="navbar">
<div class="nav">
{{ if .Site.Params.logo }}
<a href="{{ .Site.BaseURL }}" class="nav-logo">
<img src="{{ .Site.BaseURL }}images/{{ .Site.Params.logo.url }}"
width="{{ .Site.Params.logo.width }}"
height="{{ .Site.Params.logo.height }}"
alt="{{ .Site.Params.logo.alt }}">
</a>
{{ end }}
<ul class="nav-links">
{{ range .Site.Params.nav }}
{{ if .icon }}
<li><a href="{{ .url | relLangURL }}" name="{{ .name }}"><i class="{{ .icon }}"></i></a></li>
{{ else }}
<li><a href="{{ .url | relLangURL }}" name="{{ .name }}">{{ .name }}</a></li>
{{ end }}
{{ end }}
</ul>
</div>
</nav>

View file

@ -0,0 +1,15 @@
<span class="meta-post">
{{- $lastmod := .Lastmod.Format ( .Site.Params.dateformat | default "Jan 2, 2006") }}
{{- $pubdate := .PublishDate.Format ( .Site.Params.dateformat | default "Jan 2, 2006") }}
<i class="fa fa-calendar-alt"></i>
{{ $pubdate }}
{{- if ne $lastmod $pubdate }}
({{ $lastmod }})
{{- end }}
{{ if .Params.categories }}
<br><i class="fa fa-folder-open"></i>
{{ range .Params.categories }}
<a href="{{ $.Site.BaseURL }}/categories/{{ . | urlize }}/">{{ . }}</a>&nbsp;
{{ end }}
{{ end }}
</span>

View file

@ -0,0 +1,14 @@
<article class="post-preview">
<a href="{{ .Permalink }}">
<h2 class="post-title">{{ .Title }}</h2>
</a>
<div class="postmeta">
{{ partial "postmeta.html" . }}
</div>
<div class="post-entry">
{{ if .Truncated }}
<p>{{ .Summary }}</p>
<a href="{{ .Permalink }}" class="post-read-more">Read More</a>
{{ end }}
</div>
</article>

18
layouts/partials/toc.html Normal file
View file

@ -0,0 +1,18 @@
{{ if and (gt .WordCount 400) (.Param "toc") }}
{{- /* 正規表現でh[1-6]を探す */ -}}
{{- $header := (findRE "<h2.*?>(?:.|\n)*?</h2>" .Content) -}}
{{- /* 最初に出現するh[1-6]を取得 */ -}}
{{- $firstH := index $header 0 -}}
{{- if ne $firstH nil -}}
{{- /* ヘッダーの前にToCを結合した「新しいヘッダー」を作成 */ -}}
{{- $newH := printf `%s%s` .TableOfContents $firstH -}}
{{- /* 古いヘッダーを新しいヘッダーに置換して出力 */ -}}
{{- replace .Content $firstH $newH | safeHTML -}}
{{- else -}}
{{- /* そもそもヘッダーがない時は普通に出力 */ -}}
{{- .Content -}}
{{- end -}}
{{ else }}
{{ .Content }}
{{ end }}

View file

@ -0,0 +1,4 @@
{{ $id := md5 .Inner }}
<label for="{{ $id }}" class="sidenote-toggle sidenote-number"></label>
<input type="checkbox" id="{{ $id }}" class="sidenote-toggle" />
<span class="sidenote">{{ .Inner }}</span>

View file

@ -0,0 +1,9 @@
{{ $htmlTable := .Inner | markdownify }}
{{ $old := "<table>" }}
{{ $new := "" }}
{{ $title := .Get "title" }}
{{ if $title }}
{{ $new = printf "<table><caption>%s</caption>" ($title | markdownify) }}
{{ end }}
{{ $htmlTable := replace $htmlTable $old $new }}
{{ $htmlTable | safeHTML }}