Skip to content

Commit

Permalink
style: quotation
Browse files Browse the repository at this point in the history
  • Loading branch information
fbuireu committed Aug 19, 2024
1 parent 69b0cd6 commit 4a1666c
Show file tree
Hide file tree
Showing 2 changed files with 38 additions and 38 deletions.
2 changes: 1 addition & 1 deletion src/application/dto/article/utils/renderOptions/index.ts
Original file line number Diff line number Diff line change
@@ -1 +1 @@
export * from './renderOptions';
export * from "./renderOptions";
74 changes: 37 additions & 37 deletions src/application/dto/article/utils/renderOptions/renderOptions.ts
Original file line number Diff line number Diff line change
@@ -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 `
<a href="/articles/${slug}">
${title}
</a>
`;
}
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 `
<pre>
<code>${code}</code>
</pre>
`;
}
}

if (contentTypeId === 'videoEmbed' && embedUrl && title) {
return `
if (contentTypeId === "videoEmbed" && embedUrl && title) {
return `
<iframe
src="${embedUrl}"
height="100%"
Expand All @@ -41,31 +41,31 @@ export const renderOptions = (rawArticle: RawArticle) => ({
allowfullscreen
></iframe>
`;
}
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 `
<figure class="full-bleed">
<img
src="https:${url}"
height="${height || ''}"
width="${width || ''}"
height="${height || ""}"
width="${width || ""}"
alt="${description || rawArticle.fields.title}"
loading="lazy"
decoding="async"
/>
${description ? `<figcaption>${description}</figcaption>` : ''}
${description ? `<figcaption>${description}</figcaption>` : ""}
</figure>
`;
}
return '';
},
},
}
return "";
},
},
});

0 comments on commit 4a1666c

Please sign in to comment.