Migrate articles to standalone endpoints
This commit is contained in:
parent
fecdeee94d
commit
5f1c7e9804
@ -1,5 +1,5 @@
|
|||||||
/** @type {import('@sveltejs/kit').ParamMatcher} */
|
/** @type {import('@sveltejs/kit').ParamMatcher} */
|
||||||
export function match(param: string) {
|
export function match(param: string) {
|
||||||
console.log('parma', param)
|
console.debug('parma', param)
|
||||||
return !['tags', 'page'].some((keyword) => param.startsWith(keyword))
|
return !['tags', 'page'].some((keyword) => param.startsWith(keyword))
|
||||||
}
|
}
|
||||||
|
@ -3,14 +3,12 @@
|
|||||||
import type { LoadInput, LoadOutput } from '@sveltejs/kit/types/page'
|
import type { LoadInput, LoadOutput } from '@sveltejs/kit/types/page'
|
||||||
|
|
||||||
export async function load({ fetch, url }: LoadInput): Promise<LoadOutput> {
|
export async function load({ fetch, url }: LoadInput): Promise<LoadOutput> {
|
||||||
const blogPostsResponse = await fetch(`/blog`, {
|
const blogPostsResponse = await fetch(`/blog/articles`)
|
||||||
headers: { accept: 'application/json' },
|
|
||||||
})
|
|
||||||
const blogPostsContent = await blogPostsResponse.json()
|
const blogPostsContent = await blogPostsResponse.json()
|
||||||
return {
|
return {
|
||||||
props: {
|
props: {
|
||||||
latestPosts: take(5, blogPostsContent.posts),
|
latestPosts: take(5, blogPostsContent.posts),
|
||||||
// TODO Check if not bugged
|
// TODO Check if not bugged FIXME
|
||||||
segment: '',
|
segment: '',
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
|
@ -1,3 +1,15 @@
|
|||||||
|
<script lang="ts" context="module">
|
||||||
|
/**
|
||||||
|
* @type {import('@sveltejs/kit').Load}
|
||||||
|
*/
|
||||||
|
export async function load({ fetch }) {
|
||||||
|
const articleResponse = await fetch(`/blog/articles`)
|
||||||
|
.then((r) => r.json())
|
||||||
|
|
||||||
|
return { props: { posts: articleResponse.posts } }
|
||||||
|
}
|
||||||
|
</script>
|
||||||
|
|
||||||
<script lang="ts">
|
<script lang="ts">
|
||||||
import ArticleFooter from '../../components/blog/ArticleFooter.svelte'
|
import ArticleFooter from '../../components/blog/ArticleFooter.svelte'
|
||||||
import { postListClass, seeAllClass } from './index.css'
|
import { postListClass, seeAllClass } from './index.css'
|
||||||
|
Loading…
Reference in New Issue
Block a user