upgrade to sveltekit 1
This commit is contained in:
25
src/routes/_posts/all.js
Normal file
25
src/routes/_posts/all.js
Normal file
@@ -0,0 +1,25 @@
|
||||
import { dev } from '$app/environment';
|
||||
const posts = import.meta.globEager('./*.svx');
|
||||
|
||||
|
||||
let postData = [];
|
||||
for (const path in posts) {
|
||||
// skip draft posts in production mode
|
||||
if (!dev && posts[path].metadata.draft) {
|
||||
continue;
|
||||
}
|
||||
|
||||
// slice off the ./ and the .svx
|
||||
const slug = path.slice(2, -4);
|
||||
posts[path].metadata.slug = slug;
|
||||
postData.push(posts[path].metadata);
|
||||
}
|
||||
|
||||
postData.sort((a, b) => {
|
||||
// sorting in reverse, so we flip the intuitive order
|
||||
if (a.date > b.date) return -1;
|
||||
if (a.date < b.date) return 1;
|
||||
return 0;
|
||||
});
|
||||
|
||||
export { postData };
|
||||
Reference in New Issue
Block a user