diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index b686395c4..ce0e8cf96 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -1,5 +1,7 @@ # CONTRIBUTING +Make sure that you follow [CODE_OF_CONDUCT.md](CODE_OF_CONDUCT.md) while contributing and engaging in the discussions. + ## How to contribute to this project First, fork this repository by clicking the fork button. diff --git a/README.md b/README.md index 69c69ba84..04e03cb96 100644 --- a/README.md +++ b/README.md @@ -1,37 +1,57 @@ -# FixIt Theme | Hugo + +![Hugo Theme FixIt](https://fixit.lruihao.cn/images/apple-devices-preview.png) + +
English | 简体中文
+ +FixIt logo + +# FixIt [![GitHub release (latest by date)](https://img.shields.io/github/v/release/hugo-fixit/FixIt?style=flat)](https://github.com/hugo-fixit/FixIt/releases) [![Hugo](https://img.shields.io/badge/Hugo-%5E0.127.0-ff4088?style=flat&logo=hugo)](https://gohugo.io/) [![License](https://img.shields.io/github/license/hugo-fixit/FixIt?style=flat)](/LICENSE) [![Open Source Love](https://badges.frapsoft.com/os/v1/open-source.svg?v=103)](https://github.com/hugo-fixit/FixIt) -👉 English README | [简体中文说明](README.zh-cn.md) +> «FixIt» is a **clean**, **elegant** but **advanced** blog theme for [Hugo](https://gohugo.io/). -[FixIt](https://github.com/hugo-fixit/FixIt) is a **clean**, **elegant** but **advanced** blog theme for [Hugo](https://gohugo.io/). +It is based on the original [LoveIt](https://github.com/dillonzq/LoveIt) Theme, [KeepIt](https://github.com/Fastbyte01/KeepIt) Theme and [LeaveIt](https://github.com/liuzc/LeaveIt) Theme. -It is based on the original [LoveIt Theme](https://github.com/dillonzq/LoveIt), [KeepIt Theme](https://github.com/Fastbyte01/KeepIt) and [LeaveIt Theme](https://github.com/liuzc/LeaveIt).[^1] +## Live Preview -![Hugo Theme FixIt](https://fixit.lruihao.cn/images/apple-devices-preview.webp) +

+ 💟 Production | ❇️ Preview | 🚼 Demo | 🆕 Starter +
+
+ More «FixIt» examples here. +

