-
Notifications
You must be signed in to change notification settings - Fork 5
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Don't just catch everything as a flat page
- Loading branch information
Showing
4 changed files
with
44 additions
and
3 deletions.
There are no files selected for viewing
2 changes: 1 addition & 1 deletion
2
src/routes/(pages)/[...path]/+page.svelte → src/routes/(pages)/about/+page.svelte
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
import { error } from "@sveltejs/kit"; | ||
|
||
import { PAGE_MAX_AGE } from "@/config/config.js"; | ||
import * as flatpages from "$lib/api/flatpages"; | ||
|
||
export const trailingSlash = "always"; | ||
|
||
const path = "/about/"; | ||
|
||
export async function load({ fetch, setHeaders }) { | ||
const { data, error: err } = await flatpages.get(path, fetch); | ||
|
||
if (err) { | ||
return error(err.status, { message: err.message }); | ||
} | ||
|
||
if (!data) { | ||
return error(404, "Page not found"); | ||
} | ||
|
||
setHeaders({ | ||
"cache-control": `public, max-age=${PAGE_MAX_AGE}`, | ||
}); | ||
|
||
return data; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
<script lang="ts"> | ||
import Flatpage from "$lib/components/layouts/Flatpage.svelte"; | ||
export let data; | ||
$: title = data.title; | ||
$: content = data.content; | ||
</script> | ||
|
||
<svelte:head> | ||
<title>{title} | DocumentCloud</title> | ||
</svelte:head> | ||
|
||
<Flatpage {content} /> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters