feat: add styling and typography method for macors

This commit is contained in:
Innei
2022-04-30 21:51:23 +08:00
parent c2709d1e3f
commit 80bb68e0aa
4 changed files with 93 additions and 34 deletions

View File

@@ -178,7 +178,7 @@ export class MarkdownController {
const { id } = params
const now = performance.now()
const [
{ html: markdown, document, type },
{ html: markdownMacros, document, type },
{
url: { webUrl },
},
@@ -212,9 +212,7 @@ export class MarkdownController {
})()
const url = new URL(relativePath!, webUrl)
const markdownMacros = this.service.renderMarkdownContent(
await this.macroService.replaceTextMacro(markdown, document),
)
const structure = await this.service.getRenderedMarkdownHtmlStructure(
markdownMacros,
document.title,

View File

@@ -15,6 +15,7 @@ import { ReturnModelType } from '@typegoose/typegoose'
import { DatabaseService } from '~/processors/database/database.service'
import { AssetService } from '~/processors/helper/helper.asset.service'
import { TextMacroService } from '~/processors/helper/helper.macro.service'
import { InjectModel } from '~/transformers/model.transformer'
import { CategoryModel } from '../category/category.model'
@@ -39,6 +40,8 @@ export class MarkdownService {
private readonly pageModel: ReturnModelType<typeof PageModel>,
private readonly databaseService: DatabaseService,
private readonly macroService: TextMacroService,
) {}
async insertPostsToDb(data: DatatypeDto[]) {
@@ -223,7 +226,12 @@ ${text.trim()}
}
return {
html: doc.document.text,
html: this.renderMarkdownContent(
await this.macroService.replaceTextMacro(
doc.document.text,
doc.document,
),
),
...doc,
document: doc.document,
}