-
Notifications
You must be signed in to change notification settings - Fork 43
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
fix: **BREAKING** refactor frontmatter API #589
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I like this.
As far as I understand, this is marked as a breaking change since we'd have to modify CLI's code to use the new API, right?
src/transform/frontmatter.ts
Outdated
.replace(/^\s+/gm, '') | ||
.replace(/\n/g, ' ') | ||
.trim(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'd say we could use ts-dedent
here as well, granted that we started using it again in our codebases
const matchMetadata = (fileContent: string) => { | ||
if (!fileContent.startsWith(SEP)) { | ||
return null; | ||
} | ||
|
||
const closeStart = fileContent.indexOf('\n' + SEP, SEP.length); | ||
const closeEnd = fileContent.indexOf('\n', closeStart + 1); | ||
|
||
if (closeStart === -1) { | ||
return null; | ||
} | ||
|
||
return [fileContent.slice(SEP.length, closeStart).trim(), fileContent.slice(closeEnd + 1)]; | ||
}; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for refactoring the regexp monstrosity, I was lazy to do the same :)
const [metadata, strippedContent] = matches; | ||
|
||
return [ | ||
cloneDeepWith( |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ok, this is a fair change
Description
Убрал излишнюю декомпозицию из frontmatter.
Заменил основные методы на extractFrontMatter и composeFrontMatter.
composeFrontMatter совместим с extractFrontMatter по аргументам
Поменял логику обновления сурсмапов:
Большая пачка кода и тестов ушла из-за использования deepMergeWith