Skip to content

Commit

Permalink
remove translations + small improvements
Browse files Browse the repository at this point in the history
- remove the translations due to the awful support within zola and theme usages

+ better improved 404 page

+ better get theme fallback mechanism

+ avoid errors when an extra key is not set
  • Loading branch information
oltdaniel committed May 7, 2023
1 parent 036ebbe commit 3ae904c
Show file tree
Hide file tree
Showing 7 changed files with 23 additions and 30 deletions.
14 changes: 7 additions & 7 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ and then enable it in your `config.toml`:
theme = "dose"
```

The following taxonomies are enabled (for default `en` and `de`):
You can enable the following taxonomies:

```toml
taxonomies = [
Expand All @@ -40,7 +40,7 @@ default_theme = "dark" # or "light"
```

The description of yourself with your image, you can modify by using a template. Just create a new
file `myblog/parts/me.html`:
file `myblog/templates/parts/me.html`:

```html
<img src="https://via.placeholder.com/50" height="50px" width="50px">
Expand Down Expand Up @@ -74,12 +74,12 @@ This theme supports dark and light mode. Currently this will be only switched ba
#### Size

The JavaScript has been moved into the page itself to allow minification. Together this results in the following sizes for the `index.html`:
- `2.91kB` JavaScript
- `3.04kB` CSS
- `16.7kB` Profile Image
- `4.67kB - 2.91kB = 1.76kB` HTML
- `~ 3kB` JavaScript
- `~ 3kB` CSS
- `~ 17kB` Profile Image
- `~5kB - ~3kB = ~2kB` HTML

Which results in a total loading size of `2.91kB + 3.04kB + 16.7kB + 1.76kB = 24.41kB`.
Which results in a total loading size of `3kB + 3kB + 17kB + 2kB = 25kB`.

#### Syntax Highlighting

Expand Down
20 changes: 7 additions & 13 deletions config.toml
Original file line number Diff line number Diff line change
Expand Up @@ -9,26 +9,20 @@ compile_sass = true
# Whether to build a search index to be used later on by a JavaScript library
build_search_index = false

# Default English language
[languages.en]
# Explicitly set default language
default_language = "en"

# Enable taxonomies in default language
taxonomies = [
{ name = "tags", feed = true }
{ name = "tags" }
]

[languages.en.translations]
tags = "Tags"
toggle_theme = "Toggle Theme"

# German language
[languages.de]
# Enable taxonomies in german language
taxonomies = [
{ name = "tags", feed = true }
{ name = "tags" }
]

[languages.de.translations]
tags = "Tags"
toggle_theme = "Thema umschalten"

[markdown]
# Whether to do syntax highlighting
# Theme can be customised by setting the `highlight_theme` variable to a theme supported by Zola
Expand Down
5 changes: 4 additions & 1 deletion templates/404.html
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
{% extends "base.html" %}

{% block content %}
404
<div style="display: block; padding: 20vh 0; width: 100%; text-align: center;">
<h1>404</h1>
<h5>NOT FOUND</h5>
</div>
{% endblock content %}
4 changes: 3 additions & 1 deletion templates/base.html
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@
<body>
<script>
function get_theme() {
return localStorage.getItem('prefers-color') || '{{ config.extra.default_theme }}'
return localStorage.getItem('prefers-color') || (window.matchMedia('(prefers-color-scheme: dark)').matches ? 'dark' : '{% if config.extra.default_theme %}{{ config.extra.default_theme }}{% else %}light{% endif %}')
}

/**
Expand All @@ -55,13 +55,15 @@
<div class="footer-social-media">
<a id="toggle-theme"></a>
<a href="/tags">{{ trans(key="tags", lang=lang) }}</a>
{% if config.extra.social_media %}
{% for social in config.extra.social_media %}
{% if social.rel %}
<a href="{{ social.url | safe }}" rel="{{ social.rel }}" target="_blank">{{ social.name }}</a>
{% else %}
<a href="{{ social.url | safe }}" target="_blank">{{ social.name }}</a>
{% endif %}
{% endfor %}
{% endif %}
</div>
</footer>
</body>
Expand Down
2 changes: 1 addition & 1 deletion templates/tags/list.html
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
{% block content %}
<header>
<p><a href="..">..</a>/tags</p>
<h4>{{ trans(key="tags", lang=lang) }}</h4>
<h4>Tags</h4>
</header>
<main>
<div class="chips">
Expand Down
2 changes: 1 addition & 1 deletion templates/tags/single.html
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
{% block content %}
<header>
<p><a href="..">..</a>/tags/{{ term.name }}</p>
<h4>{{ trans(key="tags", lang=lang) }} - {{ term.name }}</h4>
<h4>Tags - {{ term.name }}</h4>
</header>
<main>
{% if lang != lang %}
Expand Down
6 changes: 0 additions & 6 deletions theme.toml
Original file line number Diff line number Diff line change
Expand Up @@ -6,12 +6,6 @@ min_version = "0.14.0"
demo = "https://oltdaniel.github.io/dose"

[extra]
social_media = [
{ name = "GitHub", url = "https://github.com/oltdaniel" },
{ name = "Twitter", url = "https://twitter.com/@twitter" },
{ name = "Mastodon", url = "https://mastodon.social/@Mastodon", rel = "me" }
]
default_theme = "dark"

[author]
name = "oltdaniel"
Expand Down

0 comments on commit 3ae904c

Please sign in to comment.