Skip to content

Commit

Permalink
🚧 WIP: add feed scoped config for section and list
Browse files Browse the repository at this point in the history
  • Loading branch information
Lruihao committed Aug 18, 2024
1 parent 7e22c33 commit e403560
Show file tree
Hide file tree
Showing 6 changed files with 28 additions and 21 deletions.
30 changes: 18 additions & 12 deletions hugo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -509,8 +509,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. Default is -1, which means 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]
Expand All @@ -519,14 +523,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. Default is -1, which means 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]
Expand All @@ -538,8 +546,6 @@ enableEmoji = true

# Home page config
[params.home]
# amount of RSS pages
rss = 10
# Home page profile
[params.home.profile]
enable = false
Expand Down Expand Up @@ -820,12 +826,12 @@ enableEmoji = true
# "corner-indicator", "fill-left", "flash", "flat-top", "loading-bar", "mac-osx", "material", "minimal"]
theme = "minimal"

# FixIt 0.3.10 | NEW Feed config for RSS, Atom and JSON feed.
# 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. Default is -1, which means all posts.
limit = -1
limit = 10
# whether to show the full text content in feed.
fullText = false
fullText = true

# FixIt 0.2.15 | NEW Developer options
# Select the scope named `public_repo` to generate personal access token,
Expand All @@ -843,10 +849,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
Expand Down
7 changes: 3 additions & 4 deletions layouts/partials/feed/rss.html
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,8 @@
{{- $pages = where $pages "Params.password" "eq" nil -}}
{{- /* Front matter: hiddenFromFeed */ -}}
{{- $pages = where $pages "Params.hiddenFromFeed" "ne" true -}}
{{- $limit := .Site.Params.feed.limit -}}
{{- if ge $limit 1 -}}
{{- $pages = $pages | first $limit -}}
{{- if ge .Config.limit 1 -}}
{{- $pages = $pages | first .Config.limit -}}
{{- end -}}
{{- $length := $pages.Len -}}
{{- /* TODO 文章内图片链接、分类、标签等处理 */ -}}
Expand All @@ -27,7 +26,7 @@
{{- end }}
{{- range $page := $pages }}
{{- $params := .Params | merge .Site.Params.Page }}
{{- $fullText := (.Param "feed").fullText }}
{{- $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 }}
Expand Down
2 changes: 1 addition & 1 deletion layouts/partials/init/index.html
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
{{- .Scratch.Set "version" "v0.3.10-5a715ca9" -}}
{{- .Scratch.Set "version" "v0.3.10-7e22c336" -}}
{{- .Scratch.Set "this" dict -}}

{{- partial "init/detection-env.html" . -}}
Expand Down
2 changes: 1 addition & 1 deletion layouts/rss.xml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
{{- $options := dict "Site" .Site "OutputFormats" .OutputFormats -}}
{{- $options := dict "Site" .Site "Config" .Site.Params.feed "OutputFormats" .OutputFormats -}}
{{- $options = dict "Permalink" .Permalink "Version" (.Scratch.Get "version") | merge $options -}}
{{- $options = dict "Title" .Site.Title "Pages" (.Scratch.Get "mainSectionPages") | merge $options -}}
{{- partial "feed/rss.html" $options -}}
3 changes: 2 additions & 1 deletion layouts/section/rss.xml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,8 @@
{{- if .Site.Params.withSiteTitle -}}
{{- $title = printf "%s %s %s" $title .Site.Params.titleDelimiter .Site.Title -}}
{{- end -}}
{{- $options := dict "Site" .Site "OutputFormats" .OutputFormats -}}
{{- $config := (.Params.feed | default dict) | merge .Site.Params.section.feed | merge .Site.Params.feed -}}
{{- $options := dict "Site" .Site "Config" $config "OutputFormats" .OutputFormats -}}
{{- $options = dict "Permalink" .Permalink "Version" (.Scratch.Get "version") | merge $options -}}
{{- $options = dict "Title" $title "Pages" .Pages | merge $options -}}
{{- partial "feed/rss.html" $options -}}
5 changes: 3 additions & 2 deletions layouts/taxonomy/rss.xml
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
{{- $title := printf "%s %s" .Title (T .Data.Singular | default .Data.Singular) -}}
{{- $title := printf "%s - %s" .Title (T .Data.Singular | default .Data.Singular) -}}
{{- if .Site.Params.withSiteTitle -}}
{{- $title = printf "%s %s %s" $title .Site.Params.titleDelimiter .Site.Title -}}
{{- end -}}
{{- $options := dict "Site" .Site "OutputFormats" .OutputFormats -}}
{{- $config := (.Params.feed | default dict) | merge .Site.Params.list.feed | merge .Site.Params.feed -}}
{{- $options := dict "Site" .Site "Config" $config "OutputFormats" .OutputFormats -}}
{{- $options = dict "Permalink" .Permalink "Version" (.Scratch.Get "version") | merge $options -}}
{{- $options = dict "Title" $title "Pages" .Pages | merge $options -}}
{{- partial "feed/rss.html" $options -}}

0 comments on commit e403560

Please sign in to comment.