From b4031adcd6764e57844cd0e2d55aad93087f6a3a Mon Sep 17 00:00:00 2001 From: Mivinci <1366723936@qq.com> Date: Sun, 30 Jan 2022 15:12:29 +0800 Subject: [PATCH] new feature: external link post --- README.md | 18 ++++++++++++++++++ docs/README_CN.md | 21 ++++++++++++++++++++- exampleSite/content/about.md | 2 +- exampleSite/content/chinese.md | 2 +- exampleSite/content/link.md | 7 +++++++ exampleSite/content/placeholder-text.md | 2 +- layouts/partials/list.html | 4 ++++ theme.toml | 2 +- 8 files changed, 53 insertions(+), 5 deletions(-) create mode 100644 exampleSite/content/link.md diff --git a/README.md b/README.md index 897ab71..afa452f 100644 --- a/README.md +++ b/README.md @@ -50,6 +50,7 @@ Follow [exampleSite/config.toml](https://github.com/Mivinci/hugo-theme-minima/bl | title | string | Title of the post | | description | string | Description of the post | | date | string | Datetime when the post is written | +| link | string | If set, the post will redirect to an external link | | categories | array | Array of categories the posts belongs to | | series | array | Array of series the post belongs to | | tags | array | Array of tags the posts is related to | @@ -59,6 +60,23 @@ Follow [exampleSite/config.toml](https://github.com/Mivinci/hugo-theme-minima/bl | draft | bool | True if the post isn't already for publishing | | toc | bool | True if the post needs a ToC | +### External Link Post + +Use the `link` in the front matter to make a post a specific external link. Such external link post will redirect to the link provided. + +**Example** + +```yaml +--- +author: XJJ +title: External Link Post +date: 2021-07-17T10:52:59+08:00 +link: https://gohugo.io +--- +``` + +And when you click the title in the list page, you will be redireted to https://gohugo.io which's 🆒. + ### Feedback Feedbacks are welcome [here](https://github.com/Mivinci/hugo-theme-minima/issues). diff --git a/docs/README_CN.md b/docs/README_CN.md index 2b88e9c..d87de22 100644 --- a/docs/README_CN.md +++ b/docs/README_CN.md @@ -51,10 +51,11 @@ git clone https://github.com/mivinci/hugo-theme-minima.git themes/minima 为缩短博客网页的加载和渲染时间,minima 不支持如公式、图表、评论插件的全局配置,需要在每篇文章中设置是否启用相关插件,以下是 minima 目前支持的文章配置。 | 字段 | 类型 | 解释 | -| ----------- | ------ | --------------------------------- | +|:----------- |:------ |:--------------------------------- | | title | string | 文章标题 | | description | string | 文章简介,会显示在标题和正文之间 | | date | string | 文章创建日期 | +| link | string | 外部链接 | | categories | array | 文章分类 | | series | array | 文章专栏 | | tags | array | 文章标签 | @@ -64,6 +65,24 @@ git clone https://github.com/mivinci/hugo-theme-minima.git themes/minima | draft | bool | true:该篇文章为草稿,不会被打包 | | toc | bool | true:为该篇文章开启目录显示 | + +### 外部链接 + +可在 front matter 中通过设置 `link` 来创建外部链接。 + +**Example** + +```yaml +--- +author: XJJ +title: External Link Post +date: 2021-07-17T10:52:59+08:00 +link: https://gohugo.io +--- +``` + +当点击改文章题目时,会跳转到设置的链接地址 https://gohugo.io,🆒 + ### 反馈 欢迎在 [issues](https://github.com/Mivinci/hugo-theme-minima/issues) 下留言,或将问题详细描述发送到我的邮箱:mivinci@qq.com diff --git a/exampleSite/content/about.md b/exampleSite/content/about.md index 7e1b642..c6c879e 100644 --- a/exampleSite/content/about.md +++ b/exampleSite/content/about.md @@ -1,6 +1,6 @@ --- title: "About" -date: 2021-07-16T11:24:06+08:00 +date: 2021-07-10T11:24:06+08:00 draft: false type: about --- diff --git a/exampleSite/content/chinese.md b/exampleSite/content/chinese.md index 16ba62b..b18b6bd 100644 --- a/exampleSite/content/chinese.md +++ b/exampleSite/content/chinese.md @@ -1,7 +1,7 @@ --- author: XJJ title: 中文测试 -date: 2021-07-17T10:52:59+08:00 +date: 2021-07-16T10:52:59+08:00 description: comment: false --- diff --git a/exampleSite/content/link.md b/exampleSite/content/link.md new file mode 100644 index 0000000..4079c14 --- /dev/null +++ b/exampleSite/content/link.md @@ -0,0 +1,7 @@ +--- +author: XJJ +title: External Link Post +date: 2021-07-17T10:52:59+08:00 +description: +link: https://gohugo.io +--- \ No newline at end of file diff --git a/exampleSite/content/placeholder-text.md b/exampleSite/content/placeholder-text.md index 860d681..cf8700f 100644 --- a/exampleSite/content/placeholder-text.md +++ b/exampleSite/content/placeholder-text.md @@ -1,7 +1,7 @@ +++ author = "Hugo Authors" title = "Placeholder Text" -date = "2021-07-18T10:52:59+08:00" +date = "2021-07-11T10:52:59+08:00" description = "Lorem Ipsum Dolor Si Amet" toc = true categories = ["Markdown"] diff --git a/layouts/partials/list.html b/layouts/partials/list.html index 6d0b8a3..5377082 100644 --- a/layouts/partials/list.html +++ b/layouts/partials/list.html @@ -1,5 +1,9 @@
+{{ if .Page.Params.link }} +{{ .Title }} +{{ else }} {{ .Title }} +{{ end }} {{ if .Site.Params.displayDate }}
{{ dateFormat .Site.Params.timeformat .Date }}
{{ end }} diff --git a/theme.toml b/theme.toml index 52b5bf6..c226286 100644 --- a/theme.toml +++ b/theme.toml @@ -7,7 +7,7 @@ licenselink = "https://github.com/mivinci/minima/blob/master/LICENSE" description = "A Hugo port of Hexo Minima" homepage = "https://github.com/mivinci/hugo-theme-minima" tags = ["minimal", "clean", "blog", "responsive", "personal", "simple", "minimalist", "portfolio", "dark"] -features = ["Dark mode", "KaTeX", "Mermaid", "VSCode-style code highlighting"] +features = ["Dark mode", "KaTeX", "Mermaid", "VSCode-style code highlighting", "External link post"] min_version = "0.41.0" [author]