File tree Expand file tree Collapse file tree 3 files changed +58
-1
lines changed
Expand file tree Collapse file tree 3 files changed +58
-1
lines changed Original file line number Diff line number Diff line change 1+ ---
2+ " openscript-ch-website " : patch
3+ ---
4+
5+ Add 404 page
Original file line number Diff line number Diff line change @@ -21,7 +21,7 @@ const locale = currentLocale.get();
2121 <Email />
2222 </li >
2323 {
24- withoutLanguageSwitcher ? null : (
24+ withoutLanguageSwitcher || ! translations ? null : (
2525 <li >
2626 <LanguageSwitcher locale = { locale } translations = { translations } />
2727 </li >
Original file line number Diff line number Diff line change 1+ ---
2+ import Button from " ../components/Button.astro" ;
3+ import Shell from " ../layouts/Shell.astro" ;
4+ import Article from " ../layouts/templates/Article.astro" ;
5+ ---
6+
7+ <style >
8+ [data-translation] {
9+ display: none;
10+ }
11+
12+ .active[data-translation] {
13+ display: block;
14+ }
15+ </style >
16+
17+ <Shell >
18+ <div data-translation =" en" >
19+ <Article title =" Page not found" >
20+ <section >
21+ <p >Sorry, the page you are looking for does not exist.</p >
22+ <Button href =" /en" withArrow >Go to home page</Button >
23+ </section >
24+ </Article >
25+ </div >
26+ <div data-translation =" de" >
27+ <Article title =" Seite nicht gefunden" >
28+ <section >
29+ <p >Entschuldigung, die von Ihnen gesuchte Seite existiert nicht.</p >
30+ <Button href =" /" withArrow >Startseite aufrufen</Button >
31+ </section >
32+ </Article >
33+ </div >
34+ </Shell >
35+
36+ <script >
37+ function register() {
38+ const localeElements = document.querySelectorAll("[data-translation]");
39+ const pathname = window.location.pathname;
40+ const activeElement =
41+ Array.from(localeElements).find(
42+ (el) => el instanceof HTMLElement && pathname.startsWith(`/${el.dataset.translation}/`),
43+ ) || document.querySelector('[data-translation="de"]');
44+
45+ if (activeElement instanceof HTMLElement) {
46+ activeElement.classList.add("active");
47+ }
48+ }
49+
50+ register();
51+ document.addEventListener("astro:after-swap", register);
52+ </script >
You can’t perform that action at this time.
0 commit comments