diff --git a/src/pages/newest/index.ts b/src/pages/newest/index.ts index 9aec773..dd99c0b 100644 --- a/src/pages/newest/index.ts +++ b/src/pages/newest/index.ts @@ -6,10 +6,16 @@ import type { APIRoute } from 'astro'; const posts = await getCollection('posts') -const newestPost = posts.sort((a, b) => compareDesc(new Date(a.data.date), new Date(b.data.date)))[0]; +const newestPost = posts.sort( + (a, b) => compareDesc(new Date(a.data.date), new Date(b.data.date)) +).filter((e) => { + if (e.data.draft) { + return false; + } else return true; +})[0]; console.log(newestPost.slug) export const GET: APIRoute = ({ redirect }) => { - return redirect('https://eleboog.com/posts/' + newestPost.slug, 307); + return redirect('/posts/' + newestPost.slug, 307); } \ No newline at end of file