refactor: moves util functions into their respective library file
This commit is contained in:
parent
98ac61a6c8
commit
38b5413a37
11 changed files with 23 additions and 27 deletions
|
|
@ -2,6 +2,11 @@ import type { CollectionEntry } from 'astro:content';
|
|||
|
||||
type Post = CollectionEntry<'md'>;
|
||||
|
||||
export function getSlug(postId: string): string {
|
||||
const parts = postId.split('/');
|
||||
return parts[parts.length - 1];
|
||||
}
|
||||
|
||||
export function sortPosts(posts: Post[]): Post[] {
|
||||
return posts.slice().sort((a, b) => {
|
||||
if (a.data.pinned && !b.data.pinned) return -1;
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue