update layouts
This commit is contained in:
parent
34a66235ba
commit
ef99ea997c
8 changed files with 186 additions and 166 deletions
|
@ -1,3 +1,3 @@
|
|||
{{ partial "header.html" . }}
|
||||
{{ define "main" }}
|
||||
<h1 class="title-404">404</h1>
|
||||
{{ partial "footer.html" . }}
|
||||
{{ end }}
|
||||
|
|
20
layouts/_default/baseof.html
Normal file
20
layouts/_default/baseof.html
Normal file
|
@ -0,0 +1,20 @@
|
|||
<!DOCTYPE html>
|
||||
|
||||
{{ $social := slice "twitter" "github" "instagram" }}<!---->
|
||||
{{ range $key, $val := site.Params }}<!---->
|
||||
{{ if in $social $key }}<!---->
|
||||
{{ $.Scratch.SetInMap "social-map" $key $val }}<!---->
|
||||
{{ end }}<!---->
|
||||
{{ end }}<!---->
|
||||
|
||||
<html lang="{{ site.LanguageCode }}">
|
||||
{{ partial "head.html" . }}
|
||||
|
||||
<body class="not-ready" data-menu="{{ isset site.Menus `main` }}">
|
||||
{{ partial "header.html" . }}
|
||||
|
||||
<main class="main">{{ block "main" . }}{{ end }}</main>
|
||||
|
||||
{{ partial "footer.html" . }}
|
||||
</body>
|
||||
</html>
|
|
@ -1,16 +1,17 @@
|
|||
{{ partial "header.html" . }}
|
||||
{{ define "main" }}
|
||||
|
||||
<!-- Main Title -->
|
||||
{{ if .Title }}
|
||||
<h1 class="page-title">{{ .Title }}</h1>
|
||||
<h1 class="main-title">{{ .Title }}</h1>
|
||||
{{ end }}
|
||||
|
||||
<!-- $pages -->
|
||||
{{ $pages := union .RegularPages .Sections }}
|
||||
{{ if .IsHome }}
|
||||
{{ $pages = where site.RegularPages "Type" "in" site.Params.mainSections }}
|
||||
<!---->{{ if .IsHome }} {{ $pages = where site.RegularPages "Type" "in" site.Params.mainSections }}
|
||||
{{ end }}
|
||||
{{ $paginator := .Paginate $pages }}
|
||||
|
||||
{{ range $index, $page := $paginator.Pages }}
|
||||
<!-- Articles -->
|
||||
{{ $paginator := .Paginate $pages }} {{ range $index, $page := $paginator.Pages }}
|
||||
<article class="post-entry">
|
||||
<h2>{{ .Title }}</h2>
|
||||
<time>{{ .Date.Format "January 2, 2006" }}</time>
|
||||
|
@ -18,15 +19,16 @@
|
|||
</article>
|
||||
{{ end }}
|
||||
|
||||
<!-- Main Nav -->
|
||||
{{ if gt $paginator.TotalPages 1 }}
|
||||
<nav class="page-nav">
|
||||
<nav class="main-nav">
|
||||
{{ if $paginator.HasPrev }}
|
||||
<a class="prev" href="{{ $paginator.Prev.URL }}">← {{ i18n "prev_page" }}</a>
|
||||
{{ end }}
|
||||
{{ end }}<!---->
|
||||
{{ if $paginator.HasNext }}
|
||||
<a class="next" href="{{ $paginator.Next.URL }}">{{ i18n "next_page" }} →</a>
|
||||
{{ end }}
|
||||
</nav>
|
||||
{{ end }}
|
||||
{{ end }}<!---->
|
||||
|
||||
{{ partial "footer.html" . }}
|
||||
{{ end }}
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
{{ partial "header.html" . }}
|
||||
{{ define "main" }}
|
||||
|
||||
<article class="post-single">
|
||||
<header class="post-title">
|
||||
|
@ -8,33 +8,32 @@
|
|||
<span>{{ .Params.Author | default site.Author.name }}</span>
|
||||
{{ end }}
|
||||
</aside>
|
||||
|
||||
<h1>{{ .Title }}</h1>
|
||||
</header>
|
||||
|
||||
<section class="post-content">{{ .Content }}</section>
|
||||
|
||||
<!-- Post Tags -->
|
||||
{{ if .Params.tags }}
|
||||
<footer class="post-tags">
|
||||
{{ range .Params.tags }}
|
||||
{{ $href := print (absURL "tags/") (urlize .) }}
|
||||
{{ range .Params.tags }} {{ $href := print (absURL "tags/") (urlize .) }}
|
||||
<a href="{{ $href }}">{{ . }}</a>
|
||||
{{ end }}
|
||||
</footer>
|
||||
{{ end }}
|
||||
|
||||
{{ $pages := where site.RegularPages "Type" "in" site.Params.mainSections }}
|
||||
<!-- Post Nav -->
|
||||
{{ $pages := where site.RegularPages "Type" "in" site.Params.mainSections }}<!---->
|
||||
{{ if and (gt (len $pages) 1) (in $pages . ) }}
|
||||
<nav class="post-nav">
|
||||
{{ with $pages.Next . }}
|
||||
<a class="prev" href="{{ .Permalink }}"><span>←</span><span>{{ .Name }}</span></a>
|
||||
{{ end }}
|
||||
{{ with $pages.Prev . }}
|
||||
{{ end }} {{ with $pages.Prev . }}
|
||||
<a class="next" href="{{ .Permalink }}"><span>{{ .Name }}</span><span>→</span></a>
|
||||
{{ end }}
|
||||
</nav>
|
||||
{{ end }}
|
||||
|
||||
<!-- Disqus -->
|
||||
{{ if and site.DisqusShortname (not (eq .Params.comments false)) }}
|
||||
<div id="disqus_thread" class="post-comments"></div>
|
||||
<script>
|
||||
|
@ -47,4 +46,4 @@
|
|||
{{ end }}
|
||||
</article>
|
||||
|
||||
{{ partial "footer.html" . }}
|
||||
{{ end }}
|
||||
|
|
|
@ -1,8 +1,7 @@
|
|||
</main>
|
||||
<footer class="footer">
|
||||
<p>© {{ now.Year }} <a href="{{ "" | absURL }}">{{ site.Title }}</a></p>
|
||||
<p>© {{ now.Year }} <a href="{{ `` | absURL }}">{{ site.Title }}</a></p>
|
||||
<p>Powered by <a href="https://gohugo.io/" rel="noopener" target="_blank">Hugo️️</a>️</p>
|
||||
<p><a href="https://github.com/nanxiaobei/hugo-paper" rel="noopener" target="_blank">Paper 5.0</a></p>
|
||||
<p>
|
||||
<a href="https://github.com/nanxiaobei/hugo-paper" rel="noopener" target="_blank">Paper 5.0</a>
|
||||
</p>
|
||||
</footer>
|
||||
</body>
|
||||
</html>
|
||||
|
|
73
layouts/partials/head.html
Normal file
73
layouts/partials/head.html
Normal file
|
@ -0,0 +1,73 @@
|
|||
<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 -->
|
||||
{{ if eq .Kind "page" }}
|
||||
<meta name="description" content="{{ .Summary }}" />
|
||||
<meta name="author" content="{{ .Params.Author | default site.Author.name }}" />
|
||||
{{ else }}
|
||||
<meta name="description" content="{{ site.Params.description }}" />
|
||||
<meta name="author" content="{{ site.Author.name }}" />
|
||||
{{ end }}
|
||||
|
||||
<!-- Styles & Scripts -->
|
||||
{{ $app_css := resources.Get "app.css" }}
|
||||
<!---->
|
||||
{{ $custom_css := resources.Get "custom.css" }}
|
||||
<!---->
|
||||
{{ $css := slice $app_css $custom_css | resources.Concat "app.css" | minify }}
|
||||
<link rel="preload stylesheet" as="style" href="{{ $css.Permalink }}" />
|
||||
|
||||
{{ if and .IsPage (not site.Params.disableHLJS) }}
|
||||
<link rel="preload stylesheet" as="style" href="{{ `an-old-hope.min.css` | absURL }}" />
|
||||
<script
|
||||
defer
|
||||
src="{{ `highlight.min.js` | absURL }}"
|
||||
onload="hljs.initHighlightingOnLoad();"
|
||||
></script>
|
||||
{{ end }}
|
||||
|
||||
<!-- Preload -->
|
||||
<link rel="preload" as="image" href="{{ `theme.png` | absURL }}" />
|
||||
|
||||
{{ range $key, $val := $.Scratch.Get "social-map" }}
|
||||
<link rel="preload" as="image" href="{{ printf `%s.svg` $key | absURL }}" />
|
||||
{{ end }}
|
||||
|
||||
<!-- Favicon -->
|
||||
<link rel="icon" href="{{ `favicon.ico` | absURL }}" />
|
||||
<link rel="apple-touch-icon" href="{{ `apple-touch-icon.png` | absURL }}" />
|
||||
|
||||
<!-- Generator -->
|
||||
{{ hugo.Generator }}
|
||||
|
||||
<!-- RSS -->
|
||||
{{ range .AlternativeOutputFormats }}
|
||||
<link
|
||||
rel="{{ .Rel }}"
|
||||
type="{{ .MediaType.Type }}"
|
||||
href="{{ .Permalink }}"
|
||||
title="{{ site.Title }}"
|
||||
/>
|
||||
{{ end }}
|
||||
|
||||
<!-- Misc -->
|
||||
{{ if hugo.IsProduction | eq site.Params.env "production" }}
|
||||
<!---->
|
||||
{{ template "_internal/google_analytics_async.html" . }}
|
||||
<!---->
|
||||
{{ template "_internal/google_news.html" . }}
|
||||
<!---->
|
||||
{{ template "_internal/opengraph.html" . }}
|
||||
<!---->
|
||||
{{ template "_internal/schema.html" . }}
|
||||
<!---->
|
||||
{{ template "_internal/twitter_cards.html" . }}
|
||||
<!---->
|
||||
{{ end }}
|
||||
</head>
|
|
@ -1,127 +1,60 @@
|
|||
<!DOCTYPE html>
|
||||
<html lang="{{ site.LanguageCode }}">
|
||||
<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 -->
|
||||
{{ if eq .Kind "page" }}
|
||||
<meta name="description" content="{{ .Summary }}">
|
||||
<meta name="author" content="{{ .Params.Author | default site.Author.name }}">
|
||||
{{ else }}
|
||||
<meta name="description" content="{{ site.Params.description }}">
|
||||
<meta name="author" content="{{ site.Author.name }}">
|
||||
{{ end }}
|
||||
|
||||
<!-- Styles & Scripts -->
|
||||
{{ $app_css := resources.Get "app.css" }}
|
||||
{{ $custom_css := resources.Get "custom.css" }}
|
||||
{{ $css := slice $app_css $custom_css | resources.Concat "app.css" | minify }}
|
||||
<link rel="preload stylesheet" as="style" href="{{ $css.Permalink }}">
|
||||
|
||||
{{ if and .IsPage (not site.Params.disableHLJS) }}
|
||||
<link rel="preload stylesheet" as="style" href="{{ `an-old-hope.min.css` | absURL }}">
|
||||
<script defer src="{{ `highlight.min.js` | absURL }}" onload="hljs.initHighlightingOnLoad();"></script>
|
||||
{{ end }}
|
||||
|
||||
<!-- Preload -->
|
||||
<link rel="preload" as="image" href="{{ `theme.png` | absURL }}">
|
||||
{{ if site.Params.twitter }}
|
||||
<link rel="preload" as="image" href="{{ `twitter.svg` | absURL }}">
|
||||
{{ end }}
|
||||
{{ if site.Params.github }}
|
||||
<link rel="preload" as="image" href="{{ `github.svg` | absURL }}">
|
||||
{{ end }}
|
||||
{{ if site.Params.instagram }}
|
||||
<link rel="preload" as="image" href="{{ `instagram.svg` | absURL }}">
|
||||
{{ end }}
|
||||
|
||||
<!-- Favicon -->
|
||||
<link rel="icon" href="{{ `favicon.ico` | absURL }}">
|
||||
<link rel="apple-touch-icon" href="{{ `apple-touch-icon.png` | absURL }}">
|
||||
|
||||
<!-- Generator -->
|
||||
{{ hugo.Generator }}
|
||||
|
||||
<!-- RSS -->
|
||||
{{ range .AlternativeOutputFormats }}
|
||||
<link rel="{{ .Rel }}" type="{{ .MediaType.Type }}" href="{{ .Permalink }}" title="{{ site.Title }}">
|
||||
{{ end }}
|
||||
|
||||
<!-- Misc -->
|
||||
{{ if hugo.IsProduction | eq site.Params.env "production" }}
|
||||
{{ template "_internal/google_analytics_async.html" . }}
|
||||
{{ template "_internal/google_news.html" . }}
|
||||
{{ template "_internal/opengraph.html" . }}
|
||||
{{ template "_internal/schema.html" . }}
|
||||
{{ template "_internal/twitter_cards.html" . }}
|
||||
{{ end }}
|
||||
</head>
|
||||
|
||||
<body class="not-ready" data-menu="{{ isset site.Menus `main` }}">
|
||||
<header class="header">
|
||||
{{ $tag := cond .IsHome "h1" "p" }}
|
||||
{{ printf `
|
||||
<%s class="logo">
|
||||
<a class="site-name" href="%s">%s</a>
|
||||
<a class="btn-theme"></a>
|
||||
</%s>
|
||||
` $tag ("" | absURL) site.Title $tag | safeHTML }}
|
||||
{{ if .IsHome }}
|
||||
<h1 class="logo">
|
||||
<a class="site-name" href="{{ `` | absURL }}">{{ site.Title }}</a><a class="btn-theme"></a>
|
||||
</h1>
|
||||
{{ else }}
|
||||
<p class="logo">
|
||||
<a class="site-name" href="{{ `` | absURL }}">{{ site.Title }}</a><a class="btn-theme"></a>
|
||||
</p>
|
||||
{{ end }}
|
||||
|
||||
<script>
|
||||
let bodyClass = document.body.classList;
|
||||
let schemeDark = window.matchMedia('(prefers-color-scheme: dark)');
|
||||
let buttonDark = document.querySelector('.btn-theme');
|
||||
let schemeDark = window.matchMedia('(prefers-color-scheme: dark)');
|
||||
|
||||
let setDark = () => {
|
||||
bodyClass.add('dark');
|
||||
localStorage.setItem('dark', 'true');
|
||||
};
|
||||
|
||||
let setLight = () => {
|
||||
bodyClass.remove('dark');
|
||||
localStorage.removeItem('dark');
|
||||
};
|
||||
|
||||
if (schemeDark.matches || localStorage.getItem('dark')) setDark();
|
||||
|
||||
requestAnimationFrame(() => {
|
||||
bodyClass.remove('not-ready');
|
||||
});
|
||||
|
||||
schemeDark.addEventListener('change', event => {
|
||||
event.matches ? setDark() : setLight();
|
||||
});
|
||||
|
||||
buttonDark.addEventListener('click', () => {
|
||||
bodyClass.contains('dark') ? setLight() : setDark();
|
||||
});
|
||||
schemeDark.addEventListener('change', event => {
|
||||
event.matches ? setDark() : setLight();
|
||||
});
|
||||
</script>
|
||||
|
||||
{{ if site.Menus.main }}
|
||||
{{ $url := .RelPermalink }}<!---->
|
||||
{{ with site.Menus.main }}
|
||||
<nav class="menu">
|
||||
{{ $url := .Permalink }}
|
||||
{{ range site.Menus.main }}
|
||||
<a class="{{ if eq $url .URL }}active{{ end }}" href="{{ .URL }}">{{ .Name }}</a>
|
||||
{{ range . }}
|
||||
<a class="{{ if eq .URL $url }}active{{ end }}" href="{{ .URL }}">{{ .Name }}</a>
|
||||
{{ end }}
|
||||
</nav>
|
||||
{{ end }}<!---->
|
||||
|
||||
{{ with $.Scratch.Get "social-map" }}
|
||||
<nav class="social">
|
||||
{{ range $key, $val := . }}
|
||||
<a
|
||||
class="{{ $key }}"
|
||||
style="--img: url(./{{ printf `%s.svg` $key }})"
|
||||
href="https://{{ $key }}.com/{{ $val }}"
|
||||
target="_blank"
|
||||
></a>
|
||||
{{ end }}
|
||||
</nav>
|
||||
{{ end }}
|
||||
|
||||
{{ if site.Params.twitter }}
|
||||
<a class="social-icon twitter" href="https://twitter.com/{{ site.Params.twitter }}" target="_blank"></a>
|
||||
{{ end }}
|
||||
|
||||
{{ if site.Params.github }}
|
||||
<a class="social-icon github" href="https://github.com/{{ site.Params.github }}" target="_blank"></a>
|
||||
{{ end }}
|
||||
|
||||
{{ if site.Params.instagram }}
|
||||
<a class="social-icon instagram" href="https://www.instagram.com/{{ site.Params.instagram }}/" target="_blank"></a>
|
||||
{{ end }}
|
||||
|
||||
</header>
|
||||
<main class="main">
|
||||
|
|
|
@ -1,15 +1,9 @@
|
|||
{{ if .Get "content" }}
|
||||
{{ if .Get "summary" }}
|
||||
{{ else }}
|
||||
{{ warnf "missing value for param 'summary': %s" .Position }}
|
||||
{{ end }}
|
||||
{{ else }}
|
||||
{{ errorf "missing value for param 'content': %s" .Position }}
|
||||
{{ end }}
|
||||
<!---->{{ if not (.Get "summary") }}
|
||||
<!---->{{ errorf "missing param 'summary': %s" .Position }}
|
||||
<!---->{{ else if not (.Get "content") }}{{ warnf "missing param 'content': %s" .Position }}
|
||||
<!---->{{ end }}
|
||||
|
||||
<p>
|
||||
<details {{ if (eq (.Get "openByDefault") true) }}open=true{{ end }}>
|
||||
<details {{ if (eq (.Get `openByDefault`) true) }}open="true" {{ end }}>
|
||||
<summary markdown="span">{{ .Get "summary" | markdownify }}</summary>
|
||||
{{ .Get "content" | markdownify }}
|
||||
</details>
|
||||
</p>
|
||||
|
|
Loading…
Reference in a new issue