Fix/Feat: footer, newsletter, logo footerLogo, i18n, router formatting
- Footer : newsletter commentée, margin-top blog, text-align footer-col - Blueprint site : logo → footerLogo (champ dédié au pied de page) - Controller : logo → footerLogo - i18n : newsletter_heading mis à jour (newsletters) - site.svelte.js : retrait console.log debug - router/index.js : reformatage quotes (linter) Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
parent
c6fa61c77b
commit
474baf321b
7 changed files with 73 additions and 54 deletions
|
|
@ -5,12 +5,12 @@ import { locale } from "@state/locale.svelte";
|
|||
let siteInitialized = false;
|
||||
|
||||
function normalizePath(path) {
|
||||
const stripped = path.replace(/^\/en(\/|$)/, '$1') || '/';
|
||||
return stripped === '/' ? '/home' : stripped;
|
||||
const stripped = path.replace(/^\/en(\/|$)/, "$1") || "/";
|
||||
return stripped === "/" ? "/home" : stripped;
|
||||
}
|
||||
|
||||
function apiPrefix() {
|
||||
return locale.current === 'en' ? '/en' : '';
|
||||
return locale.current === "en" ? "/en" : "";
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
@ -80,10 +80,15 @@ export function slideTo(path, { skipHistory = false } = {}) {
|
|||
path = normalizePath(path);
|
||||
|
||||
if (!skipHistory) {
|
||||
const historyPath = locale.current === 'en'
|
||||
? (path === '/home' ? '/en' : `/en${path}`)
|
||||
: (path === '/home' ? '/' : path);
|
||||
history.pushState({}, '', historyPath);
|
||||
const historyPath =
|
||||
locale.current === "en"
|
||||
? path === "/home"
|
||||
? "/en"
|
||||
: `/en${path}`
|
||||
: path === "/home"
|
||||
? "/"
|
||||
: path;
|
||||
history.pushState({}, "", historyPath);
|
||||
}
|
||||
|
||||
const idx = findSlideIndex(path);
|
||||
|
|
@ -102,18 +107,18 @@ export function slideTo(path, { skipHistory = false } = {}) {
|
|||
|
||||
export async function initRouter() {
|
||||
// Language detection: URL prefix > localStorage > navigator
|
||||
const hasEnPrefix = window.location.pathname.startsWith('/en');
|
||||
const hasEnPrefix = window.location.pathname.startsWith("/en");
|
||||
if (hasEnPrefix) {
|
||||
locale.setLanguage('en');
|
||||
localStorage.setItem('wg_lang', 'en');
|
||||
} else if (!localStorage.getItem('wg_lang')) {
|
||||
const navLang = navigator.language || navigator.languages?.[0] || 'fr';
|
||||
if (navLang.startsWith('en')) {
|
||||
window.location.replace('/en' + window.location.pathname);
|
||||
locale.setLanguage("en");
|
||||
localStorage.setItem("wg_lang", "en");
|
||||
} else if (!localStorage.getItem("wg_lang")) {
|
||||
const navLang = navigator.language || navigator.languages?.[0] || "fr";
|
||||
if (navLang.startsWith("en")) {
|
||||
window.location.replace("/en" + window.location.pathname);
|
||||
return;
|
||||
}
|
||||
} else if (localStorage.getItem('wg_lang') === 'en') {
|
||||
window.location.replace('/en' + window.location.pathname);
|
||||
} else if (localStorage.getItem("wg_lang") === "en") {
|
||||
window.location.replace("/en" + window.location.pathname);
|
||||
return;
|
||||
}
|
||||
|
||||
|
|
@ -126,9 +131,7 @@ export async function initRouter() {
|
|||
slides.setActiveIndex(idx);
|
||||
}
|
||||
|
||||
loadAllSlidesInBackground(
|
||||
idx !== -1 ? slides.all[idx].path : initialPath
|
||||
);
|
||||
loadAllSlidesInBackground(idx !== -1 ? slides.all[idx].path : initialPath);
|
||||
|
||||
window.addEventListener("popstate", () => {
|
||||
const path = normalizePath(window.location.pathname);
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue