fix: build errors and merging projects and homepage
This commit is contained in:
@@ -1,26 +1,29 @@
|
||||
import { db } from "$lib/db"
|
||||
import { blogArticles } from "$lib/db/schema";
|
||||
import { redirect } from "@sveltejs/kit";
|
||||
import type { PageServerLoad } from "./$types.js";
|
||||
import { db } from '$lib/server/db';
|
||||
import { blogArticles } from '$lib/server/db/schema';
|
||||
import { redirect } from '@sveltejs/kit';
|
||||
import type { PageServerLoad } from './$types.js';
|
||||
|
||||
export const load: PageServerLoad = async () => {
|
||||
const articles = await db.select().from(blogArticles)
|
||||
const articles = await db.select().from(blogArticles);
|
||||
|
||||
return {
|
||||
blogArticles: articles
|
||||
}
|
||||
}
|
||||
};
|
||||
};
|
||||
|
||||
export const actions = {
|
||||
default: async ({ request }): Promise<Response> => {
|
||||
const formData = await request.formData();
|
||||
|
||||
const blogArticle = await db.insert(blogArticles).values({
|
||||
title: formData.get('title')?.toString(),
|
||||
slug: formData.get('slug')?.toString(),
|
||||
content: formData.get('content')?.toString()
|
||||
}).returning();
|
||||
const blogArticle = await db
|
||||
.insert(blogArticles)
|
||||
.values({
|
||||
title: formData.get('title')?.toString(),
|
||||
slug: formData.get('slug')?.toString(),
|
||||
content: formData.get('content')?.toString()
|
||||
})
|
||||
.returning();
|
||||
|
||||
return redirect(303, `/blog/${blogArticle[0].slug}`);
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user