added support for injecting content

This commit is contained in:
Gabriele Musco 2021-01-02 14:08:21 +01:00
parent 25cf285710
commit 15c730e637
No known key found for this signature in database
GPG Key ID: 8539FD3454380B83
10 changed files with 24 additions and 0 deletions

View File

@ -10,6 +10,8 @@ A prickly blog theme for Hugo
# Customization # Customization
## Configuration
These are some parameters you can use in your `config.toml` to customize Ficurinia: These are some parameters you can use in your `config.toml` to customize Ficurinia:
```toml ```toml
@ -65,6 +67,18 @@ paginate = 5 # number of articles per page in the index
accentColor = "#db5793" accentColor = "#db5793"
``` ```
## Inject custom content
Ficurinia supports injecting custom content into the theme. There are several files you can create in `layouts/partials/inject` that will be included inside the theme in different places.
| Partial | Placement |
|---------|-----------|
| `layouts/partials/inject/body.html` | Before closing the `body` tag |
| `layouts/partials/inject/content-after.html` | After a post or page content |
| `layouts/partials/inject/content-before.html` | Before a post or page content |
| `layouts/partials/inject/footer.html` | At the beginning of the footer |
| `layouts/partials/inject/head.html` | Before closing the `head` tag |
# Does *Ficurinia* mean anything? # Does *Ficurinia* mean anything?
It's Sicilian for Indian fig, also known as prickly pear cactus. It's Sicilian for Indian fig, also known as prickly pear cactus.

View File

@ -10,5 +10,6 @@
{{- partial "footer.html" . -}} {{- partial "footer.html" . -}}
</div> </div>
{{- partial "plausible.html" . -}} {{- partial "plausible.html" . -}}
{{- partial "inject/body.html" . -}}
</body> </body>
</html> </html>

View File

@ -1,4 +1,5 @@
{{ define "main" }} {{ define "main" }}
{{- partial "inject/content-before.html" . -}}
<article> <article>
<h1>{{ .Title }}</h1> <h1>{{ .Title }}</h1>
<p class="date">{{ .Date.Format "2006-01-02" }}</p> <p class="date">{{ .Date.Format "2006-01-02" }}</p>
@ -13,6 +14,7 @@
</p> </p>
{{ end }} {{ end }}
</article> </article>
{{- partial "inject/content-after.html" . -}}
{{ if .Site.Params.commento }} {{ if .Site.Params.commento }}
<script <script
defer defer

View File

@ -1,5 +1,6 @@
<footer> <footer>
<hr /> <hr />
{{- partial "inject/footer.html" . -}}
<p><small> <p><small>
{{ now.Format "2006" }} &copy; {{ .Site.Copyright }} {{ now.Format "2006" }} &copy; {{ .Site.Copyright }}
</small></p> </small></p>

View File

@ -22,4 +22,5 @@
<link href="/jetbrains-mono/jetbrains-mono.css" rel="stylesheet"> <link href="/jetbrains-mono/jetbrains-mono.css" rel="stylesheet">
{{ $style := resources.Get "/scss/style.scss" | resources.ExecuteAsTemplate "/scss/style.scss" . | resources.ToCSS (dict "targetPath" "css/styles.css" "outputStyle" "compressed" "enableSourceMap" "true") | resources.Fingerprint "sha512" }} {{ $style := resources.Get "/scss/style.scss" | resources.ExecuteAsTemplate "/scss/style.scss" . | resources.ToCSS (dict "targetPath" "css/styles.css" "outputStyle" "compressed" "enableSourceMap" "true") | resources.Fingerprint "sha512" }}
<link type=text/css rel=stylesheet href={{ $style.Permalink }} integrity="{{ $style.Data.Integrity }}" /> <link type=text/css rel=stylesheet href={{ $style.Permalink }} integrity="{{ $style.Data.Integrity }}" />
{{- partial "inject/head.html" . -}}
</head> </head>

View File

@ -0,0 +1 @@
<!-- This code will be injected before closing the body tag -->

View File

@ -0,0 +1 @@
<!-- This code will be injected after a post or page content -->

View File

@ -0,0 +1 @@
<!-- This code will be injected before a post or page content -->

View File

@ -0,0 +1 @@
<!-- This code will be injected at the beginning of the footer -->

View File

@ -0,0 +1 @@
<!-- This code will be injected before closing the head tag -->