feat: support multilingual sites

This commit is contained in:
Cyril MARPAUD
2023-03-14 10:38:08 +01:00
parent dac13b410e
commit 63e21f0fe0
4 changed files with 36 additions and 7 deletions

View File

@ -3,7 +3,7 @@
{% set author = macro::format_name(name=config.extra.name) | striptags -%}
<!DOCTYPE html>
<html lang="fr">
<html lang="{{ lang }}">
<head>
<meta charset="utf-8">
@ -12,7 +12,7 @@
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<link rel="icon" href="favicon.svg">
<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/modern-normalize/modern-normalize.min.css">
<link rel="stylesheet" type="text/css" href="style.css">
<link rel="stylesheet" type="text/css" href="{{ config.base_url }}/style.css">
<link rel="stylesheet" href="https://fonts.googleapis.com/css2?family=Roboto&display=swap">
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/6.3.0/css/all.min.css" />
<title>{{ author }}</title>
@ -24,7 +24,7 @@
<script src="https://cdn.jsdelivr.net/particles.js/2.0.0/particles.min.js"></script>
<script>
particlesJS.load('particles', 'particles.json', null);
particlesJS.load('particles', '{{ config.base_url | safe }}/particles.json', null);
</script>
</html>

View File

@ -9,7 +9,7 @@
{% endif %}
{% if page.extra.link %}
<a aria-label="external link" class="list_link" href="{{ page.extra.link }}" target="_blank" rel="noopener noreferrer">Découvrir</a>
<a aria-label="external link" class="list_link" href="{{ page.extra.link }}" target="_blank" rel="noopener noreferrer">{{ section.extra.discover | default(value="Discover") }}</a>
{% endif %}
{% if not link_after %}

View File

@ -2,9 +2,14 @@
{% block content -%}
{% set ext = "" -%}
{% if config.default_language != lang -%}
{% set ext = "." ~ lang -%}
{% endif -%}
{% set sections = [] -%}
{% for section in config.extra.sections | default(value=[]) -%}
{% set_global sections = sections | concat(with=get_section(path=section ~ "/_index.md")) -%}
{% set_global sections = sections | concat(with=get_section(path=section ~ "/_index" ~ ext ~ ".md")) -%}
{% endfor -%}
<div id="particles" class="fullflex"></div>
@ -12,14 +17,24 @@
<div id="landing" class="fullflex">
<div id="splash">
<div id="lang">
{%- for lang,tr in config.languages %}
{% if config.default_language != lang -%}
{% set url = config.base_url ~ "/" ~ lang -%}
{% endif -%}
{% if not loop.first %}| {% endif -%}
<a href="{{ url | default(value=config.base_url | safe) }}">{{ tr.translations.flag | default(value=lang) }}</a>
{%- endfor %}
</div>
<h1 id="name">
{{ macro::format_name(name=config.extra.name) }}
</h1>
{% if config.extra.roles -%}
{% if section.extra.roles -%}
<div id="roles">
<p>
{% for role in config.extra.roles -%}
{%- for role in section.extra.roles %}
<span>{{ role }}</span><br>
{% endfor %}
</p>