Skip to content

Commit cdd1744

Browse files
[docs] Fix hydration error
1 parent b3ec703 commit cdd1744

File tree

2 files changed

+11
-7
lines changed

2 files changed

+11
-7
lines changed

docs/src/modules/components/MarkdownDocs.js

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -177,6 +177,11 @@ function MarkdownDocs(props) {
177177
<Ad />
178178
</Portal>
179179
)}
180+
<svg style={{ display: 'none' }} xmlns="http://www.w3.org/2000/svg">
181+
<symbol id="icons--fragment-link" viewBox="0 0 16 16">
182+
<path d="M4 9h1v1H4c-1.5 0-3-1.69-3-3.5S2.55 3 4 3h4c1.45 0 3 1.69 3 3.5 0 1.41-.91 2.72-2 3.25V8.59c.58-.45 1-1.27 1-2.09C10 5.22 8.98 4 8 4H4c-.98 0-2 1.22-2 2.5S3 9 4 9zm9-3h-1v1h1c1 0 2 1.22 2 2.5S13.98 12 13 12H9c-.98 0-2-1.22-2-2.5 0-.83.42-1.64 1-2.09V6.25c-1.09.53-2 1.84-2 3.25C6 11.31 7.55 13 9 13h4c1.45 0 3-1.69 3-3.5S14.5 6 13 6z" />
183+
</symbol>
184+
</svg>
180185
<AppContent disableAd={disableAd} disableToc={disableToc}>
181186
{!disableEdit ? (
182187
<div className={classes.header}>

docs/src/modules/components/MarkdownElement.js

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -27,16 +27,15 @@ renderer.heading = (text, level) => {
2727
}
2828

2929
// eslint-disable-next-line no-underscore-dangle
30-
const escapedText = textToHash(text, global.__MARKED_UNIQUE__);
30+
const hash = textToHash(text, global.__MARKED_UNIQUE__);
3131

3232
return [
3333
`<h${level}>`,
34-
`<a class="anchor-link" id="${escapedText}"></a>${text}`,
35-
typeof window !== 'undefined'
36-
? `<a class="anchor-link-style" aria-label="anchor" href="#${escapedText}">` +
37-
`<svg viewBox="0 0 16 16" xmlns="http://www.w3.org/2000/svg"><path d="M4 9h1v1H4c-1.5 0-3-1.69-3-3.5S2.55 3 4 3h4c1.45 0 3 1.69 3 3.5 0 1.41-.91 2.72-2 3.25V8.59c.58-.45 1-1.27 1-2.09C10 5.22 8.98 4 8 4H4c-.98 0-2 1.22-2 2.5S3 9 4 9zm9-3h-1v1h1c1 0 2 1.22 2 2.5S13.98 12 13 12H9c-.98 0-2-1.22-2-2.5 0-.83.42-1.64 1-2.09V6.25c-1.09.53-2 1.84-2 3.25C6 11.31 7.55 13 9 13h4c1.45 0 3-1.69 3-3.5S14.5 6 13 6z"/></svg>` +
38-
`</a>`
39-
: null,
34+
`<a class="anchor-link" id="${hash}"></a>`,
35+
text,
36+
`<a class="anchor-link-style" aria-hidden="true" href="#${hash}">`,
37+
'<svg><use xlink:href="#icons--fragment-link" /></svg>',
38+
'</a>',
4039
`</h${level}>`,
4140
].join('');
4241
};

0 commit comments

Comments
 (0)