diff --git a/src/data/transformPageContent.ts b/src/data/transformPageContent.ts index 41e7cac8..0997415b 100644 --- a/src/data/transformPageContent.ts +++ b/src/data/transformPageContent.ts @@ -1,3 +1,4 @@ +import {MarkdownItPluginCb} from '@doc-tools/transform/lib/plugins/typings'; import {ConstructorBlock, PageContent} from '@gravity-ui/page-constructor'; import {contentTransformer} from '@gravity-ui/page-constructor/server'; import yaml from 'js-yaml'; @@ -16,15 +17,17 @@ type TransformPageContentPropsType = { lang: Lang; region?: string; typographyConfig?: TypographyConfigType; + plugins?: MarkdownItPluginCb[]; }; type TransformBlocksPropsType = { blocks: ConstructorBlock[]; lang: Lang; typographyConfig?: TypographyConfigType; + plugins?: MarkdownItPluginCb[]; }; -const transformer = ({blocks, lang, typographyConfig}: TransformBlocksPropsType) => +const transformer = ({blocks, lang, typographyConfig, plugins}: TransformBlocksPropsType) => contentTransformer({ content: { blocks: blocks || [], @@ -35,6 +38,7 @@ const transformer = ({blocks, lang, typographyConfig}: TransformBlocksPropsType) ...typographyConfig, ...getExtendTypographyConfig(), }, + plugins, }, }); @@ -45,6 +49,7 @@ const transformer = ({blocks, lang, typographyConfig}: TransformBlocksPropsType) * @param lang - runtime app lang * @param region - runtime app region * @param typographyConfig - page-constructor extend typography config + * @param plugins - YFM plugins * @returns transformed content */ export const transformPageContent = ({ @@ -52,6 +57,7 @@ export const transformPageContent = ({ lang, region, typographyConfig = {}, + plugins, }: TransformPageContentPropsType) => { try { const transformedContent = filterContent(yaml.load(content) as PageContent, {lang, region}); @@ -61,6 +67,7 @@ export const transformPageContent = ({ blocks: transformedContent.blocks, lang, typographyConfig, + plugins, }); transformedContent.blocks = transformedBlocks; diff --git a/src/data/transformPost.ts b/src/data/transformPost.ts index cf014ad0..51ac451e 100644 --- a/src/data/transformPost.ts +++ b/src/data/transformPost.ts @@ -1,6 +1,6 @@ import {typografToHTML, typografToText, yfmTransformer} from '@gravity-ui/page-constructor/server'; -import {PostData} from '../models/common'; +import {PostData, TransformPostOptions} from '../models/common'; import {Lang} from '../models/locale'; /** @@ -9,9 +9,14 @@ import {Lang} from '../models/locale'; * @param postData - post data * @param lang - runtime language * + * @param plugins - YFM plugins list * @returns -prepared post */ -export const transformPost = (postData: PostData, lang: Lang) => { +export const transformPost = ( + postData: PostData, + lang: Lang, + {plugins}: TransformPostOptions = {}, +) => { if (!postData) { // eslint-disable-next-line no-console console.error('Post not found'); @@ -28,6 +33,6 @@ export const transformPost = (postData: PostData, lang: Lang) => { textTitle: typografToText(title, lang), htmlTitle: typografToHTML(title, lang), metaTitle: metaTitle || title, - description: yfmTransformer(lang, description as string), + description: yfmTransformer(lang, description as string, {plugins}), }; }; diff --git a/src/models/common.ts b/src/models/common.ts index 9d1a0390..9b50803a 100644 --- a/src/models/common.ts +++ b/src/models/common.ts @@ -1,5 +1,6 @@ import {ReactNode} from 'react'; +import {MarkdownItPluginCb} from '@doc-tools/transform/lib/plugins/typings'; import {HeaderBlockProps as PageConstructorHeaderBlockProps} from '@gravity-ui/page-constructor'; import {IBrowser, IDevice} from 'ua-parser-js'; @@ -211,3 +212,7 @@ export enum PostCardTitleHeadingLevel { H2 = 'h2', H3 = 'h3', } + +export interface TransformPostOptions { + plugins?: MarkdownItPluginCb[]; +}