Skip to content

Commit

Permalink
.
Browse files Browse the repository at this point in the history
  • Loading branch information
songkg7 committed Jun 28, 2024
1 parent 4538e01 commit f17b92a
Showing 1 changed file with 8 additions and 8 deletions.
16 changes: 8 additions & 8 deletions src/jekyll/FrontMatterConverter.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down Expand Up @@ -122,7 +123,6 @@ function convertImageFrontMatter(
return frontMatter;
}


const match = ObsidianRegex.ATTACHMENT_LINK.exec(frontMatter.image);
if (match) {
frontMatter.image = `${match[1]}.${match[2]}`;

Check warning on line 128 in src/jekyll/FrontMatterConverter.ts

View check run for this annotation

Codecov / codecov/patch

src/jekyll/FrontMatterConverter.ts#L128

Added line #L128 was not covered by tests
Expand Down

0 comments on commit f17b92a

Please sign in to comment.