that should not happen either wow i am bad at this
Some checks are pending
ci / builder (push) Waiting to run
Some checks are pending
ci / builder (push) Waiting to run
This commit is contained in:
parent
9739575f50
commit
c219a1d60a
1 changed files with 8 additions and 2 deletions
|
@ -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);
|
||||
}
|
Loading…
Add table
Reference in a new issue