File tree Expand file tree Collapse file tree 2 files changed +11
-3
lines changed
src/theme/ReferenceCodeBlock Expand file tree Collapse file tree 2 files changed +11
-3
lines changed Original file line number Diff line number Diff line change @@ -11,6 +11,10 @@ This theme provides the following:
1111https: // github.com/saucelabs/docusaurus-theme-github-codeblock/blob/main/src/theme/ReferenceCodeBlock/index.tsx#L104-L107
1212```
1313
14+ ``` js reference title="Custom Title"
15+ https: // github.com/saucelabs/docusaurus-theme-github-codeblock/blob/main/src/theme/ReferenceCodeBlock/index.tsx#L104-L107
16+ ```
17+
1418You can write content using [ GitHub-flavored Markdown syntax] ( https://github.github.com/gfm/ ) .
1519
1620## Markdown Syntax
Original file line number Diff line number Diff line change @@ -109,11 +109,15 @@ function ReferenceCode(props: ReferenceCodeBlockProps) {
109109 fetchCode ( codeSnippetDetails , fetchResultStateDispatcher )
110110 }
111111
112+ const titleMatch = props . metastring ?. match ( / t i t l e = " (?< title > .* ) " / ) ;
113+
112114 const customProps = {
113115 ...props ,
114- metastring : ` title="${ codeSnippetDetails . title } "` ,
115- children : initialFetchResultState . code
116- }
116+ metastring : titleMatch ?. groups ?. title
117+ ? ` title="${ titleMatch ?. groups ?. title } "`
118+ : ` title="${ codeSnippetDetails . title } "` ,
119+ children : initialFetchResultState . code ,
120+ } ;
117121
118122 return (
119123 < div >
You can’t perform that action at this time.
0 commit comments