Skip to content

Commit

Permalink
✨ Feat: add custom partials options params.customPartials
Browse files Browse the repository at this point in the history
  • Loading branch information
Lruihao committed Sep 25, 2024
1 parent fabe057 commit 954d864
Show file tree
Hide file tree
Showing 4 changed files with 52 additions and 8 deletions.
14 changes: 14 additions & 0 deletions hugo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -825,6 +825,20 @@ enableEmoji = true
# whether to show the full text content in feed.
fullText = true

# FixIt 0.3.12 | NEW Custom partials config
# Custom partials must be stored in the /layouts/partials/ directory.
# Depends on open custom blocks https://fixit.lruihao.cn/references/blocks/
[params.customPartials]
head = []
profile = []
aside = []
comment = []
footer = []
widgets = []
assets = []
postFooterBefore = []
postFooterAfter = []

# FixIt 0.2.15 | NEW Developer options
# Select the scope named `public_repo` to generate personal access token,
# Configure with environment variable `HUGO_PARAMS_GHTOKEN=xxx`, see https://gohugo.io/functions/os/getenv/#examples
Expand Down
1 change: 0 additions & 1 deletion layouts/_default/baseof.html
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
{{- partial "init/index.html" . -}}
{{- partial "custom.html" . -}}

<!DOCTYPE html>
<html itemscope itemtype="http://schema.org/WebPage" lang="{{ .Site.LanguageCode }}">
Expand Down
43 changes: 37 additions & 6 deletions layouts/partials/custom.html
Original file line number Diff line number Diff line change
@@ -1,31 +1,62 @@
{{- /*
To avoid upgrade conflicts and facilitate the reference of theme components,
it's strongly recommended to copy this file from the theme to your project and override it.
*/ -}}

{{- define "custom-head" -}}
{{- $ctx := . -}}
{{- range .Site.Params.customPartials.head -}}
{{- partial . $ctx -}}
{{- end -}}
{{- end -}}

{{- define "custom-profile" -}}
{{- $ctx := . -}}
{{- range .Site.Params.customPartials.profile -}}
{{- partial . $ctx -}}
{{- end -}}
{{- end -}}

{{- define "custom-aside" -}}
{{- $ctx := . -}}
{{- range .Site.Params.customPartials.aside -}}
{{- partial . $ctx -}}
{{- end -}}
{{- end -}}

{{- define "custom-comment" -}}
{{- $ctx := . -}}
{{- range .Site.Params.customPartials.comment -}}
{{- partial . $ctx -}}
{{- end -}}
{{- end -}}

{{- define "custom-footer" -}}
{{- $ctx := . -}}
{{- range .Site.Params.customPartials.footer -}}
{{- partial . $ctx -}}
{{- end -}}
{{- end -}}

{{- define "custom-widgets" -}}
{{- $ctx := . -}}
{{- range .Site.Params.customPartials.widgets -}}
{{- partial . $ctx -}}
{{- end -}}
{{- end -}}

{{- define "custom-assets" -}}
{{- $ctx := . -}}
{{- range .Site.Params.customPartials.assets -}}
{{- partial . $ctx -}}
{{- end -}}
{{- end -}}

{{- define "custom-post__footer:before" -}}
{{- $ctx := . -}}
{{- range .Site.Params.customPartials.postFooterBefore -}}
{{- partial . $ctx -}}
{{- end -}}
{{- end -}}

{{- define "custom-post__footer:after" -}}
{{- end -}}
{{- $ctx := . -}}
{{- range .Site.Params.customPartials.postFooterAfter -}}
{{- partial . $ctx -}}
{{- end -}}
{{- end -}}
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.12-185c6803" -}}
{{- .Scratch.Set "version" "v0.3.12-314d24a3" -}}
{{- .Scratch.Set "this" dict -}}

{{- partial "init/detection-env.html" . -}}
Expand Down

0 comments on commit 954d864

Please sign in to comment.