File tree Expand file tree Collapse file tree 1 file changed +11
-0
lines changed
Expand file tree Collapse file tree 1 file changed +11
-0
lines changed Original file line number Diff line number Diff line change @@ -98,6 +98,16 @@ async function buildVersionMenu(versions, currentVersion) {
9898}
9999
100100const marked = new Marked ( ) ;
101+ const customRenderer = {
102+ link ( { href, text } ) {
103+ const isExternal = / ^ h t t p s ? : \/ \/ / . test ( href ) ;
104+ let html = `<a href="${ href } "` ;
105+ if ( isExternal ) html += ' target="_blank"' ;
106+ html += `>${ text } </a>` ;
107+ return html ;
108+ }
109+ } ;
110+ marked . use ( { renderer : customRenderer } ) ;
101111
102112let blogMenu = '' ;
103113async function buildBlogMenu ( ) {
@@ -137,6 +147,7 @@ async function build() {
137147 let htmlFileName = '' ;
138148
139149 const markedWithContents = new Marked ( ) ;
150+ markedWithContents . use ( { renderer : customRenderer } ) ;
140151 markedWithContents . use ( gfmHeadingId ( { prefix : 'block-' } ) , {
141152 hooks : {
142153 postprocess ( html ) {
You can’t perform that action at this time.
0 commit comments