Skip to content

Commit

Permalink
✨ Feat: add unified custom template entry file `layouts/partials/cust…
Browse files Browse the repository at this point in the history
…om.html`
  • Loading branch information
Lruihao committed May 9, 2024
1 parent f32402d commit eb0acca
Show file tree
Hide file tree
Showing 7 changed files with 47 additions and 5 deletions.
3 changes: 3 additions & 0 deletions layouts/_default/baseof.html
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
{{- partial "init/index.html" . -}}
{{- partial "custom.html" . -}}

<!DOCTYPE html>
<html itemscope itemtype="http://schema.org/WebPage" lang="{{ .Site.LanguageCode }}">
Expand All @@ -14,6 +15,8 @@
{{- partial "head/meta.html" . -}}
{{- partial "head/link.html" . -}}
{{- partial "head/seo.html" . -}}
{{- /* Custom head */ -}}
{{- block "custom-head" . }}{{ end -}}
</head>
<body data-header-desktop="{{ .Site.Params.header.desktopMode }}" data-header-mobile="{{ .Site.Params.header.mobileMode }}">
{{- /* Check theme isDark before body rendering */ -}}
Expand Down
3 changes: 3 additions & 0 deletions layouts/partials/assets.html
Original file line number Diff line number Diff line change
Expand Up @@ -306,3 +306,6 @@
{{- end -}}

{{- partial "plugin/analytics.html" . -}}

{{- /* Custom Assets */ -}}
{{- block "custom-assets" . }}{{ end -}}
22 changes: 22 additions & 0 deletions layouts/partials/custom.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
{{- /*
In order to avoid upgrade conflicts and to easily reference theme components,
It's recommended to copy this file from the theme to your project and rewrite it.
*/ -}}

{{- define "custom-head" -}}
{{- end -}}

{{- define "custom-profile" -}}
{{- end -}}

{{- define "custom-aside" -}}
{{- end -}}

{{- define "custom-footer" -}}
{{- end -}}

{{- define "custom-widgets" -}}
{{- end -}}

{{- define "custom-assets" -}}
{{- end -}}
5 changes: 4 additions & 1 deletion layouts/partials/footer.html
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,12 @@
{{- if ne $footerConfig.enable false -}}
<footer class="footer">
<div class="footer-container">
{{- /* Custom Content */ -}}
{{- /* TODO remove Custom Content */ -}}
{{- partial (.Scratch.Get "customFilePath").footer . -}}

{{- /* Custom Footer */ -}}
{{- block "custom-footer" . }}{{ end -}}

{{- /* Powered by Hugo and Theme - FixIt */ -}}
{{- if ne $footerConfig.powered.enable false -}}
<div class="footer-line powered{{ with $footerConfig.order.powered }} order-{{ . }}{{ end }}">
Expand Down
5 changes: 4 additions & 1 deletion layouts/partials/home/profile.html
Original file line number Diff line number Diff line change
Expand Up @@ -108,6 +108,9 @@ <h3 class="home-disclaimer">
</h3>
{{- end -}}

{{- /* Custom Content */ -}}
{{- /* TODO remove Custom Content */ -}}
{{- partial (.Scratch.Get "customFilePath").profile . -}}

{{- /* Custom Profile */ -}}
{{- block "custom-profile" . }}{{ end -}}
</div>
8 changes: 6 additions & 2 deletions layouts/partials/widgets.html
Original file line number Diff line number Diff line change
Expand Up @@ -49,11 +49,15 @@
{{- if .Dark -}}
{{- $style = printf "%v--bg-progress-dark: %v;" $style .Dark -}}
{{- end -}}
<div class="reading-progress-bar" {{ printf "style=\"%v\"" $style | safeHTMLAttr }}></div>
<div class="reading-progress-bar" {{ printf `style="%v"` $style | safeHTMLAttr }}></div>
{{- end -}}
{{- end -}}

{{- /* Custom widgets */ -}}
{{- block "custom-widgets" . }}{{ end -}}

<noscript>
<div class="noscript-warning">{{ T "baseof.noscript" }}</div>
</noscript>
</div>
</div>
{{- /* EOF */ -}}
6 changes: 5 additions & 1 deletion layouts/posts/single.html
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,12 @@
<aside class="aside-collection animate__animated animate__fadeIn animate__faster" aria-label="{{ T "collections" }}">
{{- /* Collection List */ -}}
{{- partial "single/collection-list.html" . -}}
{{- /* Custom part for aside */ -}}

{{- /* TODO remove Custom part for aside */ -}}
{{- partial (.Scratch.Get "customFilePath").aside . -}}

{{- /* Custom Aside */ -}}
{{- block "custom-aside" . }}{{ end -}}
</aside>

<article class="page single">
Expand Down

0 comments on commit eb0acca

Please sign in to comment.