adding the article suggestion at the end of the blog post
Deploy Vercel / deploy-preprod (push) Successful in 1m9s
Deploy Vercel / deploy-production (push) Has been skipped

This commit is contained in:
2026-07-08 09:36:56 +02:00
parent 5f41471108
commit abc3a9095c
6 changed files with 140 additions and 7 deletions
+11
View File
@@ -45,6 +45,17 @@ export function getAllArticles(locale: string): Article[] {
.sort((a, b) => new Date(b.date).getTime() - new Date(a.date).getTime());
}
export function getRandomOtherArticles(locale: string, excludeSlug: string, count: number): Article[] {
const candidates = getAllArticles(locale).filter((article) => article.slug !== excludeSlug);
for (let i = candidates.length - 1; i > 0; i--) {
const j = Math.floor(Math.random() * (i + 1));
[candidates[i], candidates[j]] = [candidates[j], candidates[i]];
}
return candidates.slice(0, count);
}
export function getAlternatesArticle(article: Article) {
if (!article.translationKey) {
return {};