-## Getting started +## Documentation -1. [Installation](https://fixit.lruihao.cn/documentation/installation/) -2. [Getting Started](https://fixit.lruihao.cn/documentation/getting-started/) -3. [Content Management](https://fixit.lruihao.cn/documentation/content-management/) -4. [Advanced Usage](https://fixit.lruihao.cn/documentation/advanced/) +Head to the [Quick Start](https://fixit.lruihao.cn/documentation/getting-started/quick-start/) page for a step-by-step guide on how to create a new website with FixIt. -Alternatively, you can run the [documentation site](https://fixit.lruihao.cn/) locally. For more details, see [hugo-fixit/docs](https://github.com/hugo-fixit/docs). +Outline: [Installation](https://fixit.lruihao.cn/documentation/installation/) ➜ [Getting Started](https://fixit.lruihao.cn/documentation/getting-started/) ➜ [Content Management](https://fixit.lruihao.cn/documentation/content-management/) ➜ [Advanced Usage](https://fixit.lruihao.cn/documentation/advanced/) ## Template repository -- [hugo-fixit/hugo-fixit-start](https://github.com/hugo-fixit/hugo-fixit-start/generate) -- [hugo-fixit/hugo-fixit-start1](https://github.com/hugo-fixit/hugo-fixit-start1/generate) -- [hugo-fixit/docs](https://github.com/hugo-fixit/docs/generate) -- [Lruihao/hugo-blog](https://github.com/Lruihao/hugo-blog/generate) +Click the following links to generate a new repository with template: -## Who used FixIt +| Template repository | Generate link | +| :----------------------------------------- | :----------------------------: | +| [hugo-fixit/hugo-fixit-starter][starter] | [Click][starter:generate] | +| [hugo-fixit/hugo-fixit-starter1][starter1] | [Click][starter1:generate] | +| [hugo-fixit/docs][docs] | [Click][docs:generate] | +| [Lruihao/hugo-blog][lruihao-blog] | [Click][lruihao-blog:generate] | -To see this theme in action, here are some [live demo sites](https://fixit.lruihao.cn/friends/) which are rendered with **FixIt** theme. +[starter]: https://github.com/hugo-fixit/hugo-fixit-starter +[starter:generate]: https://github.com/hugo-fixit/hugo-fixit-starter/generate +[starter1]: https://github.com/hugo-fixit/hugo-fixit-starter1 +[starter1:generate]: https://github.com/hugo-fixit/hugo-fixit-starter1/generate +[docs]: https://github.com/hugo-fixit/docs +[docs:generate]: https://github.com/hugo-fixit/docs/generate +[lruihao-blog]: https://github.com/Lruihao/hugo-blog +[lruihao-blog:generate]: https://github.com/Lruihao/hugo-blog/generate + + ## Features @@ -96,12 +116,12 @@ To see this theme in action, here are some [live demo sites](https://fixit.lruih - Kinds of **admonitions** shortcode - **Custom style** shortcode - **Custom script** shortcode +- Open more **custom blocks** - **Animated typing** supported by [TypeIt](https://typeitjs.com/) - **Cookie consent banner** supported by [cookieconsent](https://github.com/osano/cookieconsent) - **Web Watermark** supported by [cell-watermark](https://github.com/Lruihao/watermark) - **Chinese typesetting** supported by [pangu.js](https://github.com/vinta/pangu.js) - Options to **cache remote image** locally -- High **extensibility** - ... ### Theme Components @@ -152,13 +172,12 @@ Don't forget to leave a ⭐️ if you like this theme, thanks! ## Contributing -- [Roadmap of FixIt](https://github.com/orgs/hugo-fixit/projects/2) - -Please see [CONTRIBUTING.md](CONTRIBUTING.md) for getting started with the contribution. +We welcome you to join the development of FixIt. Please see [contributing document](CONTRIBUTING.md). 🤗 -Make sure that you follow [CODE_OF_CONDUCT.md](CODE_OF_CONDUCT.md) while contributing and engaging in the discussions. +Also, we welcome Issue or PR to our [official-components](https://github.com/hugo-fixit). -**When contributing, please first discuss the change you wish to make via an issue on this repository before making the actual change**. +> [!note] +> When contributing, please first discuss the change you wish to make via a discussion on this repository before making the actual change. ## Acknowledgements @@ -226,6 +245,3 @@ If you enjoy the theme, please consider buying me a coffee ☕️. Thanks! ## Author [Lruihao](https://github.com/Lruihao "Follow me on GitHub") - - -[^1]: The theme name is interesting: "leave it, keep it, love it, fix it". Appears and leaves, loves but cannot keep. Doesn't it look like that damn love and BUG? 🤣 diff --git a/README.zh-cn.md b/README.zh-cn.md index ceaaef638..72317a189 100644 --- a/README.zh-cn.md +++ b/README.zh-cn.md @@ -1,37 +1,57 @@ -# FixIt 主题 | Hugo + +![Hugo Theme FixIt](https://fixit.lruihao.cn/images/apple-devices-preview.png) + +
English | 简体中文
+ +FixIt logo + +# FixIt [![GitHub release (latest by date)](https://img.shields.io/github/v/release/hugo-fixit/FixIt?style=flat)](https://github.com/hugo-fixit/FixIt/releases) [![Hugo](https://img.shields.io/badge/Hugo-%5E0.127.0-ff4088?style=flat&logo=hugo)](https://gohugo.io/) [![License](https://img.shields.io/github/license/hugo-fixit/FixIt?style=flat)](/LICENSE) [![Open Source Love](https://badges.frapsoft.com/os/v1/open-source.svg?v=103)](https://github.com/hugo-fixit/FixIt) -👉 [English README](README.md) | 简体中文说明 +> «FixIt» 是一个**简洁**、**优雅**且**高效**的 [Hugo](https://gohugo.io/) 博客主题。 -[FixIt](https://github.com/hugo-fixit/FixIt) 是一个**简洁**、**优雅**且**高效**的 [Hugo](https://gohugo.io/) 博客主题。 +它的原型基于 [LoveIt](https://github.com/dillonzq/LoveIt) 主题,[KeepIt](https://github.com/Fastbyte01/KeepIt) 主题和 [LeaveIt](https://github.com/liuzc/LeaveIt) 主题。 -它的原型基于 [LoveIt 主题](https://github.com/dillonzq/LoveIt),[KeepIt 主题](https://github.com/Fastbyte01/KeepIt) 和 [LeaveIt 主题](https://github.com/liuzc/LeaveIt)。[^1] +## 即时预览 -![Hugo Theme FixIt](https://fixit.lruihao.cn/images/apple-devices-preview.webp) +

+ 💟 Production | ❇️ Preview | 🚼 Demo | 🆕 Starter +
+
+ 更多 «FixIt» 的例子参见 这里。 +

