Skip to content

Commit 584768a

Browse files
committed
add customizable copyright
- years can be configured - fix #56 copyright can be enabled/disabled - moved all copyright config under .Site.Params.Copyright
1 parent a27a143 commit 584768a

File tree

3 files changed

+27
-7
lines changed

3 files changed

+27
-7
lines changed

README.md

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -178,12 +178,14 @@ The `name` key expects the name of a [Font Awesome icon](https://fontawesome.com
178178

179179
### Copyright
180180

181-
Assign your copy right to `.Site.Copyright`. Cactus will append current year to the head.
182-
183-
TODO: Customizable copyright year
181+
Assign your copy right to `.Site.Params.Copyright.Name`.
184182

185183
```toml
186-
copyright = "Zeran Wu" # cactus theme will use site title if copyright is not set
184+
[params.copyright]
185+
enabled = true # default
186+
name = "Zeran Wu" # cactus will use title if copyright is not set
187+
startYear = 2020 # if not provided, will use current year.
188+
endYear = 2021 # if not provided, will use current year.
187189
```
188190

189191
### Comments
@@ -290,7 +292,7 @@ Pagination on posts archive can be disabled to show all posts in chronological o
290292
- [x] Analytics
291293
- [ ] Local Search
292294
- [ ] toc template
293-
- [ ] Customizable copyright year
295+
- [x] Customizable copyright year
294296
- [ ] gallery
295297
- [ ] expose [mathjax configuration](https://docs.mathjax.org/en/latest/web/configuration.html#web-configuration)
296298

exampleSite/config.toml

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ baseURL = "https://example.com"
22
languageCode = "en-us"
33
title = "Cactus theme example"
44
theme = "cactus"
5-
copyright = "You" # cactus will use title if copyright is not set
5+
copyright = "You" # deprecated, please use params.copyright
66
disqusShortname = "example" # Used when comments is enabled. Cactus will use site title if not set
77
# googleAnalytics = "UA-1234-5"
88

@@ -81,6 +81,14 @@ weight = 4
8181
#serverUrl = "" # Defaults to https://matrix.cactus.chat:8448 (Cactus Chat public server)
8282
#serverName = "" # Defaults to cactus.chat
8383

84+
# Customize the copyright years
85+
# Note: if startYear/endYear not provided, will use current year.
86+
[params.copyright]
87+
enabled = true # default
88+
name = "You" # cactus will use title if copyright is not set
89+
startYear = 2021
90+
endYear = 2021
91+
8492
# the value of name should be an valid font awesome icon name (brands type)
8593
# https://fontawesome.com/icons?d=gallery&s=brands
8694
[[params.social]]

layouts/partials/footer.html

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,17 @@
11
<footer id="footer">
22
<div class="footer-left">
3-
Copyright &copy; {{ now.Format "2006" }} {{ if .Site.Copyright }} {{ print .Site.Copyright | markdownify }} {{ else }} {{ print .Site.Title }} {{ end }}
3+
{{ $copyrightEnabled := true }}
4+
{{ if (isset .Site.Params "copyright") }}
5+
{{ $copyrightEnabled = .Site.Params.Copyright.Enabled | default false }}
6+
{{ end }}
7+
{{ if $copyrightEnabled }}
8+
{{ $startYear := .Site.Params.Copyright.StartYear | default (now.Format "2006") }}
9+
{{ $endYear := .Site.Params.Copyright.EndYear | default (now.Format "2006") }}
10+
Copyright &copy;
11+
{{ if (eq $startYear $endYear) }} {{ $startYear }} {{ else }} {{ $startYear }}-{{ $endYear }} {{ end }} {{ if .Site.Params.Copyright.Name }} {{ print .Site.Params.Copyright.Name | markdownify }} {{ else }} {{ print .Site.Title }} {{ end }}
12+
{{ end }}
413
</div>
14+
515
<div class="footer-right">
616
<nav>
717
<ul>

0 commit comments

Comments
 (0)