Switch subscribe query to page endpoint
This commit is contained in:
@@ -12,7 +12,7 @@
|
|||||||
import InteractiveGlobe from '$components/organisms/InteractiveGlobe.svelte'
|
import InteractiveGlobe from '$components/organisms/InteractiveGlobe.svelte'
|
||||||
|
|
||||||
export let data: any
|
export let data: any
|
||||||
export let issues: any
|
export let issues: any[]
|
||||||
|
|
||||||
|
|
||||||
onMount(() => {
|
onMount(() => {
|
||||||
@@ -94,37 +94,4 @@
|
|||||||
</section>
|
</section>
|
||||||
|
|
||||||
<InteractiveGlobe type="cropped" />
|
<InteractiveGlobe type="cropped" />
|
||||||
</PageTransition>
|
</PageTransition>
|
||||||
|
|
||||||
|
|
||||||
<script context="module" lang="ts">
|
|
||||||
import { fetchAPI } from '$utils/api'
|
|
||||||
|
|
||||||
/** @type {import('@sveltejs/kit').Load} */
|
|
||||||
export async function load ({ url, params, fetch, session, stuff }) {
|
|
||||||
const res = await fetchAPI(`
|
|
||||||
query {
|
|
||||||
settings {
|
|
||||||
newsletter_page_text
|
|
||||||
}
|
|
||||||
|
|
||||||
newsletter (limit: -1, sort: "-issue") {
|
|
||||||
issue
|
|
||||||
title
|
|
||||||
date_sent
|
|
||||||
link
|
|
||||||
thumbnail { id }
|
|
||||||
}
|
|
||||||
}
|
|
||||||
`)
|
|
||||||
|
|
||||||
const { data } = res
|
|
||||||
|
|
||||||
return {
|
|
||||||
props: {
|
|
||||||
data: data.settings,
|
|
||||||
issues: data.newsletter,
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
</script>
|
|
||||||
40
src/routes/subscribe.ts
Normal file
40
src/routes/subscribe.ts
Normal file
@@ -0,0 +1,40 @@
|
|||||||
|
import type { RequestEvent, RequestHandlerOutput } from '@sveltejs/kit'
|
||||||
|
import { fetchAPI } from '$utils/api'
|
||||||
|
|
||||||
|
export async function get({}: RequestEvent): Promise<RequestHandlerOutput> {
|
||||||
|
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 }
|
||||||
|
}
|
||||||
|
}
|
||||||
|
`)
|
||||||
|
|
||||||
|
const { data } = res
|
||||||
|
|
||||||
|
return {
|
||||||
|
body: {
|
||||||
|
data: data.settings,
|
||||||
|
issues: data.newsletter,
|
||||||
|
}
|
||||||
|
}
|
||||||
|
} catch (error) {
|
||||||
|
return {
|
||||||
|
status: 404,
|
||||||
|
body: error,
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
Reference in New Issue
Block a user