Skip to content
This repository was archived by the owner on Apr 30, 2020. It is now read-only.

Commit b1b8473

Browse files
author
lepon01
committed
Prefix img src tags with the docs location
1 parent 92d9dd3 commit b1b8473

File tree

3 files changed

+8
-1
lines changed

3 files changed

+8
-1
lines changed

src/components/BotPageContentBox/index.js

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -138,6 +138,12 @@ class BotPageContentBox extends Component {
138138

139139
return;
140140
},
141+
onTagAttr: (tag, name, value, isWhiteAttr) => {
142+
if (tag === 'img' && name === 'src' && this.props.cdn && value.startsWith('/')) {
143+
return `src="${this.props.cdn}${value}"`
144+
}
145+
return;
146+
},
141147
onIgnoreTagAttr: (tag, name, value, isWhiteAttr) => {
142148
if (this.props.allowHTML || name === 'class') {
143149
return `${name}="${xss.escapeAttrValue(value)}"`

src/data/Locations.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ const Locations = {
44
cdn: 'https://ls.terminal.ink',
55
domain: 'https://discordapps.dev',
66
docsServer: 'https://docs.discordapps.dev',
7+
// docsServer: 'http://127.0.0.1:4000',
78
logo: 'https://ls.terminal.ink/img/logo/logo.svg',
89
favicon: 'https://ls.terminal.ink/img/logo/logo32.png',
910
sourceCode: 'https://github.com/Terminal/discordapps.dev',

src/pages/DocPage/index.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,7 @@ class DocPage extends Component {
6161
{date.toLocaleDateString(this.props.intl.locale, DateFormat)}
6262
</p>}
6363
</ContentBox>
64-
<BotPageContentBox page={page.content} forceLarge={true} allowHTML={true} />
64+
<BotPageContentBox page={page.content} forceLarge={true} allowHTML={true} cdn={Locations.docsServer} />
6565
</Container>
6666
</Layout>
6767
);

0 commit comments

Comments
 (0)