mirror of
https://github.com/cupcakearmy/nicco.io.git
synced 2025-12-16 02:35:09 +00:00
cache data
This commit is contained in:
@@ -1,9 +1,6 @@
|
||||
<script context="module">
|
||||
import { getOne } from '../../lib/wp'
|
||||
export async function preload({ params }) {
|
||||
const { slug } = params
|
||||
const post = await getOne('posts', { slug })
|
||||
return { post }
|
||||
return this.fetch(`/api/posts/${params.slug}.json`).then((res) => res.json())
|
||||
}
|
||||
</script>
|
||||
|
||||
@@ -12,10 +9,10 @@
|
||||
import WPAdapter from '../../components/WPAdapter.svelte'
|
||||
import PostAttributes from '../../components/PostAttributes.svelte'
|
||||
|
||||
export let post
|
||||
export let data
|
||||
</script>
|
||||
|
||||
<SimplePage title={post.title} expanded={false} readable>
|
||||
<PostAttributes {post} full />
|
||||
<WPAdapter content={post.content} />
|
||||
<SimplePage title={data.title} expanded={false} readable>
|
||||
<PostAttributes post={data} full />
|
||||
<WPAdapter content={data.content} />
|
||||
</SimplePage>
|
||||
|
||||
@@ -1,9 +1,6 @@
|
||||
<script context="module">
|
||||
import { getAll } from '../../lib/wp'
|
||||
|
||||
export async function preload() {
|
||||
const data = await getAll('posts')
|
||||
return { data }
|
||||
return this.fetch('/api/posts.json').then((res) => res.json())
|
||||
}
|
||||
</script>
|
||||
|
||||
|
||||
Reference in New Issue
Block a user