Skip to content

Commit bb48410

Browse files
authored
docs: fix IE11 issues in docs (#4009)
1 parent a2de6cd commit bb48410

File tree

5 files changed

+9
-45
lines changed

5 files changed

+9
-45
lines changed

docs/src/components/CodeSnippet/CodeSnippet.js

Lines changed: 4 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,5 @@
11
import _ from 'lodash'
22
import * as Prism from 'prismjs/components/prism-core'
3-
import prettier from 'prettier/standalone'
4-
import babel from 'prettier/parser-babel'
5-
import html from 'prettier/parser-html'
63
import PropTypes from 'prop-types'
74
import React from 'react'
85

@@ -16,19 +13,6 @@ import 'prismjs/components/prism-jsx'
1613

1714
import CodeSnippetLabel from './CodeSnippetLabel'
1815

19-
const prettierConfig = {
20-
htmlWhitespaceSensitivity: 'ignore',
21-
printWidth: 100,
22-
tabWidth: 2,
23-
semi: false,
24-
singleQuote: true,
25-
trailingComma: 'all',
26-
plugins: {
27-
babel,
28-
html,
29-
},
30-
}
31-
3216
const normalizeToString = (value) => {
3317
if (Array.isArray(value)) {
3418
return value.join('\n')
@@ -37,22 +21,12 @@ const normalizeToString = (value) => {
3721
return _.isObject(value) ? JSON.stringify(value, null, 2) : value
3822
}
3923

40-
export const prettifyCode = (code, parser) => {
41-
const formatted = prettier.format(code, {
42-
...prettierConfig,
43-
// a narrower print width is more friendly to doc examples
44-
parser,
45-
})
46-
47-
return formatted.replace(/^;</m, '<') // remove beginning semi in JSX/HTML
48-
}
49-
5024
const formatters = {
5125
bash: (val = '') => val.replace(/^[\w]/gm, '$$ $&'),
52-
json: (val) => prettifyCode(val, 'json'),
53-
js: (val = '') => prettifyCode(val, 'babel'),
54-
jsx: (val = '') => prettifyCode(val, 'babel'),
55-
html: (val = '') => prettifyCode(val, 'html'),
26+
json: (val) => val,
27+
js: (val = '') => val,
28+
jsx: (val = '') => val,
29+
html: (val = '') => val,
5630
}
5731

5832
export const formatCode = (code, mode) => {

docs/src/components/Document.js

Lines changed: 1 addition & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@ const Document = ({ Body, children, Head, Html, siteData: { dev, versions } }) =
2121
/>
2222

2323
<script src='https://cdn.jsdelivr.net/npm/core-js-bundle/minified.js' />
24+
<script src='https://polyfill.io/v3/polyfill.min.js?features=IntersectionObserver' />
2425
<script
2526
src={`https://cdnjs.cloudflare.com/ajax/libs/anchor-js/${versions.anchor}/anchor.min.js`}
2627
/>
@@ -29,14 +30,6 @@ const Document = ({ Body, children, Head, Html, siteData: { dev, versions } }) =
2930
/>
3031
<script src={`https://cdn.jsdelivr.net/faker.js/${versions.faker}/faker.min.js`} />
3132

32-
<script
33-
crossOrigin='true'
34-
src={`https://cdn.jsdelivr.net/npm/prettier@${versions.prettier}/standalone.min.js`}
35-
/>
36-
<script
37-
crossOrigin='true'
38-
src={`https://cdn.jsdelivr.net/combine/npm/prettier@${versions.prettier}/parser-babel.min.js,npm/prettier@${versions.prettier}/parser-html.min.js`}
39-
/>
4033
<script
4134
src={`https://cdnjs.cloudflare.com/ajax/libs/prop-types/${versions.propTypes}/prop-types${
4235
siteData.dev ? '' : '.min'

docs/src/utils/formatCode.js

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,6 @@
11
import prettier from 'prettier/standalone'
2+
import babel from 'prettier/parser-babel'
3+
24
import prettierConfig from '../../../.prettierrc.json'
35
import isBrowser from '../../../src/lib/isBrowser'
46

@@ -21,7 +23,7 @@ const formatCode = isBrowser()
2123
...prettierConfig,
2224
printWidth,
2325
parser,
24-
plugins: window.prettierPlugins,
26+
plugins: { babel },
2527
})
2628

2729
return formatted.replace(/^;</, '<') // remove beginning semi in JSX/HTML

static.config.js

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,6 @@ export default {
2121
standalone: require('@babel/standalone/package.json').version,
2222
},
2323
faker: require('faker/package.json').version,
24-
prettier: require('prettier/package.json').version,
2524
propTypes: require('prop-types/package.json').version,
2625
prismjs: require('prismjs/package.json').version,
2726
react: require('react/package.json').version,

static.webpack.js

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -21,11 +21,6 @@ export default (webpackConfig, { stage }) => ({
2121
'anchor-js': 'AnchorJS',
2222
'@babel/standalone': 'Babel',
2323
faker: 'faker',
24-
'prettier/standalone': 'prettier',
25-
// These Prettier plugins are available under window.prettierPlugins
26-
'prettier/parser-babel': 'prettierPlugins.babel',
27-
'prettier/parser-html': 'prettierPlugins.html',
28-
2924
'prop-types': 'PropTypes',
3025
react: 'React',
3126
'react-dom': 'ReactDOM',
@@ -43,6 +38,7 @@ export default (webpackConfig, { stage }) => ({
4338
path.resolve(__dirname, 'node_modules/chalk'),
4439
path.resolve(__dirname, 'node_modules/debug'),
4540
path.resolve(__dirname, 'node_modules/leven'),
41+
path.resolve(__dirname, 'node_modules/prettier'),
4642

4743
path.resolve(__dirname, 'docs'),
4844
path.resolve(__dirname, 'src'),

0 commit comments

Comments
 (0)