mirror of https://github.com/lxndrblz/anatole.git

Alexander Bilz
05.21.2021 de3f78c9c41e999d9072ae6ed93d3e49127d2aeb
Merge branch 'master' into date-improvements
1 files deleted
4 files added
7 files modified
254 ■■■■■ changed files
README.md 24 ●●●●● patch | view | raw | blame | history
assets/js/anatole-header.js 54 ●●●●● patch | view | raw | blame | history
assets/js/anatole-theme-switcher.js 51 ●●●●● patch | view | raw | blame | history
exampleSite/config.toml 11 ●●●●● patch | view | raw | blame | history
i18n/pt-br.toml 24 ●●●●● patch | view | raw | blame | history
i18n/zh-cn.toml 24 ●●●●● patch | view | raw | blame | history
i18n/zh-zn.toml 24 ●●●●● patch | view | raw | blame | history
layouts/_default/baseof.html 3 ●●●●● patch | view | raw | blame | history
layouts/partials/analytics/simpleanalytics.html 7 ●●●●● patch | view | raw | blame | history
layouts/partials/head.html 18 ●●●● patch | view | raw | blame | history
layouts/partials/navbar.html 12 ●●●●● patch | view | raw | blame | history
layouts/partials/sidebar.html 2 ●●● patch | view | raw | blame | history
README.md
@@ -18,6 +18,7 @@
- Multilingual
- 100⁄100 Google Lighthouse score
- Google Analytics (optional)
- SimpleAnalytics (optional)
- Comments powered by Disqus (optional)
- Katex support (optional)
- Formspree Contact Form (optional)
@@ -71,6 +72,12 @@
Add you own favicon in `static/favicons/favicon.ico`.
### Copyright
By default the copyright, will show the current year, but you can change this by configuring the `copyright` parameter.
```toml
copyright = "2020-2021"
```
### Navigation items
Non-content entries can be added right from the `config.toml` file.
@@ -108,6 +115,13 @@
displayMode = "dark"
```
### Disable Theme Switcher
You can easily disable the theme switcher from the `config.toml`. All you have to do is to set the parameter `disableThemeSwitcher` to `true`.
```toml
[params]
disableThemeSwitcher = true # Theme switcher is enabled by default
```
### Disable Animations
You can easily disable the animations from the `config.toml`. All you have to do is to set the parameter `doNotLoadAnimations` to `true`.
```toml
@@ -205,6 +219,16 @@
googleAnalytics = "UA-123-45"
```
### Simple Analytics
To use Simple Analytics, it has to be enabled by setting the parameter to true. If you are using a custom subdomain to evade Adblockers, then specify the URL without a trailing slash.
```toml
[params.simpleAnalytics]
enable = true
# customurl = "https://analytics.example.com"
```
### Google Site Verification
To use Google Site Verification, add the following line to the `[params]`:
assets/js/anatole-header.js
@@ -1,53 +1,3 @@
// initialize default value
function getTheme() {
    return localStorage.getItem('theme') ? localStorage.getItem('theme') : null;
}
function setTheme(style) {
    document.documentElement.setAttribute('data-theme', style);
    localStorage.setItem('theme', style);
}
function init() {
    // initialize default value
    var theme = getTheme();
    // check if a prefered color theme is set for users that have never been to our site
    const userPrefersDark = window.matchMedia && window.matchMedia('(prefers-color-scheme: dark)').matches;
    if (theme === null) {
        if (userPrefersDark) {
            setTheme('dark');
        } else if (!document.documentElement.getAttribute('data-theme')) {
            setTheme('light');
        } else {
            setTheme(document.documentElement.getAttribute('data-theme'));
        }
    } else {
        // load a stored theme
        if (theme == 'light') {
            document.documentElement.setAttribute('data-theme', 'light');
        } else {
            document.documentElement.setAttribute('data-theme', 'dark');
        }
    }
}
// switch themes
function switchTheme(e) {
    var theme = getTheme();
    if (theme == 'light') {
        setTheme('dark');
    } else {
        setTheme('light');
    }
}
document.addEventListener('DOMContentLoaded', function () {
    var themeSwitcher = document.querySelector('.theme-switch');
    themeSwitcher.addEventListener('click', switchTheme, false);
}, false);
document.addEventListener("DOMContentLoaded", function () {
// Get all "navbar-burger" elements
    var $navbarBurgers = Array.prototype.slice.call(document.querySelectorAll(".navbar-burger"), 0);
@@ -63,6 +13,4 @@
            });
        });
    }
});
init();
});
assets/js/anatole-theme-switcher.js
New file
@@ -0,0 +1,51 @@
// initialize default value
function getTheme() {
    return localStorage.getItem('theme') ? localStorage.getItem('theme') : null;
}
function setTheme(style) {
    document.documentElement.setAttribute('data-theme', style);
    localStorage.setItem('theme', style);
}
function init() {
    // initialize default value
    const theme = getTheme();
    // check if a preferred color theme is set for users that have never been to our site
    const userPrefersDark = window.matchMedia && window.matchMedia('(prefers-color-scheme: dark)').matches;
    if (theme === null) {
        if (userPrefersDark) {
            setTheme('dark');
        } else if (!document.documentElement.getAttribute('data-theme')) {
            setTheme('light');
        } else {
            setTheme(document.documentElement.getAttribute('data-theme'));
        }
    } else {
        // load a stored theme
        if (theme === 'light') {
            document.documentElement.setAttribute('data-theme', 'light');
        } else {
            document.documentElement.setAttribute('data-theme', 'dark');
        }
    }
}
// switch themes
function switchTheme() {
    const theme = getTheme();
    if (theme === 'light') {
        setTheme('dark');
    } else {
        setTheme('light');
    }
}
document.addEventListener('DOMContentLoaded', function () {
    const themeSwitcher = document.querySelector('.theme-switch');
    themeSwitcher.addEventListener('click', switchTheme, false);
}, false);
init();
exampleSite/config.toml
@@ -21,6 +21,7 @@
[params]
title = "I'm Jane Doe"
author = "Jane Doe"
#copyright = "2020-2021"
description = "Call me Jane"
profilePicture = "images/profile.jpg"
keywords = ""
@@ -36,11 +37,13 @@
#contactFormAction = "https://formspree.io/f/your-form-hash-here"
# Google Site Verify
#googleSiteVerify = "ABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789"
# indexDateFormat = "Mon, Jan 2, 2006"
# listDateFormat = "Jan 2"
# singleDateFormat = "Mon, Jan 2, 2006"
indexDateFormat = "Mon, Jan 2, 2006"
listDateFormat = "Jan 2"
singleDateFormat = "Mon, Jan 2, 2006"
[params.simpleAnalytics]
# enable = true
# customurl = "https://analytics.example.com"
## Math settings
[params.math]
i18n/pt-br.toml
New file
@@ -0,0 +1,24 @@
[category]
other = "categoria"
[tag]
other = "etiqueta"
[reading_time]
one = "Tempo de leitura: 1 minuto"
other = "Tempo de leitura: {{ .Count }} minutos"
[page_not_found]
other = "Página não encontrada"
[page_does_not_exist]
other = "Desculpa, esta página não existe."
[head_back]
other = "Retornar à <a href=\"{{ . }}\">página inicial</a>."
[comments]
other = "comentários"
[send]
other = "Enviar"
i18n/zh-cn.toml
New file
@@ -0,0 +1,24 @@
[category]
other = "分类"
[tag]
other = "标签"
[reading_time]
one = "阅读时间 1 分钟"
other = "阅读时间 {{ .Count }} 分钟"
[page_not_found]
other = "页面未找到"
[page_does_not_exist]
other = "抱歉,此页面不存在"
[head_back]
other = "返回<a href=\"{{ . }}\">首页</a>."
[comments]
other = "评论"
[send]
other = "发送"
i18n/zh-zn.toml
File was deleted
layouts/_default/baseof.html
@@ -14,6 +14,9 @@
</div>
{{- partial "footer.html" . -}}
{{- if (eq .Site.Params.simpleAnalytics.enable true) -}}
    {{- partial "analytics/simpleanalytics.html" . -}}
{{- end -}}
</body>
</html>
layouts/partials/analytics/simpleanalytics.html
New file
@@ -0,0 +1,7 @@
{{ with .Site.Params.simpleAnalytics.customUrl }}
<script async defer src="{{ . | relURL }}/latest.js"></script>
<noscript><img src="{{ . | relURL }}/noscript.gif" alt=""/></noscript>
{{ else }}
<script async defer src=" https://scripts.simpleanalyticscdn.com/latest.js"></script>
<noscript><img src="https://queue.simpleanalyticscdn.com/noscript.gif" alt=""/></noscript>
{{ end }}
layouts/partials/head.html
@@ -51,13 +51,23 @@
    {{ end -}}
    <!-- JavaScript -->
    {{ $anatole := resources.Get "js/anatole-header.js" }}
    {{ $secureJS := $anatole |  resources.Minify | resources.Fingerprint }}
    {{ $anatoleHeader := resources.Get "js/anatole-header.js" }}
    {{ $secureHeaderJS := $anatoleHeader |  resources.Minify | resources.Fingerprint }}
    <script type="text/javascript"
            src="{{ $secureJS.Permalink }}"
            integrity="{{ $secureJS.Data.Integrity }}"
            src="{{ $secureHeaderJS.Permalink }}"
            integrity="{{ $secureHeaderJS.Data.Integrity }}"
            crossorigin="anonymous"></script>
    {{ if not .Site.Params.disableThemeSwitcher }}
        {{ $anatoleThemeSwitcher := resources.Get "js/anatole-theme-switcher.js" }}
        {{ $secureThemeSwitcherJS := $anatoleThemeSwitcher |  resources.Minify | resources.Fingerprint }}
        <script type="text/javascript"
                src="{{ $secureThemeSwitcherJS.Permalink }}"
                integrity="{{ $secureThemeSwitcherJS.Data.Integrity }}"
                crossorigin="anonymous"></script>
    {{ end }}
    {{- $js := "" -}}
    {{- range .Site.Params.customJs -}}
        {{- if or (in . "http://") (in . "https://") -}}
layouts/partials/navbar.html
@@ -23,10 +23,12 @@
                </li>
            {{ end }}
        {{ end }}
        <li class="theme-switch-item">
            <a class="theme-switch" title="Switch Theme">
                <i class="fas fa-adjust fa-fw" aria-hidden="true"></i>
            </a>
        </li>
        {{ if not .Site.Params.disableThemeSwitcher }}
            <li class="theme-switch-item">
                <a class="theme-switch" title="Switch Theme">
                    <i class="fas fa-adjust fa-fw" aria-hidden="true"></i>
                </a>
            </li>
        {{ end }}
    </ul>
</div>
layouts/partials/sidebar.html
@@ -18,6 +18,6 @@
        {{ end }}
    </ul>
    <div class="footer">
        <div class="by_farbox">&copy; {{ .Site.Params.author }} {{ now.Format "2006"}} </div>
        <div class="by_farbox">&copy; {{ .Site.Params.author }} {{ if isset .Site.Params "copyright" }} {{ .Site.Params.copyright }} {{ else }} {{ now.Format "2006"}} {{end}}</div>
    </div>
</div>