-
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
28 changed files
with
203 additions
and
214 deletions.
There are no files selected for viewing
Binary file not shown.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
import type { CollectionEntry } from 'astro:content'; | ||
import type { BaseDTO } from '@shared/application/dto/baseDTO.ts'; | ||
import { DEFAULT_DATE_FORMAT } from 'src/consts'; | ||
import MarkdownIt from 'markdown-it'; | ||
import { generateExcerpt } from '@shared/application/utils/generateExcerpt'; | ||
import { getEntry } from "astro:content"; | ||
|
||
const parser: MarkdownIt = new MarkdownIt(); | ||
|
||
export enum ArticleType { | ||
DEFAULT = "default", | ||
NO_IMAGE = "no_image", | ||
} | ||
|
||
export interface ArticleData { | ||
author: CollectionEntry<"authors">; | ||
description: string; | ||
publishDate: string; | ||
variant: ArticleType; | ||
} | ||
|
||
export type ArticleDTO = { | ||
data: ArticleData; | ||
} & CollectionEntry<"articles"> | ||
|
||
|
||
export const articleDTO: BaseDTO<CollectionEntry<"articles">, ArticleDTO, Promise<ArticleDTO>> = { | ||
render: async (raw: CollectionEntry<"articles">): Promise<ArticleDTO> => { | ||
const author = await getEntry(raw.data.author.collection, raw.data.author.slug) | ||
const description = raw.data.description ?? generateExcerpt({ parser, content: raw.body }).excerpt | ||
const publishDate = new Date(raw.data.publishDate).toLocaleDateString("en", DEFAULT_DATE_FORMAT) | ||
const variant: ArticleType = raw.data.featuredImage ? ArticleType.DEFAULT : ArticleType.NO_IMAGE | ||
|
||
return { | ||
...raw, | ||
data: { | ||
...raw.data, | ||
author, | ||
description, | ||
publishDate, | ||
variant, | ||
}, | ||
} | ||
}, | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
2 changes: 1 addition & 1 deletion
2
src/ui/components/molecules/breadcrumbs/utils/generateBreadcrumbs/generateBreadcrumbs.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
26 changes: 3 additions & 23 deletions
26
src/ui/components/organisms/aboutLatestArticles/AboutLatestArticles.astro
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.