Skip to content

Commit

Permalink
add customizable copyright
Browse files Browse the repository at this point in the history
- years can be configured
- fix #56 copyright can be enabled/disabled
- moved all copyright config under .Site.Params.Copyright
  • Loading branch information
yishanhe committed Sep 5, 2021
1 parent a27a143 commit 5319937
Show file tree
Hide file tree
Showing 3 changed files with 27 additions and 7 deletions.
12 changes: 7 additions & 5 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -178,12 +178,14 @@ The `name` key expects the name of a [Font Awesome icon](https://fontawesome.com

### Copyright

Assign your copy right to `.Site.Copyright`. Cactus will append current year to the head.

TODO: Customizable copyright year
Assign your copy right to `.Site.Params.Copyright.Name`.

```toml
copyright = "Zeran Wu" # cactus theme will use site title if copyright is not set
[params.copyright]
enabled = true # default
name = "Zeran Wu" # cactus will use title if copyright is not set
startYear = 2020 # if not provided, will use current year.
endYear = 2021 # if not provided, will use current year.
```

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

Expand Down
10 changes: 9 additions & 1 deletion exampleSite/config.toml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ baseURL = "https://example.com"
languageCode = "en-us"
title = "Cactus theme example"
theme = "cactus"
copyright = "You" # cactus will use title if copyright is not set
copyright = "You" # deprecated, please use of params.copyright
disqusShortname = "example" # Used when comments is enabled. Cactus will use site title if not set
# googleAnalytics = "UA-1234-5"

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

# Customize the copyright years
# Note: if startYear/endYear not provided, will use current year.
[params.copyright]
enabled = false # default
name = "You" # cactus will use title if copyright is not set
startYear = 2021
endYear = 2021

# the value of name should be an valid font awesome icon name (brands type)
# https://fontawesome.com/icons?d=gallery&s=brands
[[params.social]]
Expand Down
12 changes: 11 additions & 1 deletion layouts/partials/footer.html
Original file line number Diff line number Diff line change
@@ -1,7 +1,17 @@
<footer id="footer">
<div class="footer-left">
Copyright &copy; {{ now.Format "2006" }} {{ if .Site.Copyright }} {{ print .Site.Copyright | markdownify }} {{ else }} {{ print .Site.Title }} {{ end }}
{{ $copyrightEnabled := true }}
{{ if (isset .Site.Params "copyright") }}
{{ $copyrightEnabled = .Site.Params.Copyright.Enabled | default false }}
{{ end }}
{{ if $copyrightEnabled }}
{{ $startYear := .Site.Params.Copyright.StartYear | default (now.Format "2006") }}
{{ $endYear := .Site.Params.Copyright.EndYear | default (now.Format "2006") }}
Copyright &copy;
{{ 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 }}
{{ end }}
</div>

<div class="footer-right">
<nav>
<ul>
Expand Down

0 comments on commit 5319937

Please sign in to comment.