feat: Update recent articles limit to 6 on top page

This commit is contained in:
Keisuke Hirata 2024-08-25 10:18:47 +09:00
parent f6c332bc2e
commit 53fba96092

View File

@ -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,
@ -46,55 +45,3 @@ export const load: PageServerLoad = async ({ params }) => {
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;
// };