diff --git a/src/routes/+page.server.ts b/src/routes/+page.server.ts index 0d1bbde..cc18ebd 100644 --- a/src/routes/+page.server.ts +++ b/src/routes/+page.server.ts @@ -1,6 +1,5 @@ import { error } from '@sveltejs/kit'; import type { PageServerLoad } from './$types'; -import type { Content } from '$lib/article'; import PG from '$lib/server/database'; let data: { @@ -24,7 +23,7 @@ export const load: PageServerLoad = async ({ params }) => { await db.begin(); try { const recent_articles = await db.query( - "SELECT * FROM article WHERE publish = 'public' ORDER BY updated_at DESC LIMIT 4" + "SELECT * FROM article WHERE publish = 'public' ORDER BY updated_at DESC LIMIT 6" ); data.recent = recent_articles.rows.map((row) => ({ title: row.title, @@ -45,56 +44,4 @@ export const load: PageServerLoad = async ({ params }) => { data.updated = data.recent[0].date; return data; -} - -// export const load: PageServerLoad = async ({ params }) => { -// let data = { -// hero: [] as Content[], -// recent: [] as Content[], -// tags: Array.from(index.tags), -// updated: index.updated -// }; -// for (const dat of index.articles.filter((article) => article.publish == "public").list.slice(0, 4).reverse()) { -// if (!dat) continue; -// data.hero.push({ -// title: dat.title, -// image: dat.image, -// date: ((date) => { -// { -// // YYYY/MM/DD -// return `${date.getFullYear()}/${(date.getMonth() + 1).toString().padStart(2, '0')}/${date -// .getDate() -// .toString() -// .padStart(2, '0')}`; -// } -// })(dat.released), -// link: dat.series -// ? `/post/${dat.category}/${dat.series}/${dat.id}` -// : `/post/${dat.category}/${dat.id}`, -// tags: dat.tags -// }); -// } -// //recent 10 articles -// for (const dat of index.articles.filter((article) => article.publish == "public").list.slice(0, 10)) { -// if (!dat) continue; -// data.recent.push({ -// title: dat.title, -// image: dat.image, -// date: ((date) => { -// { -// // YYYY/MM/DD -// return `${date.getFullYear()}/${(date.getMonth() + 1).toString().padStart(2, '0')}/${date -// .getDate() -// .toString() -// .padStart(2, '0')}`; -// } -// })(dat.released), -// link: dat.series -// ? `/post/${dat.category}/${dat.series}/${dat.id}` -// : `/post/${dat.category}/${dat.id}`, -// tags: dat.tags -// }); -// } - -// return data; -// }; +} \ No newline at end of file