diff --git a/src/application/dto/article/utils/renderOptions/index.ts b/src/application/dto/article/utils/renderOptions/index.ts index 4ec6d40b..7986780c 100644 --- a/src/application/dto/article/utils/renderOptions/index.ts +++ b/src/application/dto/article/utils/renderOptions/index.ts @@ -1 +1 @@ -export * from './renderOptions'; +export * from "./renderOptions"; diff --git a/src/application/dto/article/utils/renderOptions/renderOptions.ts b/src/application/dto/article/utils/renderOptions/renderOptions.ts index f00e2856..ba9af0f3 100644 --- a/src/application/dto/article/utils/renderOptions/renderOptions.ts +++ b/src/application/dto/article/utils/renderOptions/renderOptions.ts @@ -1,38 +1,38 @@ -import type { Block, Inline } from '@contentful/rich-text-types'; -import { BLOCKS, INLINES } from '@contentful/rich-text-types'; -import type { RawArticle } from '@application/dto/article/types.ts'; +import type { RawArticle } from "@application/dto/article/types.ts"; +import type { Block, Inline } from "@contentful/rich-text-types"; +import { BLOCKS, INLINES } from "@contentful/rich-text-types"; type Node = Block | Inline; export const renderOptions = (rawArticle: RawArticle) => ({ - renderNode: { - [INLINES.EMBEDDED_ENTRY]: (node: Node) => { - const contentTypeId = node.data.target.sys.contentType.sys.id; - const { slug, title } = node.data.target.fields; + renderNode: { + [INLINES.EMBEDDED_ENTRY]: (node: Node) => { + const contentTypeId = node.data.target.sys.contentType.sys.id; + const { slug, title } = node.data.target.fields; - if (contentTypeId === 'article' && slug && title) { - return ` + if (contentTypeId === "article" && slug && title) { + return ` ${title} `; - } - return ''; - }, - [BLOCKS.EMBEDDED_ENTRY]: (node: Node) => { - const contentTypeId = node.data.target.sys.contentType.sys.id; - const { code, embedUrl, title } = node.data.target.fields; + } + return ""; + }, + [BLOCKS.EMBEDDED_ENTRY]: (node: Node) => { + const contentTypeId = node.data.target.sys.contentType.sys.id; + const { code, embedUrl, title } = node.data.target.fields; - if (contentTypeId === 'codeBlock' && code) { - return ` + if (contentTypeId === "codeBlock" && code) { + return `
${code}
`;
- }
+ }
- if (contentTypeId === 'videoEmbed' && embedUrl && title) {
- return `
+ if (contentTypeId === "videoEmbed" && embedUrl && title) {
+ return `
`;
- }
- return '';
- },
- [BLOCKS.EMBEDDED_ASSET]: (node: Node) => {
- const { file, description } = node.data.target.fields;
- const { url, details } = file || {};
- const { image } = details || {};
- const { height, width } = image || {};
+ }
+ return "";
+ },
+ [BLOCKS.EMBEDDED_ASSET]: (node: Node) => {
+ const { file, description } = node.data.target.fields;
+ const { url, details } = file || {};
+ const { image } = details || {};
+ const { height, width } = image || {};
- if (url) {
- return `
+ if (url) {
+ return `
`;
- }
- return '';
- },
- },
+ }
+ return "";
+ },
+ },
});