Merge pull request #1 from nanxiaobei/master

rebase
This commit is contained in:
Ryan Harter 2020-05-22 17:12:46 -05:00 committed by GitHub
commit 98a6d49c5e
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
6 changed files with 77 additions and 63 deletions

View File

@ -1,4 +1,4 @@
# Paper <sup><sup><sub>v4.5 (Dark Mode)</sub></sup></sup> # Paper <sup><sup><sub>v4.7 (Dark Mode)</sub></sup></sup>
A simple, clean, flexible Hugo theme. A simple, clean, flexible Hugo theme.
@ -39,3 +39,7 @@ theme = "paper"
``` ```
For more information read the official [guide](https://gohugo.io/getting-started/quick-start/#step-3-add-a-theme) of Hugo. For more information read the official [guide](https://gohugo.io/getting-started/quick-start/#step-3-add-a-theme) of Hugo.
## Dark Mode
It's automatic, according to the natural time of day and night.

View File

@ -1,3 +1,3 @@
{{ partial "header.html" . }} {{- partial "header.html" . }}
<div class="not-found">404</div> <div class="not-found">404</div>
{{ partial "footer.html" . }} {{- partial "footer.html" . }}

View File

@ -1,16 +1,21 @@
{{ partial "header.html" . }} {{- partial "header.html" . }}
{{- $scope := .Site }}
{{ if not .IsHome }} {{- if .Title }}
<header class="page-header"> <header class="page-header"><h1>{{ .Title }}</h1></header>{{ $scope = . }}
<h1>{{ if eq .Data.Singular "tag" }}{{ .Data.Term }}{{ else }}Posts{{ end }}</h1>
</header>
{{ end }} {{ end }}
{{ $paginator := .Paginate (where .Site.RegularPages ".Params.type" "!=" "page") }} {{- $paginator := .Paginate (where $scope.RegularPages ".Params.type" "!=" "page") }}
{{ range $index, $page := $paginator.Pages }} {{- range $index, $page := $paginator.Pages }}
<article class="{{ if and $.IsHome (eq $paginator.PageNumber 1) (eq $index 0) }}first-entry{{ else }}post-entry{{ end }}">
{{- $class := "post-entry" }}
{{- if (and $.IsHome (eq $paginator.PageNumber 1) (eq $index 0)) }}
{{- $class = "first-entry" }}
{{- else if .Data.Term }}
{{- $class = "post-entry tag-entry" }}
{{- end }}
<article class="{{ $class }}">
<header class="entry-header"> <header class="entry-header">
<h2>{{ .Title }}</h2> <h2>{{ .Title }}</h2>
</header> </header>
@ -22,19 +27,19 @@
</footer> </footer>
<a class="entry-link" href="{{ .Permalink }}"></a> <a class="entry-link" href="{{ .Permalink }}"></a>
</article> </article>
{{ end }} {{- end }}
{{ if gt $paginator.TotalPages 1 }} {{- if gt $paginator.TotalPages 1 }}
<footer class="page-footer"> <footer class="page-footer">
<nav class="pagination"> <nav class="pagination">
{{ if $paginator.HasPrev }} {{- if $paginator.HasPrev }}
<a class="prev" href="{{ $paginator.Prev.URL }}">← {{ i18n "prev_page" }}</a> <a class="prev" href="{{ $paginator.Prev.URL }}">← {{ i18n "prev_page" }}</a>
{{ end }} {{- end }}
{{ if $paginator.HasNext }} {{- if $paginator.HasNext }}
<a class="next" href="{{ $paginator.Next.URL }}">{{ i18n "next_page" }} →</a> <a class="next" href="{{ $paginator.Next.URL }}">{{ i18n "next_page" }} →</a>
{{ end }} {{- end }}
</nav> </nav>
</footer> </footer>
{{ end }} {{- end }}
{{ partial "footer.html" . }} {{- partial "footer.html" . }}

View File

@ -1,28 +1,28 @@
{{ partial "header.html" . }} {{- partial "header.html" . }}
<article class="post-single"> <article class="post-single">
<header class="post-header"> <header class="post-header">
<h1 class="post-title">{{ .Title }}</h1> <h1 class="post-title">{{ .Title }}</h1>
<div class="post-meta"> <div class="post-meta">
{{- if or .Params.author .Site.Params.author -}} {{- if or .Params.author .Site.Params.author }}
{{ .Params.author | default .Site.Params.author }} · {{ end }} {{- .Params.author | default .Site.Params.author }} · {{ end }}
{{- .Date.Format "January 2, 2006" -}} {{- .Date.Format "January 2, 2006" -}}
</div> </div>
</header> </header>
<div class="post-content">{{ .Content }}</div> <div class="post-content">{{ .Content }}</div>
{{ if .Params.tags }} {{- if .Params.tags }}
<footer class="post-footer"> <footer class="post-footer">
<ul class="post-tags"> <ul class="post-tags">
{{ range .Params.tags }} {{- range .Params.tags }}
{{ $href := print (absURL "tags/") (urlize .) }} {{- $href := print (absURL "tags/") (urlize .) }}
<li><a href="{{ $href }}">{{ . }}</a></li> <li><a href="{{ $href }}">{{ . }}</a></li>
{{ end }} {{- end }}
</ul> </ul>
</footer> </footer>
{{ end }} {{- end }}
<!-- Comments area start --> <!-- Comments area start -->
{{ if not (eq .Params.comments false) }} {{- if not (eq .Params.comments false) }}
{{ if .Site.DisqusShortname }} {{- if .Site.DisqusShortname }}
<div id="disqus_thread"></div> <div id="disqus_thread"></div>
<script> <script>
var disqus_shortname = '{{ .Site.DisqusShortname }}'; var disqus_shortname = '{{ .Site.DisqusShortname }}';
@ -38,8 +38,8 @@
<a href="https://disqus.com/?ref_noscript">comments powered by Disqus.</a> <a href="https://disqus.com/?ref_noscript">comments powered by Disqus.</a>
</noscript> </noscript>
<!-- Comments area end --> <!-- Comments area end -->
{{ end }} {{- end }}
{{ end }} {{- end }}
</article> </article>
{{ partial "footer.html" . }} {{- partial "footer.html" . }}

View File

@ -5,22 +5,15 @@
<meta http-equiv="X-UA-Compatible" content="IE=edge"> <meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no"> <meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no">
<!-- Title --> <!-- Title -->
<title> <title>{{ if .Title }}{{ .Title }} - {{ end }}{{ .Site.Title }}</title>
{{- if not .IsHome }}
{{- if eq .Kind "page" }}{{ .Title }}
{{- else if eq .Data.Singular "tag" }}{{ .Data.Term }}
{{- else }}Posts
{{- end }} - {{ end }}
{{- .Site.Title -}}
</title>
<!-- Meta --> <!-- Meta -->
{{- if eq .Kind "page" }} {{- if eq .Kind "page" }}
<meta name="description" content="{{ .Summary }}"> <meta name="description" content="{{ .Summary }}">
<meta name="author" content="{{ .Params.author | default .Site.Params.author }}"> <meta name="author" content="{{ .Params.author | default .Site.Params.author }}">
{{ else }} {{- else }}
<meta name="description" content="{{ .Site.Params.description }}"> <meta name="description" content="{{ .Site.Params.description }}">
<meta name="author" content="{{ .Site.Params.author }}"> <meta name="author" content="{{ .Site.Params.author }}">
{{ end -}} {{- end }}
<!-- Styles --> <!-- Styles -->
<link href="{{ "an-old-hope.min.css" | absURL }}" rel="stylesheet"> <link href="{{ "an-old-hope.min.css" | absURL }}" rel="stylesheet">
<link href="{{ "style.css" | absURL }}" rel="stylesheet"> <link href="{{ "style.css" | absURL }}" rel="stylesheet">
@ -29,14 +22,14 @@
<link rel="apple-touch-icon" href="{{ "apple-touch-icon.png" | absURL }}"> <link rel="apple-touch-icon" href="{{ "apple-touch-icon.png" | absURL }}">
<link rel="icon" href="{{ "favicon.ico" | absURL }}"> <link rel="icon" href="{{ "favicon.ico" | absURL }}">
<!-- Generator --> <!-- Generator -->
{{ hugo.Generator }} {{- hugo.Generator }}
<!-- RSS --> <!-- RSS -->
<link rel="alternate" type="application/atom+xml" href="{{ "index.xml" | absURL }}" title="{{ .Site.Title }}"> <link rel="alternate" type="application/atom+xml" href="{{ "index.xml" | absURL }}" title="{{ .Site.Title }}">
<!-- Misc --> <!-- Misc -->
{{ if eq (getenv "HUGO_ENV") "production" | or (eq .Site.Params.env "production") }} {{- if eq (getenv "HUGO_ENV") "production" | or (eq .Site.Params.env "production") }}
{{ template "_internal/google_analytics_async.html" . }} {{- template "_internal/google_analytics_async.html" . }}
{{ template "_internal/opengraph.html" . }} {{- template "_internal/opengraph.html" . }}
{{ end }} {{- end }}
<!-- Script --> <!-- Script -->
<script> <script>
function setTheme() { function setTheme() {
@ -81,26 +74,26 @@
} }
</script> </script>
</head> </head>
<body class="{{if eq .Kind `page` }}single{{else}}list{{ if .IsHome }} home{{ end }}{{end}}"> <body class="{{ if eq .Kind `page` }}single{{ else }}list{{ if .IsHome }} home{{ end }}{{ end }}">
<script> <script>
setTheme(); setTheme();
</script> </script>
<header class="header"> <header class="header">
<nav class="nav"> <nav class="nav">
{{ if .IsHome }} {{- if .IsHome }}
<h1 class="logo"><a href="{{ "" | absURL }}">{{ .Site.Title }}</a></h1> <h1 class="logo"><a href="{{ "" | absURL }}">{{ .Site.Title }}</a></h1>
{{ else }} {{- else }}
<p class="logo"><a href="{{ "" | absURL }}">{{ .Site.Title }}</a></p> <p class="logo"><a href="{{ "" | absURL }}">{{ .Site.Title }}</a></p>
{{ end }} {{- end }}
{{ if .Site.Menus.main }} {{- if .Site.Menus.main }}
<ul class="menu"> <ul class="menu">
{{ range .Site.Menus.main }} {{- range .Site.Menus.main }}
<li> <li>
<a href="{{ .URL }}">{{ .Name }}</a> <a href="{{ .URL }}">{{ .Name }}</a>
</li> </li>
{{ end }} {{- end }}
</ul> </ul>
{{ end }} {{- end }}
</nav> </nav>
</header> </header>
<main class="main"> <main class="main">

View File

@ -3,7 +3,7 @@
* A simple, clean, flexible Hugo theme * A simple, clean, flexible Hugo theme
* https://github.com/nanxiaobei/hugo-paper * https://github.com/nanxiaobei/hugo-paper
* Designed by MR.LEE (https://mrlee.me/) * Designed by MR.LEE (https://mrlee.me/)
* Updated in 2019.10.17 * Updated in 2020.5.15
*/ */
/* Theme /* Theme
@ -18,29 +18,33 @@
--radius: 8px; --radius: 8px;
--theme: #fff; --theme: #fff;
--entry: #fff;
--primary: rgba(0, 0, 0, 0.88); --primary: rgba(0, 0, 0, 0.88);
--secondary: rgba(0, 0, 0, 0.56); --secondary: rgba(0, 0, 0, 0.56);
--tertiary: rgba(0, 0, 0, 0.16); --tertiary: rgba(0, 0, 0, 0.16);
--content: rgba(0, 0, 0, 0.88);
--hljs-bg: #1c1d21; --hljs-bg: #1c1d21;
--code-bg: #f5f5f5; --code-bg: #f5f5f5;
--border: #eee; --border: #eee;
} }
.dark { .dark {
--theme: #3c3c3c; --theme: #1d1d1d;
--primary: rgba(255, 255, 255, 0.88); --entry: #333;
--primary: rgba(255, 255, 255, 0.8);
--secondary: rgba(255, 255, 255, 0.56); --secondary: rgba(255, 255, 255, 0.56);
--tertiary: rgba(255, 255, 255, 0.16); --tertiary: rgba(255, 255, 255, 0.16);
--content: rgba(255, 255, 255, 0.64);
--hljs-bg: #2a2a2a; --hljs-bg: #2a2a2a;
--code-bg: #4f4f4f; --code-bg: #333;
--border: #5f5f5f; --border: #5f5f5f;
} }
.list { .list {
background: linear-gradient(135deg, #ddd, #f5f5f5, #d5d5d5); background: linear-gradient(135deg, #ddd, #f5f5f5, #d5d5d5);
} }
.dark.list { .dark.list {
background: linear-gradient(135deg, #1c1c1c, #2a2a2a, #000); background: linear-gradient(135deg, #1b1b1b, #252525, #000);
} }
/* Reset /* Reset
-------------------------------------------------- */ -------------------------------------------------- */
@ -56,7 +60,7 @@ body {
margin: 0; margin: 0;
color: var(--primary); color: var(--primary);
font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, Cantarell, font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, Cantarell,
'Open Sans', 'Helvetica Neue', sans-serif; 'Open Sans', 'Helvetica Neue', sans-serif;
font-size: 18px; font-size: 18px;
line-height: 1.8; line-height: 1.8;
word-break: break-word; word-break: break-word;
@ -82,6 +86,7 @@ h5,
h6 { h6 {
margin-top: 0; margin-top: 0;
margin-bottom: 0; margin-bottom: 0;
color: var(--primary);
line-height: 1.2; line-height: 1.2;
} }
p { p {
@ -238,13 +243,17 @@ img {
position: relative; position: relative;
margin-bottom: var(--gap); margin-bottom: var(--gap);
padding: var(--gap); padding: var(--gap);
background: var(--theme); background: var(--entry);
border-radius: var(--radius); border-radius: var(--radius);
transition: transform 0.1s; transition: transform 0.1s;
} }
.post-entry:active { .post-entry:active {
transform: scale(0.96); transform: scale(0.96);
} }
.tag-entry .entry-content,
.tag-entry .entry-footer {
display: none;
}
.entry-header h2 { .entry-header h2 {
font-size: 24px; font-size: 24px;
} }
@ -285,6 +294,9 @@ img {
color: var(--secondary); color: var(--secondary);
font-size: 14px; font-size: 14px;
} }
.post-content {
color: var(--content);
}
.post-content h1 { .post-content h1 {
margin-top: 40px; margin-top: 40px;
margin-bottom: 32px; margin-bottom: 32px;