1
0
mirror of https://github.com/trambarhq/relaks-wordpress-example.git synced 2025-09-24 22:41:31 +02:00

Fixed image links (issue #31).

This commit is contained in:
Chung Leong
2019-01-28 12:26:29 +01:00
parent f85e712337
commit d1fd76c1d4

View File

@@ -147,7 +147,13 @@ class Route {
transformNode = (node) => {
if (node.type === 'tag') {
let { siteURL } = this.params;
if (node.name === 'a') {
} else if (node.name === 'img') {
// prepend image URL with site URL
if (node.attribs.src && !_.startsWith(node.attribs.src, /https?:/)) {
node.attribs.src = siteURL + node.attribs.src;
}
}
} else if (node.type === 'text') {
// trim off leading newline characters