## 主题文档 -1. [安装篇](https://fixit.lruihao.cn/zh-cn/documentation/installation/) -2. [入门篇](https://fixit.lruihao.cn/zh-cn/documentation/getting-started/) -3. [内容管理](https://fixit.lruihao.cn/zh-cn/documentation/content-management/) -4. [进阶篇](https://fixit.lruihao.cn/zh-cn/documentation/advanced/) +前往 [快速上手](https://fixit.lruihao.cn/zh-cn/documentation/getting-started/quick-start/) 页面,了解如何使用 FixIt 主题创建一个新网站的详细步骤。 -或者在本地运行 [文档站点](https://fixit.lruihao.cn/zh-cn/),更多细节详见 [hugo-fixit/docs](https://github.com/hugo-fixit/docs)。 +大纲:[安装篇](https://fixit.lruihao.cn/zh-cn/documentation/installation/) ➜ [入门篇](https://fixit.lruihao.cn/zh-cn/documentation/getting-started/) ➜ [内容管理](https://fixit.lruihao.cn/zh-cn/documentation/content-management/) ➜ [进阶篇](https://fixit.lruihao.cn/zh-cn/documentation/advanced/) ## 模板仓库 -- [hugo-fixit/hugo-fixit-start](https://github.com/hugo-fixit/hugo-fixit-start/generate) -- [hugo-fixit/hugo-fixit-start1](https://github.com/hugo-fixit/hugo-fixit-start1/generate) -- [hugo-fixit/docs](https://github.com/hugo-fixit/docs/generate) -- [Lruihao/hugo-blog](https://github.com/Lruihao/hugo-blog/generate) +点击以下链接使用模板生成一个新的仓库: -## 谁在用 FixIt +| 模板仓库 | 生成链接 | +| :----------------------------------------- | :-------------------------------: | +| [hugo-fixit/hugo-fixit-starter][starter] | [点击生成][starter:generate] | +| [hugo-fixit/hugo-fixit-starter1][starter1] | [点击生成][starter1:generate] | +| [hugo-fixit/docs][docs] | [点击生成][docs:generate] | +| [Lruihao/hugo-blog][lruihao-blog] | [点击生成][lruihao-blog:generate] | -为了直观地浏览主题特性,这里有一些基于 **FixIt** 主题渲染的 [预览网站](https://fixit.lruihao.cn/zh-cn/friends/)。 +[starter]: https://github.com/hugo-fixit/hugo-fixit-starter +[starter:generate]: https://github.com/hugo-fixit/hugo-fixit-starter/generate +[starter1]: https://github.com/hugo-fixit/hugo-fixit-starter1 +[starter1:generate]: https://github.com/hugo-fixit/hugo-fixit-starter1/generate +[docs]: https://github.com/hugo-fixit/docs +[docs:generate]: https://github.com/hugo-fixit/docs/generate +[lruihao-blog]: https://github.com/Lruihao/hugo-blog +[lruihao-blog:generate]: https://github.com/Lruihao/hugo-blog/generate + + ## 特性 @@ -96,17 +116,17 @@ - 支持多种**注释**的 shortcode - 支持**自定义样式**的 shortcode - 支持**自定义脚本**的 shortcode +- 支持**自定义模板块** - 支持基于 [TypeIt](https://typeitjs.com/) 的**打字动画** shortcode - 支持基于 [cookieconsent](https://github.com/osano/cookieconsent) 的 **Cookie 许可横幅** - 支持基于 [cell-watermark](https://github.com/Lruihao/watermark) 的**网页水印** - 支持基于 [pangu.js](https://github.com/vinta/pangu.js) 的**中文排版** - 支持本地**缓存远程图床图片** -- 高**扩展性** - …… ### 主题组件 -FixIt 主题旨在在 **简洁性** 和 **可扩展性** 之间取得平衡。为此,我们开发了一系列额外的 [Hugo 主题组件](https://fixit.lruihao.cn/zh-cn/components/) 供用户选择。 +FixIt 主题旨在在**简洁性**和**可扩展性**之间取得平衡。为此,我们开发了一系列额外的 [Hugo 主题组件](https://fixit.lruihao.cn/zh-cn/components/) 供用户选择。 ## 多语言和国际化 @@ -130,6 +150,10 @@ FixIt 支持下列语言: [语言兼容性](https://fixit.lruihao.cn/zh-cn/theme-documentation-basics/#language-compatibility) +## 镜像 + +Gitee 镜像仓库: + ## 社区支持 所有的反馈都是欢迎的!详见 [Discussions][discussions]、[Pull requests][pulls] 和 [Issues][issues]。 @@ -152,17 +176,12 @@ FixIt 支持下列语言: ## 参与贡献 -- [Hugo FixIt 路线图](https://github.com/orgs/hugo-fixit/projects/2) - -请参阅 [CONTRIBUTING.md](CONTRIBUTING.md) 以了解贡献该项目的基本信息。 - -确保在贡献和参与讨论时遵守 [CODE_OF_CONDUCT.md](CODE_OF_CONDUCT.md)。 +我们欢迎你加入 FixIt 的开发,贡献出你的一份力量。请看开源 [贡献指南](CONTRIBUTING.md)。 🤗 -**贡献时,请先通过此存储库上的问题讨论你希望进行的更改,然后再进行实际更改**。 +你也可以随时向我们的 [官方插件](https://github.com/hugo-fixit) 提交 Issue 或 Pull Request。 -## 镜像 - -- Gitee 镜像仓库: +> [!note] +> 在贡献时,请先通过此存储库上的讨论来讨论你希望进行的更改,然后再进行实际更改。 ## 致谢 @@ -230,6 +249,3 @@ FixIt 根据 **MIT** 许可协议授权。更多信息请查看 [LICENSE 文件] ## 作者 [Lruihao](https://github.com/Lruihao "在 GitHub 上关注我") - - -[^1]: 主题名称趣谈:“leave it, keep it,love it,fix it”。出现又离开,爱而不得。这像不像那该死的爱情和 BUG 呢?🤣 diff --git a/archetypes/post-bundle/index.md b/archetypes/post-bundle/index.md index 35dc82729..71ca9297e 100644 --- a/archetypes/post-bundle/index.md +++ b/archetypes/post-bundle/index.md @@ -20,8 +20,8 @@ categories: - draft hiddenFromHomePage: false hiddenFromSearch: false -hiddenFromRss: false hiddenFromRelated: false +hiddenFromFeed: false summary: resources: - name: featured-image diff --git a/archetypes/posts.md b/archetypes/posts.md index 231b1daa2..e0362aa5c 100644 --- a/archetypes/posts.md +++ b/archetypes/posts.md @@ -20,8 +20,8 @@ categories: - draft hiddenFromHomePage: false hiddenFromSearch: false -hiddenFromRss: false hiddenFromRelated: false +hiddenFromFeed: false summary: resources: - name: featured-image diff --git a/build/changelog/template.hbs b/build/changelog/template.hbs index fd06cf42b..f394aba32 100644 --- a/build/changelog/template.hbs +++ b/build/changelog/template.hbs @@ -15,7 +15,7 @@ All notable changes to this project will be documented in this file. {{/if}} {{!-- List commits with `Breaking change: ` somewhere in the message --}} - {{#commit-list commits heading='### :boom: Breaking Changes' message='^(Breaking change|BREAKING CHANGE):'}} + {{#commit-list commits heading='### :boom: Breaking Changes' message='(:boom:|Breaking change:|BREAKING CHANGE:)'}} - {{subject}} [`{{shorthash}}`]({{href}}) by {{githubUser author}} {{/commit-list}} diff --git a/build/update-version.js b/build/update-version.js index b18a2114b..378f32420 100644 --- a/build/update-version.js +++ b/build/update-version.js @@ -39,8 +39,8 @@ const latestVersion = stage === 'version' ? version : devVersion; const lastVersion = initHtml.match(/v\d+\.\d+\.\d+(-\w+)?/)[0]; const newInitHtml = initHtml.replace(/v\d+\.\d+\.\d+(-\w+)?/, `v${latestVersion}`); fs.writeFileSync(initHtmlPath, newInitHtml); -// Add the updated file to the git stage -execSync('git add .'); +// Add the updated files to the git stage +execSync('git add layouts/partials/init/index.html package.json package-lock.json'); console.log(`Update the FixIt version from ${lastVersion} to v${latestVersion}.`); export default latestVersion; diff --git a/hugo.toml b/hugo.toml index 2c62cea4a..619eb046f 100644 --- a/hugo.toml +++ b/hugo.toml @@ -231,12 +231,8 @@ enableEmoji = true # ------------------------------------------------------------------------------------- [mediaTypes] - # Options to make output .md files - [mediaTypes."text/markdown"] - suffixes = ["md"] - # Options to make output .txt files - [mediaTypes."text/plain"] - suffixes = ["txt"] + # [mediaTypes."application/feed+json"] + # suffixes = ["json"] # ------------------------------------------------------------------------------------- # Output Format Definitions @@ -244,11 +240,6 @@ enableEmoji = true # ------------------------------------------------------------------------------------- [outputFormats] - # Options to make output .md files - [outputFormats.MarkDown] - mediaType = "text/markdown" - isPlainText = true - isHTML = false # FixIt 0.3.0 | NEW Options to make output /archives/index.html file [outputFormats.archives] path = "archives" @@ -257,6 +248,7 @@ enableEmoji = true isPlainText = false isHTML = true permalinkable = true + notAlternative = true # FixIt 0.3.0 | NEW Options to make output /offline/index.html file [outputFormats.offline] path = "offline" @@ -265,18 +257,29 @@ enableEmoji = true isPlainText = false isHTML = true permalinkable = true + notAlternative = true # FixIt 0.3.0 | NEW Options to make output readme.md file - [outputFormats.README] + [outputFormats.readme] baseName = "readme" mediaType = "text/markdown" isPlainText = true isHTML = false + notAlternative = true # FixIt 0.3.0 | CHANGED Options to make output baidu_urls.txt file [outputFormats.baidu_urls] baseName = "baidu_urls" mediaType = "text/plain" isPlainText = true isHTML = false + notAlternative = true + # FixIt 0.3.10 | NEW Options to make output search.json file + [outputFormats.search] + baseName = "search" + mediaType = "application/json" + rel = "search" + isPlainText = true + isHTML = false + permalinkable = true # ------------------------------------------------------------------------------------- # Customizing Output Formats @@ -284,17 +287,17 @@ enableEmoji = true # ------------------------------------------------------------------------------------- # Options to make hugo output files, the optional values are below: -# home: ["HTML", "RSS", "JSON", "archives", "offline", "README", "baidu_urls"] -# page: ["HTML", "MarkDown"] -# section: ["HTML", "RSS"] -# taxonomy: ["HTML", "RSS"] -# term: ["HTML", "RSS"] +# home = ["html", "rss", "archives", "offline", "readme", "baidu_urls", "search"] +# page = ["html", "markdown"] +# section = ["html", "rss"] +# taxonomy = ["html"] +# term = ["html", "rss"] [outputs] - home = ["HTML", "RSS", "JSON", "archives"] - page = ["HTML", "MarkDown"] - section = ["HTML", "RSS"] - taxonomy = ["HTML"] - term = ["HTML", "RSS"] + home = ["html", "rss", "archives", "search"] + page = ["html", "markdown"] + section = ["html", "rss"] + taxonomy = ["html"] + term = ["html", "rss"] # ------------------------------------------------------------------------------------- # Taxonomies Configuration @@ -497,8 +500,12 @@ enableEmoji = true paginate = 20 # date format (month and day) dateFormat = "01-02" - # amount of RSS pages - rss = 10 + # FixIt 0.3.10 | NEW Section feed config for RSS, Atom and JSON feed. + [params.section.feed] + # The number of posts to include in the feed. If set to -1, all posts. + limit = -1 + # whether to show the full text content in feed. + fullText = false # FixIt 0.2.13 | NEW recently updated pages config # TODO refactor to support archives, section, taxonomy and term [params.section.recentlyUpdated] @@ -507,14 +514,18 @@ enableEmoji = true days = 30 maxCount = 10 - # List (category or tag) page config + # Term list (category or tag) page config [params.list] # special amount of posts in each list page paginate = 20 # date format (month and day) dateFormat = "01-02" - # amount of RSS pages - rss = 10 + # FixIt 0.3.10 | NEW Term list feed config for RSS, Atom and JSON feed. + [params.list.feed] + # The number of posts to include in the feed. If set to -1, all posts. + limit = -1 + # whether to show the full text content in feed. + fullText = false # FixIt 0.2.17 | NEW TagCloud config for tags page [params.tagcloud] @@ -526,8 +537,6 @@ enableEmoji = true # Home page config [params.home] - # amount of RSS pages - rss = 10 # Home page profile [params.home.profile] enable = false @@ -807,6 +816,13 @@ enableEmoji = true # ["barber-shop", "big-counter", "bounce", "center-atom", "center-circle", "center-radar", "center-simple", # "corner-indicator", "fill-left", "flash", "flat-top", "loading-bar", "mac-osx", "material", "minimal"] theme = "minimal" + + # FixIt 0.3.10 | NEW Global Feed config for RSS, Atom and JSON feed. + [params.feed] + # The number of posts to include in the feed. If set to -1, all posts. + limit = 10 + # whether to show the full text content in feed. + fullText = true # FixIt 0.2.15 | NEW Developer options # Select the scope named `public_repo` to generate personal access token, @@ -824,10 +840,10 @@ enableEmoji = true hiddenFromHomePage = false # whether to hide a page from search results hiddenFromSearch = false - # FixIt 0.3.0 | NEW whether to hide a page from RSS feed - hiddenFromRss = false # FixIt 0.3.0 | NEW whether to hide a page from related posts hiddenFromRelated = false + # FixIt 0.3.10 | NEW whether to hide a page from RSS, Atom and JSON feed + hiddenFromFeed = false # whether to enable twemoji twemoji = false # FixIt 0.2.18 | CHANGED whether to enable lightgallery @@ -850,8 +866,6 @@ enableEmoji = true linkToEdit = true # FixIt 0.3.0 | NEW whether to show link to report issue for the post linkToReport = true - # whether to show the full text content in RSS - rssFullText = false # FixIt 0.3.10 | CHANGED Page style ["narrow", "normal", "wide", ...] pageStyle = "normal" # FixIt 0.2.17 | CHANGED Auto Bookmark Support diff --git a/images/apple-devices-preview.png b/images/apple-devices-preview.png new file mode 100644 index 000000000..2b79b95e1 Binary files /dev/null and b/images/apple-devices-preview.png differ diff --git a/images/apple-devices-preview.webp b/images/apple-devices-preview.webp deleted file mode 100644 index a733de2c6..000000000 Binary files a/images/apple-devices-preview.webp and /dev/null differ diff --git a/layouts/index.archives.html b/layouts/_default/home.archives.html similarity index 100% rename from layouts/index.archives.html rename to layouts/_default/home.archives.html diff --git a/layouts/index.baidu_urls.txt b/layouts/_default/home.baidu_urls.txt similarity index 100% rename from layouts/index.baidu_urls.txt rename to layouts/_default/home.baidu_urls.txt diff --git a/layouts/index.html b/layouts/_default/home.html similarity index 100% rename from layouts/index.html rename to layouts/_default/home.html diff --git a/layouts/index.offline.html b/layouts/_default/home.offline.html similarity index 100% rename from layouts/index.offline.html rename to layouts/_default/home.offline.html diff --git a/layouts/index.readme.md b/layouts/_default/home.readme.md similarity index 100% rename from layouts/index.readme.md rename to layouts/_default/home.readme.md diff --git a/layouts/_default/home.search.json b/layouts/_default/home.search.json new file mode 100644 index 000000000..29336eff8 --- /dev/null +++ b/layouts/_default/home.search.json @@ -0,0 +1,46 @@ +{{- if .Site.Params.search.enable -}} + {{- $index := slice -}} + {{- $pages := where .Site.RegularPages "Params.password" "eq" nil -}} + {{- if .Site.Params.page.hiddenFromSearch -}} + {{- $pages = where $pages "Params.hiddenfromsearch" false -}} + {{- else -}} + {{- $pages = where $pages "Params.hiddenfromsearch" "!=" true -}} + {{- end -}} + {{- range $pages -}} + {{- $uri := .RelPermalink -}} + {{- if $.Site.Params.search.absoluteURL -}} + {{- $uri = .Permalink -}} + {{- end -}} + {{- $meta := dict "uri" $uri "title" .Title "tags" .Params.tags "categories" .Params.categories -}} + {{- $meta = $.Site.Params.dateFormat | default "2006-01-02" | .PublishDate.Format | dict "date" | merge $meta -}} + {{- with .Description -}} + {{- $index = $index | append (dict "content" . "objectID" $uri | merge $meta) -}} + {{- end -}} + {{- $params := .Params | merge $.Site.Params.page -}} + {{/* Extended Markdown syntax */}} + {{- $content := dict "Content" .Content "Ruby" $params.ruby "Fraction" $params.fraction "Fontawesome" $params.fontawesome | partial "function/content.html" -}} + {{/* Remove line number for code */}} + {{- $content = $content | replaceRE ` *\d*\n?` "" -}} + {{- range $i, $contenti := split $content "

