mirror of
https://github.com/mat-1/matdoesdev.git
synced 2025-08-02 06:36:04 +00:00
only render qotd on server
This commit is contained in:
parent
3484389bfe
commit
3da484eda3
2 changed files with 11 additions and 1 deletions
10
src/routes/qotd/+server.ts
Normal file
10
src/routes/qotd/+server.ts
Normal file
|
@ -0,0 +1,10 @@
|
|||
import { type RequestHandler } from '@sveltejs/kit'
|
||||
|
||||
export const prerender = true
|
||||
|
||||
export const GET: RequestHandler = async ({}) => {
|
||||
// similar to /status.json, this is redirected in caddy but we put it in
|
||||
// sveltekit too so it can be pre-rendered
|
||||
|
||||
return await fetch('https://matdoes.dev/qotd')
|
||||
}
|
|
@ -6,7 +6,7 @@ export const load: Load = async ({ fetch }) => {
|
|||
|
||||
let qotd = 'Error: Failed to fetch quote of the day'
|
||||
try {
|
||||
qotd = await fetch('https://matdoes.dev/qotd').then((r: Response) => r.text())
|
||||
qotd = await fetch('/qotd').then((r: Response) => r.text())
|
||||
// remove first line since it's just "Quote of the day:"
|
||||
qotd = qotd.split('\n').slice(1).join('\n')
|
||||
} catch (e) {
|
||||
|
|
Loading…
Add table
Reference in a new issue