File tree Expand file tree Collapse file tree 3 files changed +19
-6
lines changed Expand file tree Collapse file tree 3 files changed +19
-6
lines changed Original file line number Diff line number Diff line change @@ -56,7 +56,12 @@ module.exports = {
56
56
} ,
57
57
} ,
58
58
'gatsby-remark-autolink-headers' ,
59
- 'gatsby-remark-codepen-examples' ,
59
+ {
60
+ resolve : 'gatsby-remark-codepen-examples' ,
61
+ options : {
62
+ directory : 'examples' ,
63
+ } ,
64
+ } ,
60
65
'gatsby-remark-use-jsx' ,
61
66
{
62
67
resolve : 'gatsby-remark-prismjs' ,
Original file line number Diff line number Diff line change @@ -171,7 +171,7 @@ exports.createPages = async ({graphql, boundActionCreators}) => {
171
171
// Create Codepen redirects.
172
172
// These use the Codepen prefill API to JIT-create Pens.
173
173
// https://blog.codepen.io/documentation/api/prefill/
174
- const files = await recursiveReaddir ( './codepen ' ) ;
174
+ const files = await recursiveReaddir ( './examples ' ) ;
175
175
files . forEach ( file => {
176
176
const slug = file . substring ( 0 , file . length - 3 ) ; // Trim extension
177
177
const code = readFileSync ( file , 'utf8' ) ;
Original file line number Diff line number Diff line change @@ -6,15 +6,23 @@ const CODEPEN_PROTOCOL = 'codepen://';
6
6
const DEFAULT_LINK_TEXT = 'Try it on CodePen' ;
7
7
8
8
// TODO target="_blank"
9
- module . exports = ( { markdownAST} ) => {
9
+ module . exports = ( { markdownAST} , { directory } ) => {
10
10
map ( markdownAST , ( node , index , parent ) => {
11
+ if ( ! directory . startsWith ( '/' ) ) {
12
+ directory = `/${ directory } ` ;
13
+ }
14
+
15
+ if ( ! directory . endsWith ( '/' ) ) {
16
+ directory = `${ directory } /` ;
17
+ }
18
+
11
19
// eg convert
12
20
// from: [](codepen:introducing-jsx)
13
- // to: <a href="https://github.com/codepen /introducing-jsx" target="_blank">Try it on CodePen</a>
21
+ // to: <a href="https://github.com/<directory> /introducing-jsx" target="_blank">Try it on CodePen</a>
14
22
// from: [Try the Hello World example on CodePen](codepen:hello-world)
15
- // to: <a href="https://github.com/codepen /hello-world" target="_blank">Try the Hello World example on CodePen</a>
23
+ // to: <a href="https://github.com/<directory> /hello-world" target="_blank">Try the Hello World example on CodePen</a>
16
24
if ( node . type === 'link' && node . url . startsWith ( CODEPEN_PROTOCOL ) ) {
17
- const href = node . url . replace ( CODEPEN_PROTOCOL , '/codepen/' ) ;
25
+ const href = node . url . replace ( CODEPEN_PROTOCOL , ` ${ directory } ` ) ;
18
26
const text =
19
27
node . children . length === 0 ? DEFAULT_LINK_TEXT : node . children [ 0 ] . value ;
20
28
You can’t perform that action at this time.
0 commit comments