Files
logos-web/apps/web/lib/tech-stack-related-articles.ts
Jinho Jang fe62cee62b feat: tech stack related articles, feature cards polish, and node programme signup (#34)
* feat(node-programme): refactor signup form and implement submission logic

* fix(web): improve layout and styling of feature cards section

* feat(tech-stack): implement tech stack related articles functionality and update blog article fetching logic
2026-06-04 02:46:17 +09:00

60 lines
1.5 KiB
TypeScript

import type { RelatedArticlesSection } from '@repo/content/schemas'
import type { BlogArticleRow } from '@/lib/blog-engine'
export interface TechStackRelatedArticleCard {
title: string
mobileTitle?: string
imageSrc: string
imageAlt: string
imagePosition?: string
date: string
author: string
readingTime?: number
href: string
}
export const TECH_STACK_RELATED_ARTICLE_TAGS = {
blockchain: 'Blockchain',
messaging: 'Messaging',
networking: 'Logos_stack',
storage: 'Storage',
} as const
export function blogArticlesToTechStackRelatedCards(
articles: ReadonlyArray<BlogArticleRow>
): TechStackRelatedArticleCard[] {
return articles.map((article) => ({
title: article.title,
imageSrc: article.cardImage,
imageAlt: article.title,
date: article.galleryDate,
author: article.author,
readingTime: article.readingTime,
href: article.href,
}))
}
export function getTechStackRelatedArticleCards(
data: RelatedArticlesSection,
articles: ReadonlyArray<BlogArticleRow>
): TechStackRelatedArticleCard[] {
if (articles.length > 0) {
return blogArticlesToTechStackRelatedCards(articles)
}
return (
data.items?.map((item) => ({
title: item.title,
mobileTitle: item.mobileTitle,
imageSrc: item.image.src,
imageAlt: item.image.alt,
imagePosition: item.imagePosition,
date: item.date,
author: item.author,
readingTime: item.readingTime,
href: item.href,
})) ?? blogArticlesToTechStackRelatedCards(articles)
)
}