From e03422873a1788137f120d9c8f34b2be079f0aee Mon Sep 17 00:00:00 2001 From: 简律纯 Date: Fri, 2 Aug 2024 13:23:35 +0800 Subject: docs: build with hugo --- themes/hugo-xmag/.github/FUNDING.yml | 3 + themes/hugo-xmag/.gitignore | 5 + themes/hugo-xmag/LICENSE.md | 20 +++ themes/hugo-xmag/README.md | 53 +++++++ themes/hugo-xmag/archetypes/default.md | 4 + themes/hugo-xmag/hugo-xmag.Rproj | 16 ++ themes/hugo-xmag/images/screenshot.png | Bin 0 -> 87623 bytes themes/hugo-xmag/images/tn.png | Bin 0 -> 49120 bytes themes/hugo-xmag/layouts/404.html | 9 ++ themes/hugo-xmag/layouts/_default/list.html | 52 ++++++ themes/hugo-xmag/layouts/_default/single.html | 41 +++++ themes/hugo-xmag/layouts/_default/terms.html | 22 +++ themes/hugo-xmag/layouts/partials/author.html | 25 +++ .../hugo-xmag/layouts/partials/author_names.html | 1 + themes/hugo-xmag/layouts/partials/banner.html | 7 + themes/hugo-xmag/layouts/partials/comments.html | 0 themes/hugo-xmag/layouts/partials/foot_custom.html | 0 themes/hugo-xmag/layouts/partials/footer.html | 34 ++++ themes/hugo-xmag/layouts/partials/head_custom.html | 1 + themes/hugo-xmag/layouts/partials/header.html | 41 +++++ themes/hugo-xmag/layouts/partials/info.html | 0 themes/hugo-xmag/layouts/partials/meta.html | 0 themes/hugo-xmag/layouts/partials/prev_next.html | 6 + themes/hugo-xmag/static/css/fonts.css | 13 ++ themes/hugo-xmag/static/css/style.css | 175 +++++++++++++++++++++ themes/hugo-xmag/theme.toml | 12 ++ 26 files changed, 540 insertions(+) create mode 100644 themes/hugo-xmag/.github/FUNDING.yml create mode 100644 themes/hugo-xmag/.gitignore create mode 100644 themes/hugo-xmag/LICENSE.md create mode 100644 themes/hugo-xmag/README.md create mode 100644 themes/hugo-xmag/archetypes/default.md create mode 100644 themes/hugo-xmag/hugo-xmag.Rproj create mode 100644 themes/hugo-xmag/images/screenshot.png create mode 100644 themes/hugo-xmag/images/tn.png create mode 100644 themes/hugo-xmag/layouts/404.html create mode 100644 themes/hugo-xmag/layouts/_default/list.html create mode 100644 themes/hugo-xmag/layouts/_default/single.html create mode 100644 themes/hugo-xmag/layouts/_default/terms.html create mode 100644 themes/hugo-xmag/layouts/partials/author.html create mode 100644 themes/hugo-xmag/layouts/partials/author_names.html create mode 100644 themes/hugo-xmag/layouts/partials/banner.html create mode 100644 themes/hugo-xmag/layouts/partials/comments.html create mode 100644 themes/hugo-xmag/layouts/partials/foot_custom.html create mode 100644 themes/hugo-xmag/layouts/partials/footer.html create mode 100644 themes/hugo-xmag/layouts/partials/head_custom.html create mode 100644 themes/hugo-xmag/layouts/partials/header.html create mode 100644 themes/hugo-xmag/layouts/partials/info.html create mode 100644 themes/hugo-xmag/layouts/partials/meta.html create mode 100644 themes/hugo-xmag/layouts/partials/prev_next.html create mode 100644 themes/hugo-xmag/static/css/fonts.css create mode 100644 themes/hugo-xmag/static/css/style.css create mode 100644 themes/hugo-xmag/theme.toml (limited to 'themes') diff --git a/themes/hugo-xmag/.github/FUNDING.yml b/themes/hugo-xmag/.github/FUNDING.yml new file mode 100644 index 0000000..9a5a186 --- /dev/null +++ b/themes/hugo-xmag/.github/FUNDING.yml @@ -0,0 +1,3 @@ +github: [yihui] +patreon: +custom: diff --git a/themes/hugo-xmag/.gitignore b/themes/hugo-xmag/.gitignore new file mode 100644 index 0000000..ce130a0 --- /dev/null +++ b/themes/hugo-xmag/.gitignore @@ -0,0 +1,5 @@ +.Rproj.user +.Rhistory +.RData +.Ruserdata +exampleSite/public diff --git a/themes/hugo-xmag/LICENSE.md b/themes/hugo-xmag/LICENSE.md new file mode 100644 index 0000000..fa77e18 --- /dev/null +++ b/themes/hugo-xmag/LICENSE.md @@ -0,0 +1,20 @@ +The MIT License (MIT) + +Copyright (c) 2017 Yihui Xie + +Permission is hereby granted, free of charge, to any person obtaining a copy of +this software and associated documentation files (the "Software"), to deal in +the Software without restriction, including without limitation the rights to +use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of +the Software, and to permit persons to whom the Software is furnished to do so, +subject to the following conditions: + +The above copyright notice and this permission notice shall be included in all +copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS +FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR +COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER +IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN +CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. diff --git a/themes/hugo-xmag/README.md b/themes/hugo-xmag/README.md new file mode 100644 index 0000000..6095d66 --- /dev/null +++ b/themes/hugo-xmag/README.md @@ -0,0 +1,53 @@ +# HUGO XMAG + +**XMag** is designed based on the Hugo theme [**XMin**](https://github.com/yihui/hugo-xmin), and similarly, features minimalism but with a magazine style on the homepage inspired by [The Signpost](https://en.wikipedia.org/wiki/Wikipedia:Wikipedia_Signpost) on Wikipedia. + +This theme includes a few cool features: + +- Responsive article summary blocks on homepage + +- Thumbnails in summary blocks + +- Magazine title in Blackletter (𝔅𝔏𝔄ℭ𝔎 𝔏𝔈𝔗𝔗𝔈ℜ) + +- Github edit links + +- Author info and site info at the bottom of an article + +- MathJax for LaTeX math expressions + +It also supports features that are probably not even worth mentioning: + +- Google Analytics + +- highlight.js for syntax highlighting of code blocks + +- Display categories and tags on single pages + +- Table of contents for single pages + +Most features can be configured through `config.toml`, and a few can be enabled by custom layouts. Please see the detailed documentation on the [About](https://xmag.yihui.org/about/) page of the theme website. The source code is available [on Github](https://github.com/yihui/hugo-xmag) (MIT license). + +## Quickstart guide + +If you are an R user, the easiest way to get started with this theme is to install the **blogdown** package, and [use `blogdown::new_site()` to create a new site](https://bookdown.org/yihui/blogdown/a-quick-example.html): + +```r +install.packages('blogdown') +blogdown::new_site(theme = 'yihui/hugo-xmag') +``` + +If you do not use R, please read on. + +**Watch out** The standard [Quickstart Guide](https://gohugo.io/getting-started/quick-start/) fails. In Step 3 do not proceed past `git init`. + +Then, to install this theme in your Hugo site + +1. Download this repo and unzip it +1. Change directory to the site root +1. Copy the downloaded theme into `themes/`: `cp -r ~/Downloads/hugo-mag-master themes/hugo-mag` +1. Copy the example site into your site root: `cp -r themes/hugo-mag/exampleSite .` + +Now resume the Quickstart Guide at Step 5. + +[![Screenshot](https://github.com/yihui/hugo-xmag/raw/master/images/screenshot.png)](https://xmag.yihui.org) diff --git a/themes/hugo-xmag/archetypes/default.md b/themes/hugo-xmag/archetypes/default.md new file mode 100644 index 0000000..fb98e92 --- /dev/null +++ b/themes/hugo-xmag/archetypes/default.md @@ -0,0 +1,4 @@ +--- +title: '' +date: '' +--- diff --git a/themes/hugo-xmag/hugo-xmag.Rproj b/themes/hugo-xmag/hugo-xmag.Rproj new file mode 100644 index 0000000..d64e28b --- /dev/null +++ b/themes/hugo-xmag/hugo-xmag.Rproj @@ -0,0 +1,16 @@ +Version: 1.0 + +RestoreWorkspace: Default +SaveWorkspace: Default +AlwaysSaveHistory: Default + +EnableCodeIndexing: Yes +UseSpacesForTab: Yes +NumSpacesForTab: 2 +Encoding: UTF-8 + +RnwWeave: knitr +LaTeX: pdfLaTeX + +AutoAppendNewline: Yes +StripTrailingWhitespace: Yes diff --git a/themes/hugo-xmag/images/screenshot.png b/themes/hugo-xmag/images/screenshot.png new file mode 100644 index 0000000..af0bb31 Binary files /dev/null and b/themes/hugo-xmag/images/screenshot.png differ diff --git a/themes/hugo-xmag/images/tn.png b/themes/hugo-xmag/images/tn.png new file mode 100644 index 0000000..68f61b4 Binary files /dev/null and b/themes/hugo-xmag/images/tn.png differ diff --git a/themes/hugo-xmag/layouts/404.html b/themes/hugo-xmag/layouts/404.html new file mode 100644 index 0000000..c7d0697 --- /dev/null +++ b/themes/hugo-xmag/layouts/404.html @@ -0,0 +1,9 @@ +{{ partial "header.html" . }} + +
+
+