{{- /* Featured image */ -}} {{- $image := $params.featuredimagepreview | default $params.featuredimage -}} + {{- with $image }} + {{- if not (hasPrefix . "/") }} + {{- $image = (printf "%s%s" $.RelPermalink .) | safeURL }} + {{- end }} + {{- $image = $image | relURL }} + {{- end }} {{- with .Resources.GetMatch "featured-image" -}} {{- $image = .RelPermalink -}} {{- end -}} diff --git a/layouts/index.json b/layouts/index.json deleted file mode 100644 index 67627cdff..000000000 --- a/layouts/index.json +++ /dev/null @@ -1,46 +0,0 @@ -{{- if .Site.Params.search.enable -}} - {{- $index := slice -}} - {{- $pages := where .Site.RegularPages "Params.password" "eq" nil -}} - {{- if .Site.Params.page.hiddenFromSearch -}} - {{- $pages = where $pages "Params.hiddenfromsearch" false -}} - {{- else -}} - {{- $pages = where $pages "Params.hiddenfromsearch" "!=" true -}} - {{- end -}} - {{- range $pages -}} - {{- $uri := .RelPermalink -}} - {{- if $.Site.Params.search.absoluteURL -}} - {{- $uri = .Permalink -}} - {{- end -}} - {{- $meta := dict "uri" $uri "title" .Title "tags" .Params.tags "categories" .Params.categories -}} - {{- $meta = $.Site.Params.dateFormat | default "2006-01-02" | .PublishDate.Format | dict "date" | merge $meta -}} - {{- with .Description -}} - {{- $index = $index | append (dict "content" . "objectID" $uri | merge $meta) -}} - {{- end -}} - {{- $params := .Params | merge $.Site.Params.page -}} - {{/* Extended Markdown syntax */}} - {{- $content := dict "Content" .Content "Ruby" $params.ruby "Fraction" $params.fraction "Fontawesome" $params.fontawesome | partial "function/content.html" -}} - {{/* Remove line number for code */}} - {{- $content = $content | replaceRE ` *\d*\n?` "" -}} - {{- range $i, $contenti := split $content "

- - - {{- .Site.Title -}} - - - {{- .Permalink -}} - - - {{- .Site.Params.description | default .Site.Title -}} - - Hugo -- gohugo.io - {{- with .Site.LanguageCode -}} - - {{- . -}} - - {{- end -}} - {{- with .Site.Params.author.email -}} - - {{- . }}{{ with $.Site.Params.author.name }} ({{ . }}){{ end -}} - - - {{- . }}{{ with $.Site.Params.author.name }} ({{ . }}){{ end -}} - - {{- end -}} - {{- with .Site.Copyright -}} - - {{- . -}} - - {{- end -}} - {{- if not .Date.IsZero -}} - - {{- .Date.Format "Mon, 02 Jan 2006 15:04:05 -0700" -}} - - {{- end -}} - {{ with .OutputFormats.Get "RSS" }} - {{ printf "" .Permalink .MediaType | safeHTML }} - {{ end }} - {{- range .Scratch.Get "mainSectionPages" | first (.Site.Params.home.rss | default 10) -}} - {{- /* TODO 0.4.0 待重构为去掉 `.page` 改用 hugo 推荐的 .Param 方法获取页面参数 */ -}} - {{- $params := .Params | merge site.Params.page -}} - {{- if $params.password | or $params.hiddenFromRss }}{{ continue }}{{ end -}} - {{- dict "Page" . "Site" .Site | partial "rss/item.html" -}} - {{- end -}} - - diff --git a/layouts/partials/assets.html b/layouts/partials/assets.html index ebdb2a003..54ff1e5f0 100644 --- a/layouts/partials/assets.html +++ b/layouts/partials/assets.html @@ -16,7 +16,7 @@ {{- dict "Source" $source "Fingerprint" $fingerprint "Defer" true | dict "Scratch" .Scratch "Data" | partial "scratch/script.html" -}} {{- $config = dict "type" "algolia" "algoliaIndex" $search.algolia.index "algoliaAppID" $search.algolia.appID "algoliaSearchKey" $search.algolia.searchKey | dict "search" | merge $config -}} {{- else if eq $search.type "fuse" -}} - {{- with .Site.Home.OutputFormats.Get "json" -}} + {{- with .Site.Home.OutputFormats.Get "search" -}} {{- $config = dict "type" "fuse" "fuseIndexURL" .RelPermalink | dict "search" | merge $config -}} {{- end -}} {{- $source := $cdn.fuseJS | default "lib/fuse/fuse.min.js" -}} diff --git a/layouts/partials/feed/rss.html b/layouts/partials/feed/rss.html new file mode 100644 index 000000000..c9aa16fa8 --- /dev/null +++ b/layouts/partials/feed/rss.html @@ -0,0 +1,72 @@ +{{- $pages := .Pages -}} +{{- /* Front matter: password */ -}} +{{- $pages = where $pages "Params.password" "eq" nil -}} +{{- /* Front matter: hiddenFromFeed */ -}} +{{- $pages = where $pages "Params.hiddenFromFeed" "ne" true -}} +{{- if ge .Config.limit 1 -}} + {{- $pages = $pages | first .Config.limit -}} +{{- end -}} +{{- $length := $pages.Len -}} +{{- /* TODO 文章内图片链接、分类、标签等处理 */ -}} + +{{- printf "" | safeHTML }} + + + {{ .Title }} + {{ .Permalink }} + {{ .Site.Params.description | default .Site.Title }} + Hugo {{ hugo.Version }} & FixIt {{ .Version }} + {{ .Site.Language.LanguageCode }}{{ with .Site.Params.author.email }} + {{.}}{{ with $.Site.Params.author.name }} ({{ . }}){{ end }}{{ end }}{{ with .Site.Params.author.email }} + {{ . }}{{ with $.Site.Params.author.name }} ({{ . }}){{ end }}{{ end }}{{ with .Site.Copyright }} + {{ . }}{{ end }}{{ if not .Date.IsZero }} + {{ (index $pages.ByLastmod.Reverse 0).Lastmod.Format "Mon, 02 Jan 2006 15:04:05 -0700" | safeHTML }}{{ end }} + {{- with .OutputFormats.Get "rss" }} + {{ printf "" .Permalink .MediaType | safeHTML }} + {{- end }} + {{- range $page := $pages }} + {{- $params := .Params | merge .Site.Params.Page }} + {{- $fullText := ((.Params.feed | default dict) | merge $.Config ).fullText }} + {{- $author := partial "function/get-author-map.html" .Params.author }} + {{- $image := $params.featuredimagepreview | default $params.featuredimage }} + {{- with $image }} + {{- if not (hasPrefix . "/") }} + {{- $image = (printf "%s%s" $page.RelPermalink .) | safeURL }} + {{- end }} + {{- $image = $image | absURL }} + {{- end }} + {{- with .Resources.GetMatch "featured-image" }} + {{- $image = .Permalink }} + {{- end }} + {{- with .Resources.GetMatch "featured-image-preview" }} + {{- $image = .Permalink }} + {{- end }} + + {{ .Title }} + {{ .Permalink }} + {{ .PublishDate.Format "Mon, 02 Jan 2006 15:04:05 -0700" | safeHTML }} + {{- with $author.email }}{{ . }}{{ with $author.name }} ({{ . }}){{ end }}{{ end }} + {{ .Permalink }} + {{- with .GetTerms "categories" }} + {{- range . }} + {{ .LinkTitle }} + {{- end }} + {{- end }} + {{- if $fullText }} + + {{- "]*>.*` "" | replaceRE `]*( /)?>` "" | safeHTML -}} */ -}} + {{- with $image }} + {{- $content = add (printf "%q" . "featured image" "no-referrer") $content | safeHTML }} + {{- end }} + {{- $content | transform.XMLEscape | safeHTML }} + {{- "]]>" | safeHTML -}} + + {{- else }} + {{ (.Summary | default .Description | default .Title) | transform.XMLEscape | safeHTML }} + {{- end }} + + {{- end }} + + diff --git a/layouts/partials/function/get-author-map.html b/layouts/partials/function/get-author-map.html new file mode 100644 index 000000000..a4433692f --- /dev/null +++ b/layouts/partials/function/get-author-map.html @@ -0,0 +1,46 @@ +{{- /* +Get author in map format. + +@param {String|Map} . the author name or map +@returns {Map} + +@example {{- $author := partial "function/get-author-map.html" .Params.author -}} +*/ -}} + +{{- if not (reflect.IsMap site.Params.author) -}} + {{- errorf "FixIt params error: site.Params.author must be a map, got %T." site.Params.author -}} +{{- end -}} + +{{- $default := dict "name" "" "link" "" "email" "" "avatar" "" -}} +{{- $author := site.Params.author | merge $default -}} +{{- $authorParam := dict -}} +{{- if reflect.IsMap . -}} + {{- $authorParam = . -}} +{{- else -}} + {{- with . -}} + {{- $authorParam = dict "name" . -}} + {{- end -}} +{{- end -}} + +{{- if isset $authorParam "name" | and (ne $authorParam.name site.Params.author.name) -}} + {{- $author = $authorParam | merge $default | merge $author -}} +{{- else -}} + {{- with $authorParam.link -}}{{ $author = dict "link" . | merge $author }}{{- end -}} + {{- with $authorParam.email -}}{{ $author = dict "email" . | merge $author }}{{- end -}} + {{- with $authorParam.avatar -}}{{ $author = dict "avatar" . | merge $author }}{{- end -}} +{{- end -}} + +{{- $gravatar := site.Params.gravatar -}} +{{- if $gravatar.enable | and $author.email -}} + {{- with $gravatar -}} + {{- /* TODO migrate to gravatar */ -}} + {{- $author = dict "avatar" (printf "https://%v/avatar/%v?s=32&d=%v" + (path.Clean .Host | default "www.gravatar.com") + (md5 $author.email) + (.Style | default "")) + | merge $author + -}} + {{- end -}} +{{- end -}} + +{{- return $author -}} diff --git a/layouts/partials/head/link.html b/layouts/partials/head/link.html index a48979ba7..45eb2a9b9 100644 --- a/layouts/partials/head/link.html +++ b/layouts/partials/head/link.html @@ -1,5 +1,9 @@ {{- $cdn := .Scratch.Get "cdn" | default dict -}} {{- $fingerprint := .Scratch.Get "fingerprint" -}} +{{- $title := printf "%s %s %s" .Title .Site.Params.titleDelimiter .Site.Title -}} +{{- if .IsHome -}} + {{- $title = site.Title -}} +{{- end -}} {{- if not .Site.Params.app.noFavicon -}} {{- with .Site.Params.app.svgFavicon -}} @@ -18,17 +22,18 @@ {{- end -}} {{- end -}} - -{{- if .Prev -}} - + +{{- with .Prev -}} + {{- end -}} -{{- if .Next -}} - +{{- with .Next -}} + {{- end -}} - -{{- with .OutputFormats.Get "RSS" -}} - - +{{- range .AlternativeOutputFormats -}} + {{- printf `` .Rel .MediaType.Type .Permalink $title | safeHTML -}} +{{- end -}} +{{- with .OutputFormats.Get "feed" -}} + {{- end -}} {{- /* style.min.css */ -}} diff --git a/layouts/partials/head/meta.html b/layouts/partials/head/meta.html index dadc6ceaa..03c361e2c 100644 --- a/layouts/partials/head/meta.html +++ b/layouts/partials/head/meta.html @@ -1,8 +1,7 @@ -{{- $params := partial "function/params.html" -}} +{{- $author := partial "function/get-author-map.html" .Params.author -}} - - - + + {{- $keywords := .Keywords -}} {{- if not $keywords -}} @@ -13,12 +12,15 @@ {{- end -}} {{- end -}} {{- with $keywords -}} - + {{- end -}} {{- template "_internal/schema.html" . -}} {{- template "_internal/opengraph.html" . -}} {{- template "_internal/twitter_cards.html" . -}} +{{- with .Site.Params.social.Twitter -}} + +{{- end -}} diff --git a/layouts/partials/init/index.html b/layouts/partials/init/index.html index ea2a9a496..86700be66 100644 --- a/layouts/partials/init/index.html +++ b/layouts/partials/init/index.html @@ -1,4 +1,4 @@ -{{- .Scratch.Set "version" "v0.3.10-c936e541" -}} +{{- .Scratch.Set "version" "v0.3.10-08d4c12c" -}} {{- .Scratch.Set "this" dict -}} {{- partial "init/detection-env.html" . -}} diff --git a/layouts/partials/rss/item.html b/layouts/partials/rss/item.html deleted file mode 100644 index bc86c4abf..000000000 --- a/layouts/partials/rss/item.html +++ /dev/null @@ -1,51 +0,0 @@ -{{- $params := .Page.Params | merge .Site.Params.Page -}} -{{- $authorName := .Site.Params.author.name | default (T "single.author") -}} -{{- with .Params.author -}} - {{- if reflect.IsMap . -}} - {{- $authorName = cond (isset . "name") .name $authorName -}} - {{- else -}} - {{- $authorName = . -}} - {{- end -}} -{{- end -}} -{{- $image := $params.featuredimagepreview | default $params.featuredimage -}} -{{- with .Page.Resources.GetMatch "featured-image" -}} - {{- $image = .Permalink -}} -{{- end -}} -{{- with .Page.Resources.GetMatch "featured-image-preview" -}} - {{- $image = .Permalink -}} -{{- end -}} - - - - {{- .Page.Title -}} - - - {{- .Page.Permalink -}} - - - {{- .Page.Date.Format "Mon, 02 Jan 2006 15:04:05 -0700" -}} - - {{ $authorName }} - - {{- .Page.Permalink -}} - - - {{- " - {{- dict "Src" . "Title" $.Page.Description "Alt" $.Page.Title "Loading" "eager" "Referrerpolicy" "no-referrer" | partial "plugin/image.html" -}} - - {{- end -}} - {{- $content := .Page.Description -}} - {{- if $params.rssFullText -}} - {{- $content = dict "Content" .Page.Content "Ruby" $params.ruby "Fraction" $params.fraction "Fontawesome" $params.fontawesome | partial "function/content.html" -}} - {{- else -}} - {{- with .Page.Summary -}} - {{- $content = dict "Content" . "Ruby" $params.ruby "Fraction" $params.fraction "Fontawesome" $params.fontawesome | partial "function/content.html" -}} - {{- end -}} - {{- end -}} - {{/* {{- $content | replaceRE `]*>.*` "" | replaceRE `]*( /)?>` "" | safeHTML -}} */}} - {{- $content | safeHTML -}} - {{- "]]>" | safeHTML -}} - - diff --git a/layouts/partials/single/post-author.html b/layouts/partials/single/post-author.html index 61d0d246d..d81308c78 100644 --- a/layouts/partials/single/post-author.html +++ b/layouts/partials/single/post-author.html @@ -1,39 +1,11 @@ {{- $params := .Params | merge .Site.Params.page -}} - -{{- /* Author data patch */ -}} -{{- $authorDefault := dict "name" "" "link" "" "email" "" "avatar" "" -}} -{{- $author := .Site.Params.author | merge $authorDefault -}} -{{- $authorPost := dict -}} -{{- if reflect.IsMap $params.author -}} - {{- $authorPost = $params.author -}} -{{- else if isset $params "author" -}} - {{- warnf "检测到你的 author 参数格式错误,请参考主题文档设置为正常的格式。" -}} - {{- $authorPost = dict "name" $params.author -}} -{{- end -}} -{{- if isset $authorPost "name" | and (ne $authorPost.name .Site.Params.author.name) -}} - {{- $author = $authorPost | merge $authorDefault | merge $author -}} -{{- else -}} - {{- with $authorPost.link -}}{{ $author = dict "link" . | merge $author }}{{- end -}} - {{- with $authorPost.email -}}{{ $author = dict "email" . | merge $author }}{{- end -}} - {{- with $authorPost.avatar -}}{{ $author = dict "avatar" . | merge $author }}{{- end -}} -{{- end -}} - -{{- $gravatar := .Site.Params.gravatar -}} -{{- if $gravatar.enable | and $author.email -}} - {{- with $gravatar -}} - {{- $author = dict "avatar" (printf "https://%v/avatar/%v?s=32&d=%v" - (path.Clean .Host | default "www.gravatar.com") - (md5 $author.email) - (.Style | default "")) - | merge $author - -}} - {{- end -}} -{{- end -}} +{{- $author := partial "function/get-author-map.html" .Params.author -}} {{- .Store.Set "author" $author -}}