File tree Expand file tree Collapse file tree 4 files changed +81
-0
lines changed Expand file tree Collapse file tree 4 files changed +81
-0
lines changed Original file line number Diff line number Diff line change @@ -161,6 +161,7 @@ export default defineConfig({
161161 headingLinks : false ,
162162 } ,
163163 routeMiddleware : "./src/plugins/starlight/route-data.ts" ,
164+ disable404Route : true ,
164165 } ) ,
165166 liveCode ( { } ) ,
166167 icon ( ) ,
Original file line number Diff line number Diff line change 1+ <div class =" flex flex-col items-center justify-center md:py-28" >
2+ <h1 >404</h1 >
3+ <p >
4+ Check the URL, try using our <a id =" 404-search-link" href =" /search/"
5+ >search</a
6+ > or try our LLM-friendly
7+ <a href =" /llms.txt" > llms.txt directory</a >.
8+ </p >
9+ </div >
10+
11+ <script >
12+ const { pathname } = window.location;
13+
14+ const anchor = document.getElementById("404-search-link");
15+
16+ if (anchor) {
17+ const pretty = pathname.replaceAll("/", " ").replaceAll("-", " ").trim();
18+
19+ anchor.setAttribute("href", `/search/?q=${encodeURIComponent(pretty)}`);
20+ }
21+ </script >
Original file line number Diff line number Diff line change 1+ ---
2+ import StarlightPage , {
3+ type StarlightPageProps ,
4+ } from " @astrojs/starlight/components/StarlightPage.astro" ;
5+ import FourOhFour from " ~/components/404.astro" ;
6+
7+ const props = {
8+ frontmatter: {
9+ title: " 404 - Page Not Found" ,
10+ template: " splash" ,
11+ editUrl: false ,
12+ feedback: false ,
13+ },
14+ hideTitle: true ,
15+ hideBreadcrumbs: true ,
16+ } as StarlightPageProps ;
17+ ---
18+
19+ <StarlightPage {... props }>
20+ <FourOhFour />
21+ </StarlightPage >
Original file line number Diff line number Diff line change 1+ ---
2+ import StarlightPage , {
3+ type StarlightPageProps ,
4+ } from " @astrojs/starlight/components/StarlightPage.astro" ;
5+ import type { GetStaticPaths } from " astro" ;
6+ import { getCollection } from " astro:content" ;
7+
8+ import FourOhFour from " ~/components/404.astro" ;
9+
10+ export const getStaticPaths = (async () => {
11+ const sections = await getCollection (" docs" , (e ) => {
12+ return e .id .split (" /" ).length === 1 ;
13+ });
14+
15+ return sections .map ((section ) => {
16+ return {
17+ params: {
18+ product: section .id ,
19+ },
20+ };
21+ });
22+ }) satisfies GetStaticPaths ;
23+
24+ const props = {
25+ frontmatter: {
26+ title: " 404 - Page Not Found" ,
27+ tableOfContents: false ,
28+ editUrl: false ,
29+ feedback: false ,
30+ },
31+ hideTitle: true ,
32+ hideBreadcrumbs: true ,
33+ } as StarlightPageProps ;
34+ ---
35+
36+ <StarlightPage {... props }>
37+ <FourOhFour />
38+ </StarlightPage >
You can’t perform that action at this time.
0 commit comments