-
Notifications
You must be signed in to change notification settings - Fork 4.1k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
docs(CodeSandbox): fix paths for images in exported examples (#3758)
- Loading branch information
1 parent
a6e5824
commit 2720a2d
Showing
4 changed files
with
41 additions
and
7 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
26 changes: 26 additions & 0 deletions
26
docs/src/components/ComponentDoc/ComponentControls/createPackageJson.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
import * as _ from 'lodash' | ||
import { externals } from 'docs/src/components/ComponentDoc/ExampleEditor/renderConfig' | ||
|
||
const name = 'semantic-ui-example' | ||
const description = 'An exported example from Semantic UI React, https://react.semantic-ui.com/' | ||
const dependencies = { | ||
..._.mapValues(externals, () => 'latest'), | ||
// required to enable all features due old templates in https://github.com/codesandbox/codesandbox-importers | ||
'react-scripts': 'latest', | ||
} | ||
|
||
const createPackageJson = () => ({ | ||
content: JSON.stringify( | ||
{ | ||
name, | ||
version: '1.0.0', | ||
description, | ||
main: 'index.js', | ||
dependencies, | ||
}, | ||
null, | ||
2, | ||
), | ||
}) | ||
|
||
export default createPackageJson |
8 changes: 8 additions & 0 deletions
8
docs/src/components/ComponentDoc/ComponentControls/enhanceExampleCode.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
const imagesRegex = /\/images\//gm | ||
|
||
const enhanceExampleCode = (code) => { | ||
// To have absolute paths on CodeSandbox for images | ||
return code.replace(imagesRegex, 'https://react.semantic-ui.com/images/') | ||
} | ||
|
||
export default enhanceExampleCode |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters