We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent 6fd0d79 commit b9616f1Copy full SHA for b9616f1
plugins/gatsby-remark-codepen-examples/index.js
@@ -1,3 +1,5 @@
1
+const {existsSync} = require('fs');
2
+const {join} = require('path');
3
const map = require('unist-util-map');
4
5
const DEFAULT_LINK_TEXT = 'Try it on CodePen';
@@ -15,6 +17,15 @@ module.exports = ({markdownAST}) => {
15
17
const text =
16
18
node.children.length === 0 ? DEFAULT_LINK_TEXT : node.children[0].value;
19
20
+ // Verify that the specified example file exists.
21
+ const filePath = join(__dirname, `../../${href}.js`);
22
+ if (!existsSync(filePath)) {
23
+ console.log(
24
+ `Invalid Codepen link specified; no such file "${filePath}"`,
25
+ );
26
+ process.exit(1);
27
+ }
28
+
29
const anchorOpenNode = {
30
type: 'html',
31
value: `<a href="${href}" target="_blank">`,
0 commit comments