🚧 Switch to monorepo with Turbo
This commit is contained in:
42
apps/website/src/routes/(site)/subscribe/+page.server.ts
Normal file
42
apps/website/src/routes/(site)/subscribe/+page.server.ts
Normal file
@@ -0,0 +1,42 @@
|
||||
import { error } from '@sveltejs/kit'
|
||||
import type { PageServerLoad } from './$types'
|
||||
import { fetchAPI } from '$utils/api'
|
||||
|
||||
|
||||
/**
|
||||
* Page Data
|
||||
*/
|
||||
export const load: PageServerLoad = async ({ setHeaders }) => {
|
||||
try {
|
||||
const res = await fetchAPI(`query {
|
||||
settings {
|
||||
newsletter_page_text
|
||||
}
|
||||
|
||||
newsletter (
|
||||
limit: -1,
|
||||
sort: "-issue",
|
||||
filter: { status: { _eq: "published" }},
|
||||
) {
|
||||
issue
|
||||
title
|
||||
date_sent
|
||||
link
|
||||
thumbnail { id }
|
||||
}
|
||||
}`)
|
||||
|
||||
if (res) {
|
||||
const { data } = res
|
||||
|
||||
setHeaders({ 'Cache-Control': 'public, max-age=1, stale-while-revalidate=86399' })
|
||||
|
||||
return {
|
||||
...data.settings,
|
||||
issues: data.newsletter,
|
||||
}
|
||||
}
|
||||
} catch (err) {
|
||||
throw error(500, err.message)
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user