mirror of
https://github.com/zaaarf/friendenstein.git
synced 2024-11-12 18:49:22 +01:00
feat: random subtitle via external api
This commit is contained in:
parent
a7b25ca5cc
commit
361d2c712e
2 changed files with 23 additions and 1 deletions
|
@ -78,6 +78,12 @@ subtitle_suffixes = [
|
|||
", random!"
|
||||
]
|
||||
|
||||
# You can fetch the subtitles from an API instead, setting these two parameters:
|
||||
# random_api = "api.url" # url of the API
|
||||
# random_api_param = "name" # parameter within the JSON to look at for
|
||||
# I recommend https://git.alemi.dev/mood/ for this, in that case "mood" would the random_api_param,
|
||||
# and the url would be wherever you set the endpoint to be.
|
||||
|
||||
# Social icons, list here: https://github.com/rhazdon/hugo-theme-hello-friend-ng/blob/master/layouts/partials/svg.html
|
||||
social_icons = [
|
||||
{ name = "github", at = "https://github.com/zaaarf" },
|
||||
|
|
|
@ -17,7 +17,23 @@
|
|||
{{ svg::draw_icons(icons=config.extra.home.social_icons) }}
|
||||
{% endif %}
|
||||
</div></div>
|
||||
{% if config.extra.home.subtitle_suffixes %}
|
||||
{% if config.extra.home.random_api and config.extra.home.random_api_param %}
|
||||
<script>
|
||||
async function fetchSubtitle() {
|
||||
let element = document.getElementById("subtitle-rand")
|
||||
try {
|
||||
let res = await fetch("{{ config.extra.home.random_api | safe }}");
|
||||
let doc = await res.json();
|
||||
element.innerHTML = `${doc.{{ config.extra.home.random_api_param }}}`;
|
||||
} catch (e) {
|
||||
console.log(e);
|
||||
element.textContent = ", seemingly incapable to configure nginx";
|
||||
}
|
||||
}
|
||||
|
||||
fetchSubtitle();
|
||||
</script>
|
||||
{% elif config.extra.home.subtitle_suffixes %}
|
||||
<script> //random subtitle logic
|
||||
const suffixes = [
|
||||
{% for s in config.extra.home.subtitle_suffixes %}
|
||||
|
|
Loading…
Reference in a new issue