feat: add blog post feed to project pages #368 (#369)

- [x] Add blog post feed to project pages #368
- [x] update readme
- [x] fix blog tags
This commit is contained in:
Kalidou Diagne
2025-05-01 14:59:04 +03:00
committed by Meyanis95
parent 313480620f
commit 741c823bcd
43 changed files with 547 additions and 311 deletions

View File

@@ -16,13 +16,18 @@ export interface Article {
hash?: string
canonical?: string
tags?: string[]
projects?: string[]
}
const articlesDirectory = path.join(process.cwd(), "articles")
// Get all articles from /articles
export function getArticles(options?: { limit?: number; tag?: string }) {
const { limit = 1000, tag } = options ?? {}
export function getArticles(options?: {
limit?: number
tag?: string
project?: string
}) {
const { limit = 1000, tag, project } = options ?? {}
// Get file names under /articles
const fileNames = fs.readdirSync(articlesDirectory)
const allArticlesData = fileNames.map((fileName: string) => {
@@ -91,6 +96,14 @@ export function getArticles(options?: { limit?: number; tag?: string }) {
)
}
// Filter by project if provided
if (project) {
filteredArticles = filteredArticles.filter(
(article) =>
Array.isArray(article.projects) && article.projects.includes(project)
)
}
// Sort posts by date
return filteredArticles
.sort((a, b) => {