Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: bring the post.excerpt parameter back #1009

Merged
merged 1 commit into from
Dec 2, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion exampleSite/config/_default/params.toml
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,7 @@ viewer = true # Image Viewer
lineNos = false # true/false represents that show/hide the line numbers by default.

[post]
# excerpt = "description"
# excerpt = "" # uncomment to use summaries as excerpts.
# excerptMaxLength = 120
# copyright = false # Whether to display copyright section on each post.
# plainifyExcerpt = false # Format excerpt in HTML if false.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -122,7 +122,7 @@ The site parameters are located in `config/_default/params.toml` by default.
| `codeBlock.lineNos` | Boolean | `true` | `true`/`false` represents that show/hide the line numbers by default.
| **Post**
| `post` | Object | - |
| ~~`post.excerpt`~~ | String | `Description` | Deleted since `v1.2.1`, the description will be used as the excerpt if not empty.
| `post.excerpt` | String | `Description` | The description will be used as the excerpt if not empty, to use summaries as excerpt, you'll need to set it as _empty string_ explicitly.
| `post.excerptMaxLength` | Integer | `320` |
| `post.copyright` | Boolean | `true` | Whether to display copyright section on each post.
| `post.plainifyExcerpt` | Boolean | `true` | Format excerpt in HTML if `false`.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -125,7 +125,7 @@ authors = ["RazonYang"]
| `codeBlock.lineNos` | Boolean | `true` | `true`/`false` 表示默认情况下显示/隐藏行号。
| **Post**
| `post` | Object | - |
| ~~`post.excerpt`~~ | String | `Description` | 自 `v1.2.1` 删除,若 Description 不为空则作为摘要。
| `post.excerpt` | String | `Description` | 若 Description 不为空则作为摘要,若需要使用 Summaries 作为摘要,你需要显式地将其设为**空字符串**
| `post.excerptMaxLength` | Integer | `320` |
| `post.copyright` | Boolean | `true` | 是否在每个帖子上显示版权部分
| `post.plainifyExcerpt` | Boolean | `true` | `false` 则格式化摘要为 HTML。
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -125,7 +125,7 @@ authors = ["RazonYang"]
| `codeBlock.lineNos` | Boolean | `true` | `true`/`false` 表示默認情況下顯示/隱藏行號。
| **Post**
| `post` | Object | - |
| ~~`post.excerpt`~~ | String | `Description` | 自 `v1.2.1` 刪除,若 Description 不為空則作為摘要
| `post.excerpt` | String | `Description` | 如果 Description 不為空則作為摘要,若需要使用 Summaries 作為摘要,你需要明確地將其設為**空字串**
| `post.excerptMaxLength` | Integer | `320` |
| `post.copyright` | Boolean | `true` | 是否在每個帖子上顯示版權部分
| `post.plainifyExcerpt` | Boolean | `true` | `false` 則格式化摘要為 HTML。
Expand Down
2 changes: 1 addition & 1 deletion exampleSite/content/docs/content/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -107,7 +107,7 @@ $ hugo new posts/new-post/index.zh-cn.md

## Summaries Selection Order

1. If the `description` is not empty, then it'll be used.
1. If the `description` is not empty, then it'll be used, to use summaries all the time, you should set the `post.excerpt` as _empty string_ explicitly.
1. Manual splitting via <code>&lt;!--more--&gt;</code>.
1. If `summary` on front matter isn't empty, then `summary` will be selected.
1. The text of content will be cut off by `post.excerptMaxLength` and formatted in plain text or HTML when `post.plainifyExcerpt = true`.
Expand Down
2 changes: 1 addition & 1 deletion exampleSite/content/docs/content/index.zh-hans.md
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,7 @@ $ hugo new posts/new-post/index.zh-cn.md

## 摘要选择顺序

1. If the `description` is not empty, then it'll be used.
1. If the `description` is not empty, then it'll be used, to use summaries all the time, you should set the `post.excerpt` as _empty string_ explicitly.
1. Manual splitting via <code>&lt;!--more--&gt;</code>.
1. If `summary` on front matter isn't empty, then `summary` will be selected.
1. The text of content will be cut off by `post.excerptMaxLength` and formatted in plain text or HTML when `post.plainifyExcerpt = true`.
Expand Down
2 changes: 1 addition & 1 deletion exampleSite/content/docs/content/index.zh-hant.md
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,7 @@ $ hugo new posts/new-post/index.zh-tw.md

## 摘要選擇順序

1. If the `description` is not empty, then it'll be used.
1. If the `description` is not empty, then it'll be used, to use summaries all the time, you should set the `post.excerpt` as _empty string_ explicitly.
1. Manual splitting via <code>&lt;!--more--&gt;</code>.
1. If `summary` on front matter isn't empty, then `summary` will be selected.
1. The text of content will be cut off by `post.excerptMaxLength` and formatted in plain text or HTML when `post.plainifyExcerpt = true`.
Expand Down
7 changes: 6 additions & 1 deletion layouts/partials/post/excerpt.html
Original file line number Diff line number Diff line change
@@ -1,9 +1,14 @@
{{- $key := "description" }}
{{- if isset site.Params.post "excerpt" }}
{{- $key = site.Params.post.excerpt }}
{{- end }}
{{- $useDescription := and (eq $key "description") .Description }}
{{- $anchor := "" }}
{{- if default false $.Site.Params.post.readMoreFromContent }}{{ $anchor = "#post-content-body" }}{{ end }}
{{- $readMoreButton := printf "<div><a class=\"btn btn-sm btn-outline-primary btn-read-more\" href=\"%s%s\">%s</a></div>" .RelPermalink $anchor (i18n "read_more") | safeHTML }}
{{- $content := "" }}
{{- $readMore := true }}
{{- if .Description }}
{{- if $useDescription }}
{{- $content = printf "<p>%s</p>" .Description | safeHTML }}
{{- else if strings.Contains .RawContent "<!--more-->" }}
{{- $content = .Summary }}
Expand Down