diff --git a/src/_includes/layouts/base.njk b/src/_includes/layouts/base.njk index c2226a6..0d60fea 100644 --- a/src/_includes/layouts/base.njk +++ b/src/_includes/layouts/base.njk @@ -1,4 +1,5 @@ +{% set lang %}{{ lang | default(config.defaultLanguage) }}{% endset %} {% include 'partials/head-matter.njk' %} diff --git a/src/_redirects b/src/_redirects index ca05b26..412ceb4 100644 --- a/src/_redirects +++ b/src/_redirects @@ -1,3 +1,5 @@ +/fr/* /fr/404.html 404 + /principles /insights /principles/DiverseParticipationAndPerspectives.html /insights/diverse-participation-and-perspectives/ /principles/AutonomousUser.html /insights/PersonalDiscovery.html diff --git a/src/404.md b/src/documents/pages/en-CA/404.md similarity index 85% rename from src/404.md rename to src/documents/pages/en-CA/404.md index b7cc437..21185c1 100644 --- a/src/404.md +++ b/src/documents/pages/en-CA/404.md @@ -1,7 +1,7 @@ --- title: 404 - Page Not Found layout: "layouts/404.njk" -permalink: /404.html +permalink: /en/404.html --- Check the entered URL, or go to the [Inclusive Design Guides homepage](/). diff --git a/src/documents/pages/fr/404.md b/src/documents/pages/fr/404.md new file mode 100644 index 0000000..e5c45e0 --- /dev/null +++ b/src/documents/pages/fr/404.md @@ -0,0 +1,7 @@ +--- +title: Erreur 404 - page introuvable +layout: "layouts/404.njk" +permalink: /fr/404.html +--- + +VĂ©rifiez l'adresse URL ou rendez-vous sur la page d'[accueil du guide pour une conception inclusive](/fr/). diff --git a/src/documents/pages/pages.11tydata.js b/src/documents/pages/pages.11tydata.js index ce6c9a9..40e80a2 100644 --- a/src/documents/pages/pages.11tydata.js +++ b/src/documents/pages/pages.11tydata.js @@ -18,7 +18,19 @@ module.exports = { return data.page.fileSlug; }, - /* Build a permalink using the title and language key. */ - permalink: data => generatePermalink(data, "pages") + /* Build a permalink using the title and language key, or to the 404 page. */ + permalink: data => { + if (data.page.fileSlug !== "404") { + return generatePermalink(data, "pages"); + } + + let lang = getLang(data.page.filePathStem, "pages"); + + if (lang !== data.config.defaultLanguage) { + return `/${data.config.languages[lang].slug}/404.html`; + } + return "/404.html"; + + } } };