blog server, page functions

This commit is contained in:
matthieu42morin 2024-04-28 01:30:30 +02:00
parent a89f69c69c
commit c7c2ea60a2
5 changed files with 13 additions and 13 deletions

View File

@ -1,2 +1,2 @@
export const prerender = true;
export const trailingSlash = 'never';
export const trailingSlash = 'never';

View File

@ -1,7 +1,7 @@
import { listPosts } from '$content/blog';
import type { PageLoad } from './$types';
export const load = async () => {
return {
posts: listPosts()
};
export const load = async ({ fetch }) => {
const response = await fetch('api/posts');
const posts: Post[] = await response.json();
return { posts };
};

View File

@ -1,4 +1,4 @@
import { listPosts } from '$content/blog';
import { listPosts } from '$lib/utils/blog';
import RSS from 'rss';
import type { Post } from '$lib/types/post';

View File

@ -1,7 +1,7 @@
import { listProjects } from '$content/projects';
import type { PageLoad } from './$types';
export const load = () => {
return {
projects: listProjects()
};
export const load = async ({ fetch }) => {
const response = await fetch('api/posts');
const projects: Projects[] = await response.json();
return { projects };
};

View File

@ -1,4 +1,4 @@
import { getProject, listProjects } from '$content/projects';
import { getProject, listProjects } from '$lib/utils/projects';
import type { PageLoad } from './$types';
export const entries = () => listProjects().map((post) => ({ slug: post.slug }));