Add storefront blog pages with nav, templates, and SEO meta.
Wire blogEnabled into shop render locals and expose public blog index and detail routes when the shop toggle is on.
This commit is contained in:
@@ -0,0 +1,27 @@
|
||||
import { Injectable } from '@nestjs/common';
|
||||
import { getBlogImagePublicUrl } from '../../../config/uploadPaths';
|
||||
import { BlogPost } from '../../blog/entities/BlogPost';
|
||||
import type { StorefrontBlogPostCardView } from '../types/StorefrontBlogPostCardView';
|
||||
import type { StorefrontBlogPostDetailView } from '../types/StorefrontBlogPostDetailView';
|
||||
|
||||
@Injectable()
|
||||
export class StorefrontBlogViewService {
|
||||
toPostsIndexView(posts: BlogPost[]): StorefrontBlogPostCardView[] {
|
||||
return posts.map(post => ({
|
||||
id: post.id,
|
||||
title: post.title,
|
||||
thumbnailUrl: post.thumbnailStorageKey ? getBlogImagePublicUrl(post.thumbnailStorageKey) : null,
|
||||
detailHref: `/shop/blog/${post.id}`
|
||||
}));
|
||||
}
|
||||
|
||||
toPostDetailView(post: BlogPost): StorefrontBlogPostDetailView {
|
||||
return {
|
||||
id: post.id,
|
||||
title: post.title,
|
||||
bannerUrl: post.bannerStorageKey ? getBlogImagePublicUrl(post.bannerStorageKey) : null,
|
||||
thumbnailUrl: post.thumbnailStorageKey ? getBlogImagePublicUrl(post.thumbnailStorageKey) : null,
|
||||
contentHtml: post.contentHtml
|
||||
};
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user