Skip to content

Commit 1dd2b37

Browse files
apercugnavvy
authored andcommitted
Rewrite doc images links for Github & Web (visgl#197)
Related to visgl#195.
1 parent 1ea135e commit 1dd2b37

10 files changed

Lines changed: 25 additions & 10 deletions

File tree

demo/src/javascripts/components/markdown-page.js

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,11 @@ const urlRewrites = {
2222
'/docs/64-bits.md': '#/documentation/advanced-topics/64-layers'
2323
};
2424

25+
/**
26+
* Same as above, but for image src's
27+
*/
28+
const imageRewrites = {};
29+
2530
export default class MarkdownPage extends Component {
2631

2732
render() {
@@ -43,9 +48,19 @@ export default class MarkdownPage extends Component {
4348
return `<a href=${to} title=${title}>${text}</a>`;
4449
};
4550

51+
renderer.image = (href, title, text) => {
52+
const src = imageRewrites[href] || href;
53+
return `<img src=${src} title=${title} alt=${text} />`;
54+
};
55+
56+
// Since some images are embedded as html, it won't be processed by
57+
// the renderer image override. So hard replace it globally.
58+
const __html = marked(content, {renderer})
59+
.replace(/\/demo\/src\/static\/images/g, 'images');
60+
4661
return (
4762
<div className="markdown">
48-
<div className="markdown-body" dangerouslySetInnerHTML={{__html: marked(content, {renderer})}} />
63+
<div className="markdown-body" dangerouslySetInnerHTML={{__html}} />
4964
</div>
5065
);
5166
}

docs/layers/arc-layer-64.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ The Arc Layer takes in paired latitude and longitude coordinated points and
44
render them as arcs that links the starting and ending points.
55

66
<div align="center">
7-
<img height="300" src="images/demo-thumb-arc.jpg" />
7+
<img height="300" src="/demo/src/static/images/demo-thumb-arc.jpg" />
88
</div>
99

1010
Check out the [64 bit about page](/docs/64-bits.md) for more info.

docs/layers/arc-layer.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ The Arc Layer takes in paired latitude and longitude coordinated points and
44
render them as arcs that links the starting and ending points.
55

66
<div align="center">
7-
<img height="300" src="images/demo-thumb-arc.jpg" />
7+
<img height="300" src="/demo/src/static/images/demo-thumb-arc.jpg" />
88
</div>
99

1010
import {ArcLayer} from 'deck.gl';

docs/layers/choropleth-layer-64.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ The Choropleth Layer takes in [GeoJson](http://geojson.org/) formatted data and
44
renders it as interactive choropleths.
55

66
<div align="center">
7-
<img height="300" src="images/demo-thumb-choropleth.jpg" />
7+
<img height="300" src="/demo/src/static/images/demo-thumb-choropleth.jpg" />
88
</div>
99

1010
Check out the [64 bit about page](/docs/64-bits.md) for more info.

docs/layers/choropleth-layer.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ The Choropleth Layer takes in [GeoJson](http://geojson.org/) formatted data and
44
renders it as interactive choropleths.
55

66
<div align="center">
7-
<img height="300" src="images/demo-thumb-choropleth.jpg" />
7+
<img height="300" src="/demo/src/static/images/demo-thumb-choropleth.jpg" />
88
</div>
99

1010
import {ChoroplethLayer} from 'deck.gl';

docs/layers/line-layer-64.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ The Line Layer takes in paired latitude and longitude coordinated points and
44
render them as arcs that links the starting and ending points.
55

66
<div align="center">
7-
<img height="300" src="images/demo-thumb-line.jpg" />
7+
<img height="300" src="/demo/src/static/images/demo-thumb-line.jpg" />
88
</div>
99

1010
Check out the [64 bit about page](/docs/64-bits.md) for more info.

docs/layers/line-layer.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ The Line Layer takes in paired latitude and longitude coordinated points and
44
render them as arcs that links the starting and ending points.
55

66
<div align="center">
7-
<img height="300" src="images/demo-thumb-line.jpg" />
7+
<img height="300" src="/demo/src/static/images/demo-thumb-line.jpg" />
88
</div>
99

1010
import {LineLayer} from 'deck.gl';

docs/layers/scatterplot-layer-64.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ The Scatterplot Layer takes in paride latitude and longitude coordinated
44
points and render them as circles with a certain radius.
55

66
<div align="center">
7-
<img height="300" src="images/demo-thumb-scatterplot.jpg" />
7+
<img height="300" src="/demo/src/static/images/demo-thumb-scatterplot.jpg" />
88
</div>
99

1010
Check out the [64 bit about page](/docs/64-bits.md) for more info.

docs/layers/scatterplot-layer.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ The Scatterplot Layer takes in paired latitude and longitude coordinated
44
points and renders them as circles with a certain radius.
55

66
<div align="center">
7-
<img height="300" src="images/demo-thumb-scatterplot.jpg" />
7+
<img height="300" src="/demo/src/static/images/demo-thumb-scatterplot.jpg" />
88
</div>
99

1010
import {ScatterplotLayer} from 'deck.gl';

docs/layers/screen-grid-layer.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ This means that this layer is best used with small data set, however the
1010
visuals when used with the right data set can be quite effective.
1111

1212
<div align="center">
13-
<img height="300" src="images/demo-thumb-screengrid.jpg" />
13+
<img height="300" src="/demo/src/static/images/demo-thumb-screengrid.jpg" />
1414
</div>
1515

1616
import {ScreenGridLayer} from 'deck.gl';

0 commit comments

Comments
 (0)