Skip to content

Commit

Permalink
✨ feat(footer): add configurable copyright notice
Browse files Browse the repository at this point in the history
- The text `$CURRENT_YEAR` will be replaced by the current year.

- Can be translated.

- Markdown is rendered.
  • Loading branch information
welpo committed Aug 18, 2023
1 parent d3167ad commit 6ed13f0
Show file tree
Hide file tree
Showing 4 changed files with 54 additions and 12 deletions.
9 changes: 9 additions & 0 deletions config.toml
Original file line number Diff line number Diff line change
Expand Up @@ -230,6 +230,15 @@ socials = [
{ name = "spotify", url = "https://open.spotify.com/artist/5Hv2bYBhMp1lUHFri06xkE", icon = "spotify" },
]

# Enable a copyright notice for the footer, shown between socials and the "Powered by" text.
# You can use $CURRENT_YEAR to automatically insert the current year.
# Markdown is supported (links, emphasis, etc).
# copyright = "© $CURRENT_YEAR Your Name • Unless otherwise noted, the content in this website is available under the [CC BY-SA 4.0](https://creativecommons.org/licenses/by-sa/4.0/) license."

# For multi-language sites, you can set a different copyright for each language.
# If this is set to true, ensure you have a `copyright` translation for each language.
translate_copyright = false

# Custom security headers. What urls should your website be able to connect to?
# You need to specify the CSP and the URLs associated with the directive.
# Useful if you want to load remote content safely (embed YouTube videos, which needs frame-src, for example).
Expand Down
5 changes: 5 additions & 0 deletions sass/parts/_footer.scss
Original file line number Diff line number Diff line change
Expand Up @@ -72,4 +72,9 @@ footer nav {
.credits {
font-size: 0.88rem;
color: var(--meta-color);
text-align: center;

p {
margin: 0;
}
}
18 changes: 14 additions & 4 deletions templates/partials/footer.html
Original file line number Diff line number Diff line change
Expand Up @@ -50,24 +50,34 @@
{% endif %}
</nav>
<div class="credits">
{# Shows "Powered by Zola & tabi" #}
{# Shows link to remote repository if repository is set and `show_remote_source` is not false #}
{% set show_source = config.extra.show_remote_source | default(value=true) %}
<small>
{# Shows optional Copyright notice #}
{%- if config.extra.copyright -%}
{% set current_year = now() | date(format="%Y") %}
{# Translate the copyright if set in the config #}
{%- if config.extra.translate_copyright and lang != config.default_language -%}
<p>{{ trans(key="copyright", lang=lang) | replace(from="$CURRENT_YEAR", to=current_year) | markdown | safe }}</p>
{%- else -%}
<p>{{ config.extra.copyright | replace(from="$CURRENT_YEAR", to=current_year) | markdown | safe }}</p>
{%- endif -%}
{%- endif -%}

{# Shows "Powered by Zola & tabi" notice #}
{%- if lang != config.default_language -%}
{{ trans(key="powered_by" | safe, lang=lang) }}
{%- else -%}
Powered by
{%- endif -%}
&nbsp;<a href="https://www.getzola.org" target="_blank">Zola</a>&nbsp;

{%- if lang != config.default_language -%}
{{ trans(key="and" | safe, lang=lang) }}
{%- else -%}
&
{%- endif -%}
&nbsp;<a href="https://github.com/welpo/tabi" target="_blank">tabi</a>

{# Shows link to remote repository if repository is set and `show_remote_source` is not false #}
{% set show_source = config.extra.show_remote_source | default(value=true) %}
{%- if config.extra.remote_repository_url and show_source -%}
&nbsp;{{ separator }}
<a href="{{ config.extra.remote_repository_url }}" target="_blank">
Expand Down
34 changes: 26 additions & 8 deletions theme.toml
Original file line number Diff line number Diff line change
Expand Up @@ -19,23 +19,24 @@ homepage = "https://osc.garden"
# be merged with user data, some kind of prefix or nesting is preferable
# Use snake_casing to be consistent with the rest of Zola
[extra]
# Languages of your site.
# You'll need to add the language translations for each non-English language.
# See the config.toml file for an example.

language_name.ca = "Català"
language_name.en = "English"
language_name.es = "Español"

# Remote repository for your Zola site.
# Only used to link to the commit history of updated posts, right next to the updated date.
# Used for `show_remote_changes` and `show_remote_source` (see below).
# Supports GitHub, GitLab, Gitea, and Codeberg.
remote_repository_url = "https://github.com/welpo/tabi"
# Set this to "auto" to try and auto-detect the platform based on the repository URL.
# Accepted values are "github", "gitlab", "gitea", and "codeberg".
# Defaults to "auto".
remote_repository_git_platform = "auto"
# Branch in the repo hosting the Zola site. Defaults to "main".
remote_repository_branch = "main"
remote_repository_git_platform = "auto" # Defaults to "auto".
# Branch in the repo hosting the Zola site.
remote_repository_branch = "main" # Defaults to "main".
# Show a link to the commit history of updated posts, right next to the last updated date.
show_remote_changes = true # Defaults to true.
# Show a link to the repository of the site, right next to the "Powered by Zola & tabi" text.
show_remote_source = true # Defaults to true.

# Enable JavaScript theme toggler to allow users to switch between dark/light mode.
# Also enables automatic switching based on user's OS-level theme settings.
Expand Down Expand Up @@ -97,6 +98,14 @@ menu = [
# The RSS icon will be shown if (1) it's enabled and (2) the following variable is set to true.
feed_icon = true

# Email address for footer's social section.
# Protect against spambots:
# 1. Use base64 for email (convert at https://www.base64encode.org/ or `printf '[email protected]' | base64`).
# 2. Or, set 'encode_plaintext_email' to true for auto-encoding (only protects on site, not in public repos).
email = "bWFpbEBleGFtcGxlLmNvbQ==" # base64 encoded version of "[email protected]"
# Decoding requires ~400 bytes of JavaScript. If JS is disabled, the email won't be displayed.
encode_plaintext_email = true # Setting is ignored if email is already encoded.

# The icons available can be found in "social_icons" in the "static" folder.
socials = [
{ name = "github", url = "https://github.com/welpo/", icon = "github" },
Expand All @@ -106,6 +115,15 @@ socials = [
{ name = "spotify", url = "https://open.spotify.com/artist/5Hv2bYBhMp1lUHFri06xkE", icon = "spotify" },
]

# Enable a copyright notice for the footer, shown between socials and the "Powered by" text.
# You can use $CURRENT_YEAR to automatically insert the current year.
# Markdown is supported (links, emphasis, etc).
# copyright = "© $CURRENT_YEAR Your Name • Unless otherwise noted, the content in this website is available under the [CC BY-SA 4.0](https://creativecommons.org/licenses/by-sa/4.0/) license."

# For multi-language sites, you can set a different copyright for each language.
# If this is set to true, ensure you have a `copyright` translation for each language.
translate_copyright = false

# Custom security headers. What urls should your website be able to connect to?
# You need to specify the CSP and the URLs associated with the directive.
# Useful if you want to load remote content safely (embed YouTube videos, which needs frame-src, for example).
Expand Down

0 comments on commit 6ed13f0

Please sign in to comment.