new feature: external link post

This commit is contained in:
Mivinci 2022-01-30 15:12:29 +08:00
parent e664d42571
commit b4031adcd6
8 changed files with 53 additions and 5 deletions

View file

@ -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).

View file

@ -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

View file

@ -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
---

View file

@ -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
---

View file

@ -0,0 +1,7 @@
---
author: XJJ
title: External Link Post
date: 2021-07-17T10:52:59+08:00
description:
link: https://gohugo.io
---

View file

@ -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"]

View file

@ -1,5 +1,9 @@
<div class="flex justify-between sm:flex-col-reverse my-4 sm:mb-6 sm:mt-3">
{{ if .Page.Params.link }}
<a class="" href="{{ .Page.Params.link }}">{{ .Title }}</a>
{{ else }}
<a class="" href="{{ .RelPermalink }}">{{ .Title }}</a>
{{ end }}
{{ if .Site.Params.displayDate }}
<div class="sm:mb-2 sm:text-sm">{{ dateFormat .Site.Params.timeformat .Date }}</div>
{{ end }}

View file

@ -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]