From f17b92a8036ccb8374c9ba87e7d8a21398b722cb Mon Sep 17 00:00:00 2001 From: haril song Date: Fri, 28 Jun 2024 12:24:05 +0900 Subject: [PATCH] . --- src/jekyll/FrontMatterConverter.ts | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/src/jekyll/FrontMatterConverter.ts b/src/jekyll/FrontMatterConverter.ts index cc048f1a..a4e86fc1 100644 --- a/src/jekyll/FrontMatterConverter.ts +++ b/src/jekyll/FrontMatterConverter.ts @@ -38,23 +38,24 @@ ${Object.entries(result) ${body}`; const convert = (frontMatter: FrontMatter) => { + const fm = { ...frontMatter }; // if not around front matter title using double quote, add double quote - frontMatter.title = frontMatter.title?.startsWith('"') ? frontMatter.title : `"${frontMatter.title}"`; + fm.title = fm.title?.startsWith('"') ? fm.title : `"${fm.title}"`; // if not around front matter categories using an array, add an array - if (frontMatter.categories && JSON.stringify(frontMatter.categories).startsWith('[')) { - frontMatter.categories = `${JSON.stringify(frontMatter.categories) + if (fm.categories && JSON.stringify(fm.categories).startsWith('[')) { + fm.categories = `${JSON.stringify(fm.categories) .replace(/,/g, ', ') .replace(/"/g, '') }`; } - // if frontMatter.tags is array - if (frontMatter.tags) { - frontMatter.tags = Array.isArray(frontMatter.tags) ? `[${frontMatter.tags.join(', ')}]` : `[${frontMatter.tags}]`; + // if fm.tags is array + if (fm.tags) { + fm.tags = Array.isArray(fm.tags) ? `[${fm.tags.join(', ')}]` : `[${fm.tags}]`; } - return frontMatter; + return fm; }; export class FrontMatterConverter implements Converter { @@ -122,7 +123,6 @@ function convertImageFrontMatter( return frontMatter; } - const match = ObsidianRegex.ATTACHMENT_LINK.exec(frontMatter.image); if (match) { frontMatter.image = `${match[1]}.${match[2]}`;