From 18076de1147c252b8c28f2981ed49f22326d8cdb Mon Sep 17 00:00:00 2001 From: Sasha Mysak Date: Thu, 21 Dec 2023 18:34:24 +0100 Subject: [PATCH] fix(parser): more fixes --- readme-parser/parse.test.ts | 13 +++++++++++-- readme-parser/parse.ts | 16 +++++++++++++--- 2 files changed, 24 insertions(+), 5 deletions(-) diff --git a/readme-parser/parse.test.ts b/readme-parser/parse.test.ts index 9849bf60..c40c55f4 100644 --- a/readme-parser/parse.test.ts +++ b/readme-parser/parse.test.ts @@ -183,7 +183,7 @@ describe('parse/yaml', function () { deepEqual(parseResult, { name: 'Do the thing', description: - 'This is an amazing codemod which does `the thing`\n### WARNING\nThis codemod does the thing\n' + + 'This is an amazing codemod which does `the thing`\n\n### WARNING\n\nThis codemod does the thing\n' + 'Following the original msw [upgrade guide](https://mswjs.io/docs/migrations/1.x-to-2.x/#imports), ' + 'there are certain imports that changed their location and/or naming. This codemod will adjust your imports to the new location and naming.\n' + '- `setupWorker` is now imported from `msw/browser`\n' + @@ -253,9 +253,12 @@ describe('parse/yaml', function () { created-on: ${date.toISOString()} f_long-description: >- ## Description - \n + + This is an amazing codemod which does \`the thing\` + ### WARNING + This codemod does the thing Following the original msw [upgrade guide](https://mswjs.io/docs/migrations/1.x-to-2.x/#imports), there are certain imports that changed their location and/or naming. This codemod will adjust your imports to the new location and naming. - \`setupWorker\` is now imported from \`msw/browser\` @@ -324,6 +327,12 @@ f_estimated-time-saving: >- tags: automations updated-on: ${date.toISOString()} published-on: ${date.toISOString()} +seo: + title: Msw V2 - Do the thing | Intuita Automations + og:title: Msw V2 - Do the thing | Intuita Automations + twitter:title: Msw V2 - Do the thing | Intuita Automations + description: This is an amazing codemod which does \`the thing\` + twitter:card: This is an amazing codemod which does \`the thing\` `.trim(), ); }); diff --git a/readme-parser/parse.ts b/readme-parser/parse.ts index 2ce5708c..360f03b1 100644 --- a/readme-parser/parse.ts +++ b/readme-parser/parse.ts @@ -145,9 +145,12 @@ const getTextByHeader = ( idx === 0 && (child.type === 'text' || child.type === 'inlineCode') ) { - return `${delimiter}${'#'.repeat(rc.depth)} ${ - child.value - }${delimiter}`; + const conditionalDelimiter = delimiter.repeat( + isDescription ? 2 : 1, + ); + return `${conditionalDelimiter}${'#'.repeat( + rc.depth, + )} ${child.value}${conditionalDelimiter}`; } if (child.type === 'inlineCode') { @@ -414,6 +417,7 @@ export const convertToYaml = ( titleWithVersion = `${framework} - ${title}`; } } + titleWithVersion = capitalize(titleWithVersion); const res = ` created-on: ${new Date().toISOString()} @@ -452,6 +456,12 @@ f_estimated-time-saving: ${ tags: automations updated-on: ${new Date().toISOString()} published-on: ${new Date().toISOString()} +seo: + title: ${titleWithVersion} | Intuita Automations + og:title: ${titleWithVersion} | Intuita Automations + twitter:title: ${titleWithVersion} | Intuita Automations + description: ${description.split('\n').at(0)} + twitter:card: ${description.split('\n').at(0)} `.trim(); return res;