File tree 3 files changed +26
-5
lines changed
packages/docusaurus-theme-classic/src
3 files changed +26
-5
lines changed Original file line number Diff line number Diff line change @@ -14,6 +14,7 @@ import {
14
14
getAnnouncementBarInlineScript ,
15
15
DataAttributeQueryStringInlineJavaScript ,
16
16
} from './inlineScripts' ;
17
+ import { SvgSpriteSymbols } from './inlineSvgSprites' ;
17
18
import type { LoadContext , Plugin } from '@docusaurus/types' ;
18
19
import type { ThemeConfig } from '@docusaurus/theme-common' ;
19
20
import type { Plugin as PostCssPlugin } from 'postcss' ;
@@ -121,6 +122,14 @@ export default function themeClassic(
121
122
injectHtmlTags ( ) {
122
123
return {
123
124
preBodyTags : [
125
+ {
126
+ tagName : 'svg' ,
127
+ attributes : {
128
+ xmlns : 'http://www.w3.org/2000/svg' ,
129
+ style : 'display: none;' ,
130
+ } ,
131
+ innerHTML : SvgSpriteSymbols ,
132
+ } ,
124
133
{
125
134
tagName : 'script' ,
126
135
innerHTML : `
Original file line number Diff line number Diff line change
1
+ /**
2
+ * Copyright (c) Facebook, Inc. and its affiliates.
3
+ *
4
+ * This source code is licensed under the MIT license found in the
5
+ * LICENSE file in the root directory of this source tree.
6
+ */
7
+
8
+ // For icons that are heavily repeated in the static html output
9
+ // See also https://github.com/facebook/docusaurus/issues/5865
10
+ export const SvgSpriteSymbols = `
11
+ <symbol id="theme-svg-external-link" viewBox="0 0 24 24"><path fill="currentColor" d="M21 13v10h-21v-19h12v2h-10v15h17v-8h2zm3-12h-10.988l4.035 4-6.977 7.07 2.828 2.828 6.977-7.07 4.125 4.172v-11z" /></symbol>
12
+ ` ;
Original file line number Diff line number Diff line change @@ -10,6 +10,10 @@ import type {Props} from '@theme/Icon/ExternalLink';
10
10
11
11
import styles from './styles.module.css' ;
12
12
13
+ // References symbol in docusaurus-theme-classic/src/inlineSvgSprites.ts
14
+ // See why: https://github.com/facebook/docusaurus/issues/5865
15
+ const svgSprite = '#theme-svg-external-link' ;
16
+
13
17
export default function IconExternalLink ( {
14
18
width = 13.5 ,
15
19
height = 13.5 ,
@@ -19,12 +23,8 @@ export default function IconExternalLink({
19
23
width = { width }
20
24
height = { height }
21
25
aria-hidden = "true"
22
- viewBox = "0 0 24 24"
23
26
className = { styles . iconExternalLink } >
24
- < path
25
- fill = "currentColor"
26
- d = "M21 13v10h-21v-19h12v2h-10v15h17v-8h2zm3-12h-10.988l4.035 4-6.977 7.07 2.828 2.828 6.977-7.07 4.125 4.172v-11z"
27
- />
27
+ < use href = { svgSprite } />
28
28
</ svg >
29
29
) ;
30
30
}
You can’t perform that action at this time.
0 commit comments