sv/en toggle

This commit is contained in:
gws 2024-11-07 10:16:24 +01:00
parent 20d21d09a4
commit d5c1fe2d60
9 changed files with 168 additions and 41 deletions

View file

@ -1,6 +1,6 @@
{% macro render_header() %}
{% set section = get_section(path="_index.md") %}
<a href="{{ section.permalink | safe }}">
{% macro render_header(path) %}
{% set root = get_section(path="_index.md") %}
<a href="{{ root.permalink | safe }}">
<div class="logo">
<img src="{{ get_url(path=config.extra.juice_logo_path) }}" alt="logo">
{{ config.extra.juice_logo_name }}
@ -15,14 +15,29 @@
{% endif %}
{% for page in section.pages %}
{% for page in root.pages %}
{% if lang == "en" %}
<a class="nav-item subtitle-text" href="{{ page.permalink | safe }}">{{ page.title }}</a>
{% else %}
<a class="nav-item subtitle-text" href="/{{lang}}{{ page.path }}">{{ page.title }}</a>
{% endif %}
{% endfor %}
{% for path in section.subsections %}
{% for path in root.subsections %}
{% set child = get_section(path=path) %}
<a class="nav-item subtitle-text" href="{{ child.permalink }}">{{ child.title }}</a>
{% if lang == "en"%}
<a class="nav-item subtitle-text" href="{{ child.permalink | safe }}">{{ child.title }}</a>
{% else %}
<a class="nav-item subtitle-text" href="/{{lang}}{{ child.path }}">{{ child.title }}</a>
{% endif %}
{% endfor %}
{% if lang == "en"%}
<a class="nav-item subtitle-text" href="/sv{{ path }}">sv</a>
{% else %}
<a class="nav-item subtitle-text" href="{{ path }}">en</a>
{% endif %}
</nav>

View file

@ -29,7 +29,7 @@
{% block header %}
<header class="box-shadow">
{{ macros::render_header() }}
{{ macros::render_header(path=page.path) }}
</header>
{% endblock header %}

View file

@ -23,50 +23,59 @@
{% endblock head %}
<body>
{% block header %}
<div class="hero">
<header class="pos-absolute" style="background-color: transparent">
{{ macros::render_header(path = section.path ) }}
</header>
{% block hero %}
<div class="hero">
<script async defer src="https://buttons.github.io/buttons.js"></script>
<section class="text-center">
<h1 class="heading-text" style="font-size: 50px">
{{ config.extra.slogan }}
</h1>
<h3 class="title-text">
{{ section.extra.intro | safe }}
</h3>
<div>
<!-- <a class="github-button" href="https://github.com/huhu/juice" data-size="large" data-show-count="true" -->
<!-- aria-label="Star huhu/juice on GitHub">Star</a> -->
<!-- <a class="github-button" href="https://github.com/huhu/juice/fork" data-size="large" data-show-count="true" -->
<!-- aria-label="Fork huhu/juice on GitHub">Repos</a> -->
{% block hero %}
<script async defer src="https://buttons.github.io/buttons.js"></script>
<section class="text-center">
<h1 class="heading-text" style="font-size: 50px">
{{ config.extra.slogan }}
</h1>
<h3 class="title-text">
{{ section.extra.intro | safe }}
</h3>
<div>
<!-- <a class="github-button" href="https://github.com/huhu/juice" data-size="large" data-show-count="true" -->
<!-- aria-label="Star huhu/juice on GitHub">Star</a> -->
<!-- <a class="github-button" href="https://github.com/huhu/juice/fork" data-size="large" data-show-count="true" -->
<!-- aria-label="Fork huhu/juice on GitHub">Repos</a> -->
</div>
</section>
<img class="hero-image" style="width: 50%" src="{{ get_url(path='build-blocks.svg') }}">
<div class="explore-more text" onclick="document.getElementById('features').scrollIntoView({behavior: 'smooth'})">
Explore More ⇩
</div>
</section>
<img class="hero-image" style="width: 50%" src="{{ get_url(path='build-blocks.svg') }}">
<div class="explore-more text" onclick="document.getElementById('features').scrollIntoView({behavior: 'smooth'})">
Explore More ⇩
</div>
<style>
.hero section {
padding: 0 5rem;
}
@media screen and (max-width: 768px) {
<style>
.hero section {
padding: 0 2rem;
padding: 0 5rem;
}
.hero-image {
display: none
@media screen and (max-width: 768px) {
.hero section {
padding: 0 2rem;
}
.hero-image {
display: none
}
}
}
</style>
</style>
{% endblock hero %}
{% endblock hero %}
</div>
{% endblock header %}

22
templates/page.html Normal file
View file

@ -0,0 +1,22 @@
{% import "_macros.html" as macros %}
{% extends "index.html" %}
{% block title %}{{ page.title }} | {{ super() }} {% endblock title %}
{% block header %}
<header class="box-shadow">
{% if lang =="en" %}
{% set path = [""] | concat(with=page.components) | join(sep="/") %}
{% else %}
{% set path = [""] | concat(with=page.components | slice(start=1)) | join(sep="/") %}
{% endif %}
{{ macros::render_header(path=path) }}
</header>
{% endblock header %}
{% block content %}
<div class="heading-text">{{ page.description }}</div>
{{ page.content | safe }}
{% endblock content %}

View file

@ -5,7 +5,13 @@
{% block header %}
<header class="box-shadow">
{{ macros::render_header() }}
{% if lang =="en" %}
{% set path = [""] | concat(with=section.components) | join(sep="/") %}
{% else %}
{% set path = [""] | concat(with=section.components | slice(start=1)) | join(sep="/") %}
{% endif %}
{{ macros::render_header(path=path) }}
</header>
{% endblock header %}