dependabot/npm_and_yarn/eslint-9.39.1
dependabot/npm_and_yarn/eslint-9.39.1
dependabot/npm_and_yarn/eslint-plugin-astro-1.5.0
dependabot/npm_and_yarn/eslint/js-9.39.1
dependabot/npm_and_yarn/katex-0.16.25
dependabot/npm_and_yarn/sharp-0.34.5
dependabot/npm_and_yarn/tailwindcss/vite-4.1.17
dependabot/npm_and_yarn/tsx-4.20.6
dependabot/npm_and_yarn/typescript-eslint-8.46.4
dependabot/npm_and_yarn/typescript-eslint/eslint-plugin-8.36.0
dependabot/npm_and_yarn/typescript-eslint/parser-8.46.4
main
| 1 | import { getCollection, type CollectionEntry } from 'astro:content' |
| 2 | |
| 3 | /** |
| 4 | * Get all posts, filtering out posts whose filenames start with _ and static pages |
| 5 | */ |
| 6 | export async function getFilteredPosts() { |
| 7 | const posts = await getCollection('posts') |
| 8 | const staticPages = ['privacy-policy', 'terms-of-use'] |
| 9 | const unpublishedPages = ['why-learn-persian', 'terms-of-use'] |
| 10 | return posts.filter( |
| 11 | (post) => |
| 12 | !post.id.startsWith('_') && |
| 13 | !staticPages.includes(post.id) && |
| 14 | !unpublishedPages.includes(post.id) |
| 15 | ) |
| 16 | } |
| 17 | |
| 18 | /** |
| 19 | * Get all posts sorted by publication date, filtering out posts whose filenames start with _ |
| 20 | */ |
| 21 | export async function getSortedFilteredPosts() { |
| 22 | const posts = await getFilteredPosts() |
| 23 | return posts.sort( |
| 24 | (a: CollectionEntry<'posts'>, b: CollectionEntry<'posts'>) => |
| 25 | b.data.pubDate.valueOf() - a.data.pubDate.valueOf() |
| 26 | ) |
| 27 | } |