diff --git a/packages/ember/dummy-docs/packages/ember/components/docfy-with-hyphenated-number-2-demo/demo1.md b/packages/ember/dummy-docs/packages/ember/components/docfy-with-hyphenated-number-2-demo/demo1.md index 2a19866..726eabd 100644 --- a/packages/ember/dummy-docs/packages/ember/components/docfy-with-hyphenated-number-2-demo/demo1.md +++ b/packages/ember/dummy-docs/packages/ember/components/docfy-with-hyphenated-number-2-demo/demo1.md @@ -4,14 +4,13 @@ order: 1 # Demo of DocfyLink component -This is a cool feature. - [Link from a demo](../docfy-output.md) ```hbs template
This is my Demo: + Assertable DOM node My Link
{{this.url}}
diff --git a/packages/ember/src/plugins/utils.ts b/packages/ember/src/plugins/utils.ts index d5a7600..245c8de 100644 --- a/packages/ember/src/plugins/utils.ts +++ b/packages/ember/src/plugins/utils.ts @@ -153,6 +153,9 @@ export function generateDemoComponentName( .replace(/(\w)(\w*)/g, function (_, g1, g2) { return `${g1.toUpperCase()}${g2.toLowerCase()}`; }) + .replace(/-(\d+)/g, function (_, g1) { + return `_${g1}`; + }) .replace(/-/g, ''); if (seenNames.has(dashCase)) { diff --git a/packages/ember/tests/acceptance/extracted-demos-test.ts b/packages/ember/tests/acceptance/extracted-demos-test.ts index 79feb52..fbfa77b 100644 --- a/packages/ember/tests/acceptance/extracted-demos-test.ts +++ b/packages/ember/tests/acceptance/extracted-demos-test.ts @@ -117,4 +117,16 @@ module('Acceptance | extracted demos', function (hooks) { assert.strictEqual(demosAll?.length, 2); }); + + test('it correctly resolves demo components with hyphenated numbers', async function (assert) { + await visit('/docs/ember/components/docfy-with-hyphenated-number-2'); + + // Since this page has a hyphenated number in it, demo components must be transformed with + // preceding underscores like this: + // + + assert + .dom('.docfy-demo__example .hyphenated-demo') + .hasText('Assertable DOM node'); + }); });