It is now possible to display #1
|
@ -1,6 +1,5 @@
|
||||||
import { error } from '@sveltejs/kit';
|
import { error } from '@sveltejs/kit';
|
||||||
import type { PageServerLoad } from './$types';
|
import type { PageServerLoad } from './$types';
|
||||||
import type { Content } from '$lib/article';
|
|
||||||
import PG from '$lib/server/database';
|
import PG from '$lib/server/database';
|
||||||
|
|
||||||
let data: {
|
let data: {
|
||||||
|
@ -24,7 +23,7 @@ export const load: PageServerLoad = async ({ params }) => {
|
||||||
await db.begin();
|
await db.begin();
|
||||||
try {
|
try {
|
||||||
const recent_articles = await db.query(
|
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) => ({
|
data.recent = recent_articles.rows.map((row) => ({
|
||||||
title: row.title,
|
title: row.title,
|
||||||
|
@ -45,56 +44,4 @@ export const load: PageServerLoad = async ({ params }) => {
|
||||||
data.updated = data.recent[0].date;
|
data.updated = data.recent[0].date;
|
||||||
|
|
||||||
return data;
|
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;
|
|
||||||
// };
|
|
Loading…
Reference in New Issue
Block a user