mirror of
https://github.com/facebook/docusaurus.git
synced 2025-07-26 04:57:50 +02:00
chore(v2): ability to test the migration cli easily (#3113)
* ability to test the migration cli easily * add node scripts to help test migration cli (locally + CI) * add test for frontmatter quotify * more tests for shouldQuotifyFrontMatter * typo * updated yarn lock
This commit is contained in:
parent
6aec331963
commit
a0ef8939a1
7 changed files with 69 additions and 20 deletions
|
@ -50,3 +50,27 @@ export default function extractMetadata(content: string): Data {
|
|||
}
|
||||
return {metadata, rawContent: both.content};
|
||||
}
|
||||
|
||||
// The new frontmatter parser need some special chars to
|
||||
export function shouldQuotifyFrontMatter([key, value]: [
|
||||
string,
|
||||
string,
|
||||
]): boolean {
|
||||
if (key === 'tags') {
|
||||
return false;
|
||||
}
|
||||
if (String(value).match(/^("|').+("|')$/)) {
|
||||
return false;
|
||||
}
|
||||
// TODO weird graymatter case
|
||||
// title: !something need quotes
|
||||
// but not title: something!
|
||||
if (!String(value).trim().match(/^\w.*/)) {
|
||||
return true;
|
||||
}
|
||||
// TODO this is not ideal to have to maintain such a list of allowed chars
|
||||
// maybe we should quotify if graymatter throws instead?
|
||||
return !String(value).match(
|
||||
/^([\w .\-sàáâãäåçèéêëìíîïðòóôõöùúûüýÿ!;,=+_?'`&#()[\]§%€$])+$/,
|
||||
);
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue