diff --git a/.changeset/cold-bears-sneeze.md b/.changeset/cold-bears-sneeze.md deleted file mode 100644 index 483d87cd3..000000000 --- a/.changeset/cold-bears-sneeze.md +++ /dev/null @@ -1,5 +0,0 @@ ---- -'@astrojs/markdown-remark': minor ---- - -fixed generated slugs in markdown that ends with a dash diff --git a/packages/markdown/remark/src/rehype-collect-headers.ts b/packages/markdown/remark/src/rehype-collect-headers.ts index 50a9c5da1..f8cedd0d5 100644 --- a/packages/markdown/remark/src/rehype-collect-headers.ts +++ b/packages/markdown/remark/src/rehype-collect-headers.ts @@ -53,11 +53,7 @@ export default function createCollectHeaders() { node as any ).value = `<${node.tagName} id={${node.properties.id}}>${raw}`; } else { - let slug = slugger.slug(text); - - if (slug.endsWith('-')) slug = slug.slice(0, -1); - - node.properties.id = slug; + node.properties.id = slugger.slug(text); } } diff --git a/packages/markdown/remark/test/expressions.test.js b/packages/markdown/remark/test/expressions.test.js index 828f70561..db351f9d8 100644 --- a/packages/markdown/remark/test/expressions.test.js +++ b/packages/markdown/remark/test/expressions.test.js @@ -54,7 +54,7 @@ describe('expressions', () => { chai .expect(code) .to.equal( - '

{ foo } is a shorthand for { foo: foo }

' + '

{ foo } is a shorthand for { foo: foo }

' ); });