Skip to content

Commit

Permalink
feat(documentation): fix autolink headings
Browse files Browse the repository at this point in the history
  • Loading branch information
davidritter-dotcom committed Jul 17, 2024
1 parent 38a9af3 commit c032144
Show file tree
Hide file tree
Showing 4 changed files with 11 additions and 88 deletions.
2 changes: 2 additions & 0 deletions packages/documentation/.storybook/main.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import type { StorybookConfig } from '@storybook/web-components-vite';
import pkg from '@/../package.json';
import { mergeConfig } from 'vite';
import rehypeSlug from 'rehype-slug';
import rehypeAutolinkHeadings from 'rehype-autolink-headings';

const config: StorybookConfig = {
Expand Down Expand Up @@ -30,6 +31,7 @@ const config: StorybookConfig = {
mdxPluginOptions: {
mdxCompileOptions: {
rehypePlugins: [
rehypeSlug,
[
rehypeAutolinkHeadings,
{
Expand Down
4 changes: 2 additions & 2 deletions packages/documentation/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -74,8 +74,8 @@
"react": "18.3.1",
"react-dom": "18.3.1",
"react-syntax-highlighter": "15.5.0",
"rehype-autolink-headings": "^7.1.0",
"remark-autolink-headings": "7.0.1",
"rehype-autolink-headings": "7.1.0",
"rehype-slug": "6.0.0",
"rimraf": "6.0.1",
"sass": "1.77.6",
"storybook": "8.1.11",
Expand Down
2 changes: 1 addition & 1 deletion packages/documentation/public/assets/scripts/autolink.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ window.addEventListener('storybook:contentReady', function () {
links.forEach(link => {
const anchor = link.getAttribute('href');
if (anchor.startsWith('#')) {
link.setAttribute('href', `${window.parent.location.href}${anchor}`);
link.setAttribute('href', `${window.parent.location.href.replace(/#.*/, '')}${anchor}`);
}
});
});
91 changes: 6 additions & 85 deletions pnpm-lock.yaml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit c032144

Please sign in to comment.