feat: thumbnail assets
All checks were successful
ci/woodpecker/push/woodpecker Pipeline was successful

This commit is contained in:
Damillora 2024-12-03 00:56:25 +07:00
parent f198ec4e40
commit 5686c93ba3

View File

@ -8,6 +8,14 @@ export const generateAssetUrl = (file: any) => {
return DIRECTUS_URL + "/assets/" + file.id + "/" + file.filename_download;
};
export const generateThumbnailUrl = (file: any) => {
if (!file) {
return null;
}
return DIRECTUS_URL + "/assets/" + file.id + "/" + file.filename_download + "?key=thumbnail";
};
export const generateCategoryUrl = (slug: string) => {
return "/" + slug;
}
@ -46,7 +54,7 @@ export const mapIndexPosts = (post: any) => {
return {
title: post.title,
feature_image: generateAssetUrl(post.feature_image),
feature_image: generateThumbnailUrl(post.feature_image),
authors: [author],
category: category,
excerpt: post.excerpt,
@ -77,7 +85,7 @@ export const mapAuthor = (author: any) => {
return {
name: author.name,
profile_image: generateAssetUrl(author.profile_image),
cover_image: generateAssetUrl(author.cover_image),
cover_image: generateThumbnailUrl(author.cover_image),
bio: author.bio,
url: generateAuthorUrl(author.slug),
website: author.website,
@ -96,7 +104,7 @@ export const mapCategory = (category: any) => {
url: generateCategoryUrl(category.slug),
slug: category.slug,
description: category.description,
cover_image: generateAssetUrl(category.cover_image),
cover_image: generateThumbnailUrl(category.cover_image),
}
};
@ -109,7 +117,7 @@ export const mapPost = (post: any) => {
id: post.id,
title: post.title,
status: post.status,
feature_image: generateAssetUrl(post.feature_image),
feature_image: generateThumbnailUrl(post.feature_image),
authors: [author],
primary_author: author,
category: category,