404 NOT FOUND

+
+
+ +{{ partial "footer.html" . }} diff --git a/themes/hugo-xmag/layouts/_default/list.html b/themes/hugo-xmag/layouts/_default/list.html new file mode 100644 index 0000000..5c1ac2c --- /dev/null +++ b/themes/hugo-xmag/layouts/_default/list.html @@ -0,0 +1,52 @@ +{{ partial "header.html" . }} + +
+
+{{ $pages := .Pages }} +{{ if .IsHome }}{{ $pages = .Site.RegularPages }}{{ end }} +{{ $paginator := .Paginate (where $pages "Section" "!=" "") }} +{{ range $paginator.Pages }} +
+
+ {{ with .Params.categories }} + {{ range first 1 . }} + {{ . }} + {{ end }} + {{ else }} + {{ default "Uncategorized" .Site.Params.text.uncategorized }} + {{ end }} +
+

{{ .Title }}

+
+ {{ if .Params.author }}{{ partial "author_names.html" . }} / {{ end }} + {{ .Date.Format "2006-01-02" }} +
+ + {{ end }} + {{ end }} + {{ end }} + {{ with .Description }} + {{ $.Scratch.Set "summary" (markdownify .) }} + {{ else }} + {{ $.Scratch.Set "summary" ((delimit (findRE "((.|\n)*?

\\s*)+" .Content) "[…] ") | plainify | truncate (default 200 .Site.Params.summary_length) (default " …" .Site.Params.text.truncated ) | replaceRE "&" "&" | safeHTML) }} + {{ end }} + {{ $.Scratch.Get "summary" }} +
+
+ +{{ end }} + + + + +{{ partial "footer.html" . }} diff --git a/themes/hugo-xmag/layouts/_default/single.html b/themes/hugo-xmag/layouts/_default/single.html new file mode 100644 index 0000000..173ec3b --- /dev/null +++ b/themes/hugo-xmag/layouts/_default/single.html @@ -0,0 +1,41 @@ +{{ partial "header.html" . }} +
+
+ + +{{ if .Params.toc }} +{{ .TableOfContents }} +{{ end }} + +
+{{ .Content }} +
+ +{{ partial "author.html" . }} +{{ partial "info.html" . }} +{{ partial "prev_next.html" . }} +{{ partial "comments.html" . }} +
+
+ +{{ partial "footer.html" . }} diff --git a/themes/hugo-xmag/layouts/_default/terms.html b/themes/hugo-xmag/layouts/_default/terms.html new file mode 100644 index 0000000..2f432ed --- /dev/null +++ b/themes/hugo-xmag/layouts/_default/terms.html @@ -0,0 +1,22 @@ +{{ partial "header.html" . }} + +
+
+
+

{{ $.Scratch.Get "Title" }}

+ +
    + {{ range $key, $value := .Data.Terms }} +
  • + + {{ $key }} + + ({{ len $value }}) +
  • + {{ end }} +
+
+
+
+ +{{ partial "footer.html" . }} diff --git a/themes/hugo-xmag/layouts/partials/author.html b/themes/hugo-xmag/layouts/partials/author.html new file mode 100644 index 0000000..c4977ab --- /dev/null +++ b/themes/hugo-xmag/layouts/partials/author.html @@ -0,0 +1,25 @@ +{{ with .Params.author }} +{{ if eq (substr (jsonify .) 0 1) "["}} +{{ $.Scratch.Set "page_author" .}} +{{ else }} +{{ $.Scratch.Set "page_author" (slice .) }} +{{ end }} + +{{ $.Scratch.Set "author_info" slice }} +{{ if $.Site.Data.authors }} +{{ range $.Scratch.Get "page_author" }} +{{ with (index $.Site.Data.authors .) }} +{{ $.Scratch.Add "author_info" . }} +{{ end }} +{{ end }} +{{ end }} +{{ if $.Scratch.Get "author_info" }} +
+

{{ default "About the Author" $.Site.Params.text.about_author }}

+ {{ range $.Scratch.Get "author_info" }} +

{{ . | markdownify }}

+ {{ end }} +
+{{ end }} + +{{ end }} diff --git a/themes/hugo-xmag/layouts/partials/author_names.html b/themes/hugo-xmag/layouts/partials/author_names.html new file mode 100644 index 0000000..bbbc978 --- /dev/null +++ b/themes/hugo-xmag/layouts/partials/author_names.html @@ -0,0 +1 @@ +{{ replace ((jsonify .Params.author) | replaceRE "[\\[\"\\]]" "") "," (default ", " $.Site.Params.text.author_delimiter) | safeHTML }} diff --git a/themes/hugo-xmag/layouts/partials/banner.html b/themes/hugo-xmag/layouts/partials/banner.html new file mode 100644 index 0000000..cc4181c --- /dev/null +++ b/themes/hugo-xmag/layouts/partials/banner.html @@ -0,0 +1,7 @@ + diff --git a/themes/hugo-xmag/layouts/partials/comments.html b/themes/hugo-xmag/layouts/partials/comments.html new file mode 100644 index 0000000..e69de29 diff --git a/themes/hugo-xmag/layouts/partials/foot_custom.html b/themes/hugo-xmag/layouts/partials/foot_custom.html new file mode 100644 index 0000000..e69de29 diff --git a/themes/hugo-xmag/layouts/partials/footer.html b/themes/hugo-xmag/layouts/partials/footer.html new file mode 100644 index 0000000..6071ad6 --- /dev/null +++ b/themes/hugo-xmag/layouts/partials/footer.html @@ -0,0 +1,34 @@ + + + + +{{ if and (not .Params.disable_mathjax) (or (in (string .Content) "\\") (in (string .Content) "$")) }} + + +{{ end }} + +{{ if and (not .Params.disable_highlight) (in (string .Content) "") }} + + + +{{ end }} + +{{ template "_internal/google_analytics.html" . }} + + + diff --git a/themes/hugo-xmag/layouts/partials/head_custom.html b/themes/hugo-xmag/layouts/partials/head_custom.html new file mode 100644 index 0000000..960789b --- /dev/null +++ b/themes/hugo-xmag/layouts/partials/head_custom.html @@ -0,0 +1 @@ + diff --git a/themes/hugo-xmag/layouts/partials/header.html b/themes/hugo-xmag/layouts/partials/header.html new file mode 100644 index 0000000..1d3b190 --- /dev/null +++ b/themes/hugo-xmag/layouts/partials/header.html @@ -0,0 +1,41 @@ + + + + + + {{ $.Scratch.Set "Title" (default .Title (index .Site.Params.text (print "title_" (lower .Title)))) }} + {{ if eq ($.Scratch.Get "Title") .Site.Title }}{{ .Site.Title }}{{ else }}{{ ($.Scratch.Get "Title") }} | {{ .Site.Title }}{{ end }} + + + {{ partial "head_custom.html" . }} + + + + diff --git a/themes/hugo-xmag/layouts/partials/info.html b/themes/hugo-xmag/layouts/partials/info.html new file mode 100644 index 0000000..e69de29 diff --git a/themes/hugo-xmag/layouts/partials/meta.html b/themes/hugo-xmag/layouts/partials/meta.html new file mode 100644 index 0000000..e69de29 diff --git a/themes/hugo-xmag/layouts/partials/prev_next.html b/themes/hugo-xmag/layouts/partials/prev_next.html new file mode 100644 index 0000000..b2ec685 --- /dev/null +++ b/themes/hugo-xmag/layouts/partials/prev_next.html @@ -0,0 +1,6 @@ +{{ if .Section }} + +{{ end }} diff --git a/themes/hugo-xmag/static/css/fonts.css b/themes/hugo-xmag/static/css/fonts.css new file mode 100644 index 0000000..2f07028 --- /dev/null +++ b/themes/hugo-xmag/static/css/fonts.css @@ -0,0 +1,13 @@ +body { + font-family: Optima, 'Lucida Sans', Calibri, Candara, Arial, 'source-han-serif-sc', 'Source Han Serif SC', 'Source Han Serif CN', 'Source Han Serif TC', 'Source Han Serif TW', 'Source Han Serif', 'Noto Serif CJK SC', 'Songti SC', 'Microsoft YaHei', sans-serif; +} +blockquote { + font-family: 'Palatino Linotype', 'Book Antiqua', Palatino, 'STKaiti', 'KaiTi', '楷体', 'SimKai', 'DFKai-SB', 'NSimSun', serif; +} +code { + font-family: "Lucida Console", 'Andale Mono', 'STKaiti', 'KaiTi', 'SimKai', monospace; +} +pre code { + font-family: "Lucida Console", Monaco, 'STKaiti', 'KaiTi', 'SimKai', monospace; + font-size: .85em; +} diff --git a/themes/hugo-xmag/static/css/style.css b/themes/hugo-xmag/static/css/style.css new file mode 100644 index 0000000..40f6622 --- /dev/null +++ b/themes/hugo-xmag/static/css/style.css @@ -0,0 +1,175 @@ +body { + margin: 0; + line-height: 1.5em; + background: #fafafa; +} +.header div, .container, .copyright, .menu { + max-width: 1100px; + margin: auto; + padding: 0 15px; +} +.page .header div, .page .container, .page .copyright, .page .menu { max-width: 900px; } +.container { hyphens: auto; } +@media (max-width: 930px) { + .page .container { padding: 0; } +} +main { margin-bottom: 15px; } + +/* header and footer areas */ +.header { + border-top: 5px solid #666; + border-bottom: 4px double #666; + text-align: center; + padding: 15px 0 5px; +} +.head-meta, .menu { + display: flex; + justify-content: space-between; +} +.header, .list section, article { background: #fff; } +.banner { font-size: 4em; } +.banner .text { + display: block; + line-height: 1em; +} +.list { + display: flex; + flex-wrap: wrap; + margin-left: -15px; +} +.list section { + flex: 1 0 350px; + box-sizing: border-box; + box-shadow: 0 0 8px #ccc; + margin: 1em 0 0 15px; + padding: 1em; + overflow-x: hidden; +} +@media (max-width: 380px) { + .list section { flex: auto; } +} +@media (min-width: 715px) { + .list section { max-width: calc(50% - 15px); } + .article-list h1 { + overflow-x: hidden; + white-space: nowrap; + text-overflow: ellipsis; + } + .article-list h1:hover { white-space: inherit; } +} +@media (min-width: 1080px) { + .list section { max-width: calc(33.33333% - 15px); } +} +.article-list a, .banner a { color: #000; } +.categories a { + font-size: .9em; + font-weight: bolder; + text-transform: uppercase; + color: #666; +} +h1 a:hover { text-decoration: underline; } +.article-list h1 { margin: .2em auto .2em 0; } +article { padding: 1em; } +.article-meta { + text-decoration: none; + background: #eee; + padding: 5px; + border-radius: 5px; +} +.menu, .article-meta, footer, .post-nav { text-align: center; } +.article-footer { text-align: left; } +.title { font-size: 1.2em; } +.article-list h1, .title { line-height: 1.2em; } +.article-list a, .header a, footer a, .categories a, .active a, .comments a { text-decoration: none; } +.pagination { text-align: center; } +.pagination li, .terms li { display: inline; } +.pagination a { padding: 0 .2em; } +.footer { + background: #666; + padding: 1em 0; +} +.footer, .footer a { color: #fff; } +.copyright, .copyright a { color: #ccc; } +.menu { + margin-bottom: .5em; + flex-wrap: wrap; +} +.menu li { + display: inline-block; + font-weight: bolder; +} +.menu a { padding: .5em; } +.menu a:hover { + color: #000; + background: #fff; +} + +hr { + border-style: dashed; + color: #ddd; +} + +/* code */ +pre { + border: 1px solid #ddd; + box-shadow: 5px 5px 5px #eee; + overflow-x: auto; +} +code { background: #f9f9f9; } +pre code { + background: none; + padding: .5em; + display: block; +} + +/* misc elements */ +img, iframe, video { max-width: 100%; } +blockquote { + background: #f9f9f9; + border-left: 5px solid #ccc; + padding: 3px 1em 3px; +} + +table { + margin: 1em auto auto; + border-top: 1px solid #666; + border-bottom: 1px solid #666; +} +table thead th { border-bottom: 1px solid #ddd; } +th, td { padding: 5px; } +tr:nth-child(even) { background: #eee } + +.thumbnail { + height: 5.1em; + width: 6.8em; + float: left; + overflow: hidden; + margin: 5px 8px 5px 0; + box-shadow: 0 0 8px #666; +} +.thumbnail img { + width: 100%; + height: 100%; + object-fit: cover; +} +#TableOfContents, #TOC, .comments { + border: 1px solid #eee; + border-radius: 5px; +} +.comments a { + display: inline-block; + width: 100%; + text-align: center; + font-size: 1.2em; +} +.terms { padding-left: 0; } +.post-nav { + margin: .5em 0; + display: flex; + justify-content: space-between; +} +.footnotes { font-size: .9em; } +.footnotes hr { + width: 50%; + margin-left: 0; +} diff --git a/themes/hugo-xmag/theme.toml b/themes/hugo-xmag/theme.toml new file mode 100644 index 0000000..78e5dd2 --- /dev/null +++ b/themes/hugo-xmag/theme.toml @@ -0,0 +1,12 @@ +name = "XMag" +license = "MIT" +licenselink = "https://github.com/yihui/hugo-xmag/blob/master/LICENSE.md" +description = "A minimal magazine theme for Hugo" +homepage = "https://xmag.yihui.org" +tags = ["minimal", "magazine", "clean", "simple", "minimalist", "blog", "responsive", "Google Analytics", "Syntax Highlighting"] +features = ["blog", "magazine"] +min_version = "0.18" + +[author] + name = "Yihui Xie" + homepage = "https://yihui.org" -- cgit v1.2.3-70-g09d2