@primer/gatsby-theme-doctocat 2.0.0 → 3.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.eslintrc.json +25 -0
- package/CHANGELOG.md +44 -0
- package/babel.config.js +1 -1
- package/gatsby-config.js +10 -13
- package/gatsby-node.js +52 -42
- package/jest.config.js +1 -1
- package/package.json +16 -5
- package/src/components/__tests__/contributors.test.js +13 -15
- package/src/components/__tests__/page-footer.test.js +2 -6
- package/src/components/clipboard-copy.js +2 -2
- package/src/components/code.js +4 -15
- package/src/components/contributors.js +4 -12
- package/src/components/details.js +1 -1
- package/src/components/do-dont.js +7 -36
- package/src/components/drawer.js +3 -10
- package/src/components/head.js +1 -3
- package/src/components/header.js +13 -35
- package/src/components/heading.js +1 -1
- package/src/components/hero-layout.js +3 -5
- package/src/components/hero.js +1 -1
- package/src/components/image-container.js +2 -4
- package/src/components/layout.js +25 -44
- package/src/components/live-code.js +7 -20
- package/src/components/mobile-search.js +14 -35
- package/src/components/nav-drawer.js +15 -66
- package/src/components/nav-dropdown.js +3 -10
- package/src/components/nav-items.js +11 -20
- package/src/components/note.js +6 -6
- package/src/components/page-footer.js +5 -7
- package/src/components/search-results.js +2 -2
- package/src/components/search.js +14 -23
- package/src/components/sidebar.js +11 -12
- package/src/components/skip-link.js +1 -1
- package/src/components/status-label.js +2 -6
- package/src/components/table-of-contents.js +3 -5
- package/src/components/wrap-root-element.js +3 -1
- package/src/github.js +33 -44
- package/src/mdx-components.js +2 -0
- package/src/prism.js +16 -16
- package/src/search.worker.js +11 -8
- package/src/use-search.js +6 -7
- package/coverage/clover.xml +0 -421
- package/coverage/coverage-final.json +0 -50
- package/coverage/lcov-report/base.css +0 -224
- package/coverage/lcov-report/block-navigation.js +0 -79
- package/coverage/lcov-report/index.html +0 -125
- package/coverage/lcov-report/prettify.css +0 -1
- package/coverage/lcov-report/prettify.js +0 -2
- package/coverage/lcov-report/sort-arrow-sprite.png +0 -0
- package/coverage/lcov-report/sorter.js +0 -170
- package/coverage/lcov-report/src/components/blockquote.js.html +0 -136
- package/coverage/lcov-report/src/components/caption.js.html +0 -103
- package/coverage/lcov-report/src/components/clipboard-copy.js.html +0 -184
- package/coverage/lcov-report/src/components/code.js.html +0 -280
- package/coverage/lcov-report/src/components/container.js.html +0 -115
- package/coverage/lcov-report/src/components/contributors.js.html +0 -238
- package/coverage/lcov-report/src/components/description-list.js.html +0 -142
- package/coverage/lcov-report/src/components/details.js.html +0 -283
- package/coverage/lcov-report/src/components/do-dont.js.html +0 -283
- package/coverage/lcov-report/src/components/drawer.js.html +0 -247
- package/coverage/lcov-report/src/components/frame.js.html +0 -184
- package/coverage/lcov-report/src/components/head.js.html +0 -151
- package/coverage/lcov-report/src/components/header.js.html +0 -628
- package/coverage/lcov-report/src/components/heading.js.html +0 -325
- package/coverage/lcov-report/src/components/hero-layout.js.html +0 -205
- package/coverage/lcov-report/src/components/hero.js.html +0 -154
- package/coverage/lcov-report/src/components/horizontal-rule.js.html +0 -115
- package/coverage/lcov-report/src/components/image-container.js.html +0 -121
- package/coverage/lcov-report/src/components/image.js.html +0 -109
- package/coverage/lcov-report/src/components/index.html +0 -740
- package/coverage/lcov-report/src/components/inline-code.js.html +0 -115
- package/coverage/lcov-report/src/components/layout.js.html +0 -493
- package/coverage/lcov-report/src/components/list.js.html +0 -157
- package/coverage/lcov-report/src/components/live-code.js.html +0 -367
- package/coverage/lcov-report/src/components/live-preview-wrapper.js.html +0 -130
- package/coverage/lcov-report/src/components/mobile-search.js.html +0 -505
- package/coverage/lcov-report/src/components/nav-drawer.js.html +0 -595
- package/coverage/lcov-report/src/components/nav-dropdown.js.html +0 -235
- package/coverage/lcov-report/src/components/nav-items.js.html +0 -367
- package/coverage/lcov-report/src/components/note.js.html +0 -190
- package/coverage/lcov-report/src/components/page-footer.js.html +0 -166
- package/coverage/lcov-report/src/components/paragraph.js.html +0 -103
- package/coverage/lcov-report/src/components/search-results.js.html +0 -241
- package/coverage/lcov-report/src/components/search.js.html +0 -373
- package/coverage/lcov-report/src/components/sidebar.js.html +0 -253
- package/coverage/lcov-report/src/components/skip-link.js.html +0 -214
- package/coverage/lcov-report/src/components/source-link.js.html +0 -127
- package/coverage/lcov-report/src/components/status-label.js.html +0 -160
- package/coverage/lcov-report/src/components/storybook-link.js.html +0 -169
- package/coverage/lcov-report/src/components/table-of-contents.js.html +0 -184
- package/coverage/lcov-report/src/components/table.js.html +0 -181
- package/coverage/lcov-report/src/components/text-input.js.html +0 -112
- package/coverage/lcov-report/src/components/wrap-page-element.js.html +0 -148
- package/coverage/lcov-report/src/components/wrap-root-element.js.html +0 -247
- package/coverage/lcov-report/src/github.js.html +0 -301
- package/coverage/lcov-report/src/index.html +0 -185
- package/coverage/lcov-report/src/live-code-scope.js.html +0 -88
- package/coverage/lcov-report/src/prism.js.html +0 -160
- package/coverage/lcov-report/src/search.worker.js.html +0 -175
- package/coverage/lcov-report/src/use-search.js.html +0 -307
- package/coverage/lcov-report/src/use-site-metadata.js.html +0 -136
- package/coverage/lcov.info +0 -1094
|
@@ -43,7 +43,7 @@ function NavItems({items}) {
|
|
|
43
43
|
to={item.url}
|
|
44
44
|
activeClassName="active"
|
|
45
45
|
partiallyActive={true}
|
|
46
|
-
color
|
|
46
|
+
sx={{color: 'inherit'}}
|
|
47
47
|
>
|
|
48
48
|
{item.title}
|
|
49
49
|
</NavLink>
|
|
@@ -55,10 +55,12 @@ function NavItems({items}) {
|
|
|
55
55
|
as={GatsbyLink}
|
|
56
56
|
to={child.url}
|
|
57
57
|
activeClassName="active"
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
58
|
+
sx={{
|
|
59
|
+
display: 'block',
|
|
60
|
+
py: 1,
|
|
61
|
+
mt: 2,
|
|
62
|
+
fontSize: 1
|
|
63
|
+
}}
|
|
62
64
|
>
|
|
63
65
|
{child.title}
|
|
64
66
|
</NavLink>
|
|
@@ -69,22 +71,11 @@ function NavItems({items}) {
|
|
|
69
71
|
</Box>
|
|
70
72
|
))}
|
|
71
73
|
{repositoryUrl ? (
|
|
72
|
-
<Box
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
borderRadius={0}
|
|
76
|
-
borderStyle="solid"
|
|
77
|
-
borderColor="border.default"
|
|
78
|
-
p={4}
|
|
79
|
-
>
|
|
80
|
-
<Link href={repositoryUrl} color="inherit">
|
|
81
|
-
<Box
|
|
82
|
-
display="flex"
|
|
83
|
-
justifyContent="space-between"
|
|
84
|
-
alignItems="center"
|
|
85
|
-
>
|
|
74
|
+
<Box borderWidth={0} borderTopWidth={1} borderRadius={0} borderStyle="solid" borderColor="border.default" p={4}>
|
|
75
|
+
<Link href={repositoryUrl} sx={{color: 'inherit'}}>
|
|
76
|
+
<Box display="flex" justifyContent="space-between" alignItems="center">
|
|
86
77
|
GitHub
|
|
87
|
-
<StyledOcticon icon={LinkExternalIcon} color
|
|
78
|
+
<StyledOcticon icon={LinkExternalIcon} sx={{color: 'fg.muted'}} />
|
|
88
79
|
</Box>
|
|
89
80
|
</Link>
|
|
90
81
|
</Box>
|
package/src/components/note.js
CHANGED
|
@@ -16,22 +16,22 @@ const Note = styled.div`
|
|
|
16
16
|
variants: {
|
|
17
17
|
info: {
|
|
18
18
|
borderColor: 'accent.muted',
|
|
19
|
-
bg: 'accent.subtle'
|
|
19
|
+
bg: 'accent.subtle'
|
|
20
20
|
},
|
|
21
21
|
warning: {
|
|
22
22
|
borderColor: 'attention.muted',
|
|
23
|
-
bg: 'attention.subtle'
|
|
23
|
+
bg: 'attention.subtle'
|
|
24
24
|
},
|
|
25
25
|
danger: {
|
|
26
26
|
borderColor: 'danger.muted',
|
|
27
|
-
bg: 'danger.subtle'
|
|
28
|
-
}
|
|
29
|
-
}
|
|
27
|
+
bg: 'danger.subtle'
|
|
28
|
+
}
|
|
29
|
+
}
|
|
30
30
|
})}
|
|
31
31
|
`
|
|
32
32
|
|
|
33
33
|
Note.defaultProps = {
|
|
34
|
-
variant: 'info'
|
|
34
|
+
variant: 'info'
|
|
35
35
|
}
|
|
36
36
|
|
|
37
37
|
export default Note
|
|
@@ -5,25 +5,23 @@ import Contributors from './contributors'
|
|
|
5
5
|
|
|
6
6
|
function PageFooter({editUrl, contributors}) {
|
|
7
7
|
return editUrl || contributors.length > 0 ? (
|
|
8
|
-
<BorderBox
|
|
9
|
-
<Grid
|
|
8
|
+
<BorderBox sx={{borderWidth: 0, borderTopWidth: 1, borderRadius: 0, mt: 8, py: 5}}>
|
|
9
|
+
<Grid sx={{gridGap: 4}}>
|
|
10
10
|
{editUrl ? (
|
|
11
11
|
<Link href={editUrl}>
|
|
12
|
-
<StyledOcticon icon={PencilIcon}
|
|
12
|
+
<StyledOcticon icon={PencilIcon} sx={{mr: 2}} />
|
|
13
13
|
Edit this page on GitHub
|
|
14
14
|
</Link>
|
|
15
15
|
) : null}
|
|
16
16
|
|
|
17
|
-
{contributors.length > 0 ?
|
|
18
|
-
<Contributors contributors={contributors} />
|
|
19
|
-
) : null}
|
|
17
|
+
{contributors.length > 0 ? <Contributors contributors={contributors} /> : null}
|
|
20
18
|
</Grid>
|
|
21
19
|
</BorderBox>
|
|
22
20
|
) : null
|
|
23
21
|
}
|
|
24
22
|
|
|
25
23
|
PageFooter.defaultProps = {
|
|
26
|
-
contributors: []
|
|
24
|
+
contributors: []
|
|
27
25
|
}
|
|
28
26
|
|
|
29
27
|
export default PageFooter
|
|
@@ -27,7 +27,7 @@ function SearchResults({results, getItemProps, highlightedIndex}) {
|
|
|
27
27
|
fontSize: 1,
|
|
28
28
|
bg: highlightedIndex === index ? 'neutral.muted' : 'transparent',
|
|
29
29
|
style: {cursor: 'pointer'},
|
|
30
|
-
borderRadius: 2
|
|
30
|
+
borderRadius: 2
|
|
31
31
|
})}
|
|
32
32
|
>
|
|
33
33
|
<Text fontSize={0} color="fg.muted">
|
|
@@ -47,7 +47,7 @@ function getBreadcrumbs(siteTitle, path) {
|
|
|
47
47
|
// The last title will be displayed separately, so we exclude it
|
|
48
48
|
// from the breadcrumbs to avoid displaying it twice.
|
|
49
49
|
.slice(0, -1)
|
|
50
|
-
.map(sentenceCase)
|
|
50
|
+
.map(sentenceCase)
|
|
51
51
|
]
|
|
52
52
|
}
|
|
53
53
|
|
package/src/components/search.js
CHANGED
|
@@ -43,21 +43,14 @@ function Search() {
|
|
|
43
43
|
itemToString={item => (item ? item.title : '')}
|
|
44
44
|
stateReducer={stateReducer}
|
|
45
45
|
>
|
|
46
|
-
{({
|
|
47
|
-
getInputProps,
|
|
48
|
-
getItemProps,
|
|
49
|
-
getMenuProps,
|
|
50
|
-
getRootProps,
|
|
51
|
-
isOpen,
|
|
52
|
-
highlightedIndex,
|
|
53
|
-
}) => (
|
|
46
|
+
{({getInputProps, getItemProps, getMenuProps, getRootProps, isOpen, highlightedIndex}) => (
|
|
54
47
|
<Position {...getRootProps({position: 'relative'})}>
|
|
55
48
|
<TextInput
|
|
56
49
|
{...getInputProps({
|
|
57
50
|
placeholder: `Search ${siteMetadata.title}`,
|
|
58
51
|
sx: {
|
|
59
|
-
width: 240
|
|
60
|
-
}
|
|
52
|
+
width: 240
|
|
53
|
+
}
|
|
61
54
|
})}
|
|
62
55
|
/>
|
|
63
56
|
{isOpen ? (
|
|
@@ -66,25 +59,23 @@ function Search() {
|
|
|
66
59
|
position: 'absolute',
|
|
67
60
|
left: 0,
|
|
68
61
|
right: 0,
|
|
69
|
-
pt: 2
|
|
62
|
+
pt: 2
|
|
70
63
|
})}
|
|
71
64
|
>
|
|
72
65
|
<ThemeProvider colorMode="day">
|
|
73
66
|
<BorderBox
|
|
74
|
-
minWidth={300}
|
|
75
|
-
maxHeight="70vh"
|
|
76
|
-
p={2}
|
|
77
|
-
boxShadow="shadow.large"
|
|
78
|
-
borderColor="border.muted"
|
|
79
|
-
bg="canvas.overlay"
|
|
80
|
-
borderRadius="12px"
|
|
81
67
|
style={{overflow: 'auto'}}
|
|
68
|
+
sx={{
|
|
69
|
+
minWidth: 300,
|
|
70
|
+
maxHeight: '70vh',
|
|
71
|
+
p: 2,
|
|
72
|
+
boxShadow: 'shadow.large',
|
|
73
|
+
borderColor: 'border.muted',
|
|
74
|
+
bg: 'canvas.overlay',
|
|
75
|
+
borderRadius: '12px'
|
|
76
|
+
}}
|
|
82
77
|
>
|
|
83
|
-
<SearchResults
|
|
84
|
-
results={results}
|
|
85
|
-
getItemProps={getItemProps}
|
|
86
|
-
highlightedIndex={highlightedIndex}
|
|
87
|
-
/>
|
|
78
|
+
<SearchResults results={results} getItemProps={getItemProps} highlightedIndex={highlightedIndex} />
|
|
88
79
|
</BorderBox>
|
|
89
80
|
</ThemeProvider>
|
|
90
81
|
</Position>
|
|
@@ -10,7 +10,7 @@ function usePersistentScroll(id) {
|
|
|
10
10
|
const handleScroll = React.useCallback(
|
|
11
11
|
// Save scroll position in session storage on every scroll change
|
|
12
12
|
event => window.sessionStorage.setItem(id, event.target.scrollTop),
|
|
13
|
-
[id]
|
|
13
|
+
[id]
|
|
14
14
|
)
|
|
15
15
|
|
|
16
16
|
React.useLayoutEffect(() => {
|
|
@@ -24,7 +24,7 @@ function usePersistentScroll(id) {
|
|
|
24
24
|
// Return props to spread onto the scroll container
|
|
25
25
|
return {
|
|
26
26
|
ref,
|
|
27
|
-
onScroll: handleScroll
|
|
27
|
+
onScroll: handleScroll
|
|
28
28
|
}
|
|
29
29
|
}
|
|
30
30
|
|
|
@@ -33,21 +33,20 @@ function Sidebar() {
|
|
|
33
33
|
|
|
34
34
|
return (
|
|
35
35
|
<Position
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
36
|
+
sx={{
|
|
37
|
+
position: 'sticky',
|
|
38
|
+
top: HEADER_HEIGHT,
|
|
39
|
+
height: `calc(100vh - ${HEADER_HEIGHT}px)`,
|
|
40
|
+
minWidth: 260,
|
|
41
|
+
bg: 'canvas.subtle'
|
|
42
|
+
}}
|
|
41
43
|
>
|
|
42
44
|
<BorderBox
|
|
43
45
|
{...scrollContainerProps}
|
|
44
|
-
borderWidth={0}
|
|
45
|
-
borderRightWidth={1}
|
|
46
|
-
borderRadius={0}
|
|
47
|
-
height="100%"
|
|
48
46
|
style={{overflow: 'auto'}}
|
|
47
|
+
sx={{borderWidth: 0, borderRightWidth: 1, borderRadius: 0, height: '100%'}}
|
|
49
48
|
>
|
|
50
|
-
<Flex flexDirection
|
|
49
|
+
<Flex sx={{flexDirection: 'column'}}>
|
|
51
50
|
<NavItems items={navItems} />
|
|
52
51
|
</Flex>
|
|
53
52
|
</BorderBox>
|
|
@@ -5,7 +5,7 @@ const STATUS_COLORS = {
|
|
|
5
5
|
alpha: 'severe.fg',
|
|
6
6
|
beta: 'attention.fg',
|
|
7
7
|
stable: 'success.fg',
|
|
8
|
-
deprecated: 'danger.fg'
|
|
8
|
+
deprecated: 'danger.fg'
|
|
9
9
|
}
|
|
10
10
|
|
|
11
11
|
function getStatusColor(status) {
|
|
@@ -14,11 +14,7 @@ function getStatusColor(status) {
|
|
|
14
14
|
|
|
15
15
|
function StatusLabel({status}) {
|
|
16
16
|
return (
|
|
17
|
-
<Label
|
|
18
|
-
outline
|
|
19
|
-
color={getStatusColor(status)}
|
|
20
|
-
borderColor={getStatusColor(status)}
|
|
21
|
-
>
|
|
17
|
+
<Label outline sx={{color: getStatusColor(status), borderColor: getStatusColor(status)}}>
|
|
22
18
|
{status}
|
|
23
19
|
</Label>
|
|
24
20
|
)
|
|
@@ -13,15 +13,13 @@ function TableOfContents({items, depth}) {
|
|
|
13
13
|
display: 'inline-block',
|
|
14
14
|
py: 1,
|
|
15
15
|
fontSize: [2, null, 1],
|
|
16
|
-
color: 'fg.muted'
|
|
16
|
+
color: 'fg.muted'
|
|
17
17
|
}}
|
|
18
18
|
>
|
|
19
19
|
{item.title}
|
|
20
20
|
</Link>
|
|
21
21
|
) : null}
|
|
22
|
-
{item.items ?
|
|
23
|
-
<TableOfContents items={item.items} depth={depth + 1} />
|
|
24
|
-
) : null}
|
|
22
|
+
{item.items ? <TableOfContents items={item.items} depth={depth + 1} /> : null}
|
|
25
23
|
</Box>
|
|
26
24
|
))}
|
|
27
25
|
</Box>
|
|
@@ -29,7 +27,7 @@ function TableOfContents({items, depth}) {
|
|
|
29
27
|
}
|
|
30
28
|
|
|
31
29
|
TableOfContents.defaultProps = {
|
|
32
|
-
depth: 0
|
|
30
|
+
depth: 0
|
|
33
31
|
}
|
|
34
32
|
|
|
35
33
|
export default TableOfContents
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import {MDXProvider} from '@mdx-js/react'
|
|
2
2
|
import {Link, ThemeProvider} from '@primer/components'
|
|
3
3
|
import React from 'react'
|
|
4
|
+
import mdxComponents from '../mdx-components'
|
|
4
5
|
import Blockquote from './blockquote'
|
|
5
6
|
import Caption from './caption'
|
|
6
7
|
import Code from './code'
|
|
@@ -36,13 +37,14 @@ const components = {
|
|
|
36
37
|
ol: List.withComponent('ol'),
|
|
37
38
|
dl: DescriptionList,
|
|
38
39
|
|
|
39
|
-
//
|
|
40
|
+
// Custom components
|
|
40
41
|
Note,
|
|
41
42
|
Do,
|
|
42
43
|
Dont,
|
|
43
44
|
DoDontContainer,
|
|
44
45
|
Caption,
|
|
45
46
|
ImageContainer,
|
|
47
|
+
...mdxComponents
|
|
46
48
|
}
|
|
47
49
|
|
|
48
50
|
function wrapRootElement({element}) {
|
package/src/github.js
CHANGED
|
@@ -1,74 +1,63 @@
|
|
|
1
1
|
export default {
|
|
2
2
|
plain: {
|
|
3
|
-
color:
|
|
4
|
-
backgroundColor:
|
|
3
|
+
color: '#393A34',
|
|
4
|
+
backgroundColor: '#f6f8fa'
|
|
5
5
|
},
|
|
6
6
|
styles: [
|
|
7
7
|
{
|
|
8
|
-
types: [
|
|
8
|
+
types: ['comment', 'prolog', 'doctype', 'cdata'],
|
|
9
9
|
style: {
|
|
10
|
-
color:
|
|
11
|
-
fontStyle:
|
|
12
|
-
}
|
|
10
|
+
color: '#999988',
|
|
11
|
+
fontStyle: 'italic'
|
|
12
|
+
}
|
|
13
13
|
},
|
|
14
14
|
{
|
|
15
|
-
types: [
|
|
15
|
+
types: ['namespace'],
|
|
16
16
|
style: {
|
|
17
|
-
opacity: 0.7
|
|
18
|
-
}
|
|
17
|
+
opacity: 0.7
|
|
18
|
+
}
|
|
19
19
|
},
|
|
20
20
|
{
|
|
21
|
-
types: [
|
|
21
|
+
types: ['string', 'attr-value'],
|
|
22
22
|
style: {
|
|
23
|
-
color:
|
|
24
|
-
}
|
|
23
|
+
color: '#e3116c'
|
|
24
|
+
}
|
|
25
25
|
},
|
|
26
26
|
{
|
|
27
|
-
types: [
|
|
27
|
+
types: ['punctuation', 'operator'],
|
|
28
28
|
style: {
|
|
29
|
-
color:
|
|
30
|
-
}
|
|
29
|
+
color: '#393A34'
|
|
30
|
+
}
|
|
31
31
|
},
|
|
32
32
|
{
|
|
33
|
-
types: [
|
|
34
|
-
"entity",
|
|
35
|
-
"url",
|
|
36
|
-
"symbol",
|
|
37
|
-
"number",
|
|
38
|
-
"boolean",
|
|
39
|
-
"variable",
|
|
40
|
-
"constant",
|
|
41
|
-
"property",
|
|
42
|
-
"regex",
|
|
43
|
-
"inserted",
|
|
44
|
-
],
|
|
33
|
+
types: ['entity', 'url', 'symbol', 'number', 'boolean', 'variable', 'constant', 'property', 'regex', 'inserted'],
|
|
45
34
|
style: {
|
|
46
|
-
color:
|
|
47
|
-
}
|
|
35
|
+
color: '#36acaa'
|
|
36
|
+
}
|
|
48
37
|
},
|
|
49
38
|
{
|
|
50
|
-
types: [
|
|
39
|
+
types: ['atrule', 'keyword', 'attr-name', 'selector'],
|
|
51
40
|
style: {
|
|
52
|
-
color:
|
|
53
|
-
}
|
|
41
|
+
color: '#00a4db'
|
|
42
|
+
}
|
|
54
43
|
},
|
|
55
44
|
{
|
|
56
|
-
types: [
|
|
45
|
+
types: ['function', 'deleted', 'tag'],
|
|
57
46
|
style: {
|
|
58
|
-
color:
|
|
59
|
-
}
|
|
47
|
+
color: '#d73a49'
|
|
48
|
+
}
|
|
60
49
|
},
|
|
61
50
|
{
|
|
62
|
-
types: [
|
|
51
|
+
types: ['function-variable'],
|
|
63
52
|
style: {
|
|
64
|
-
color:
|
|
65
|
-
}
|
|
53
|
+
color: '#6f42c1'
|
|
54
|
+
}
|
|
66
55
|
},
|
|
67
56
|
{
|
|
68
|
-
types: [
|
|
57
|
+
types: ['tag', 'selector', 'keyword'],
|
|
69
58
|
style: {
|
|
70
|
-
color:
|
|
71
|
-
}
|
|
72
|
-
}
|
|
73
|
-
]
|
|
74
|
-
}
|
|
59
|
+
color: '#00009f'
|
|
60
|
+
}
|
|
61
|
+
}
|
|
62
|
+
]
|
|
63
|
+
}
|
package/src/prism.js
CHANGED
|
@@ -1,27 +1,27 @@
|
|
|
1
1
|
import Prism from 'prismjs/components/prism-core'
|
|
2
2
|
|
|
3
3
|
// Core languages
|
|
4
|
-
import 'prismjs/components/prism-clike'
|
|
5
|
-
import 'prismjs/components/prism-markup'
|
|
6
|
-
import 'prismjs/components/prism-markup-templating'
|
|
4
|
+
import 'prismjs/components/prism-clike'
|
|
5
|
+
import 'prismjs/components/prism-markup'
|
|
6
|
+
import 'prismjs/components/prism-markup-templating'
|
|
7
7
|
|
|
8
8
|
// Supported languages
|
|
9
|
-
import 'prismjs/components/prism-bash'
|
|
10
|
-
import 'prismjs/components/prism-css'
|
|
11
|
-
import 'prismjs/components/prism-diff'
|
|
12
|
-
import 'prismjs/components/prism-go'
|
|
13
|
-
import 'prismjs/components/prism-json'
|
|
14
|
-
import 'prismjs/components/prism-markdown'
|
|
15
|
-
import 'prismjs/components/prism-yaml'
|
|
9
|
+
import 'prismjs/components/prism-bash'
|
|
10
|
+
import 'prismjs/components/prism-css'
|
|
11
|
+
import 'prismjs/components/prism-diff'
|
|
12
|
+
import 'prismjs/components/prism-go'
|
|
13
|
+
import 'prismjs/components/prism-json'
|
|
14
|
+
import 'prismjs/components/prism-markdown'
|
|
15
|
+
import 'prismjs/components/prism-yaml'
|
|
16
16
|
|
|
17
17
|
// JS like
|
|
18
|
-
import 'prismjs/components/prism-javascript'
|
|
19
|
-
import 'prismjs/components/prism-jsx'
|
|
20
|
-
import 'prismjs/components/prism-typescript'
|
|
21
|
-
import 'prismjs/components/prism-tsx'
|
|
18
|
+
import 'prismjs/components/prism-javascript'
|
|
19
|
+
import 'prismjs/components/prism-jsx'
|
|
20
|
+
import 'prismjs/components/prism-typescript'
|
|
21
|
+
import 'prismjs/components/prism-tsx'
|
|
22
22
|
|
|
23
23
|
// Ruby like
|
|
24
|
-
import 'prismjs/components/prism-ruby'
|
|
25
|
-
import 'prismjs/components/prism-erb'
|
|
24
|
+
import 'prismjs/components/prism-ruby'
|
|
25
|
+
import 'prismjs/components/prism-erb'
|
|
26
26
|
|
|
27
27
|
export default Prism
|
package/src/search.worker.js
CHANGED
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
import Fuse from 'fuse.js'
|
|
2
2
|
import debounce from 'lodash.debounce'
|
|
3
|
-
|
|
4
|
-
(function searchWorker() {
|
|
3
|
+
;(function searchWorker() {
|
|
5
4
|
let fuse = null
|
|
6
5
|
|
|
7
6
|
// [MKT]: I landed on the debouce wait value of 50 based mostly on
|
|
@@ -13,17 +12,21 @@ import debounce from 'lodash.debounce'
|
|
|
13
12
|
// > Note: If `leading` and `trailing` options are `true`, `func` is invoked
|
|
14
13
|
// > on the trailing edge of the timeout only if the debounced function is
|
|
15
14
|
// > invoked more than once during the wait timeout.
|
|
16
|
-
const performSearch = debounce(
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
15
|
+
const performSearch = debounce(
|
|
16
|
+
function performSearch(query) {
|
|
17
|
+
const results = fuse.search(query).slice(0, 20)
|
|
18
|
+
postMessage({results: results, query: query})
|
|
19
|
+
},
|
|
20
|
+
50,
|
|
21
|
+
{leading: true, trailing: true}
|
|
22
|
+
)
|
|
20
23
|
|
|
21
|
-
onmessage = function({data}) {
|
|
24
|
+
onmessage = function ({data}) {
|
|
22
25
|
if (data.list) {
|
|
23
26
|
fuse = new Fuse(data.list, {
|
|
24
27
|
threshold: 0.2,
|
|
25
28
|
keys: ['title', 'rawBody'],
|
|
26
|
-
tokenize: true
|
|
29
|
+
tokenize: true
|
|
27
30
|
})
|
|
28
31
|
} else if (data.query) {
|
|
29
32
|
performSearch(data.query)
|
package/src/use-search.js
CHANGED
|
@@ -3,7 +3,7 @@ import path from 'path'
|
|
|
3
3
|
import React from 'react'
|
|
4
4
|
import SearchWorker from 'worker-loader!./search.worker.js'
|
|
5
5
|
|
|
6
|
-
const ensureAbsolute = uri => uri.startsWith('/') ? uri : `/${uri}`
|
|
6
|
+
const ensureAbsolute = uri => (uri.startsWith('/') ? uri : `/${uri}`)
|
|
7
7
|
|
|
8
8
|
function useSearch(query) {
|
|
9
9
|
const latestQuery = React.useRef(query)
|
|
@@ -32,14 +32,13 @@ function useSearch(query) {
|
|
|
32
32
|
const list = React.useMemo(
|
|
33
33
|
() =>
|
|
34
34
|
data.allMdx.nodes.map(node => ({
|
|
35
|
-
path: ensureAbsolute(
|
|
36
|
-
node.parent.relativeDirectory,
|
|
37
|
-
|
|
38
|
-
)),
|
|
35
|
+
path: ensureAbsolute(
|
|
36
|
+
path.join(node.parent.relativeDirectory, node.parent.name === 'index' ? '/' : node.parent.name)
|
|
37
|
+
),
|
|
39
38
|
title: node.frontmatter.title,
|
|
40
|
-
rawBody: node.rawBody
|
|
39
|
+
rawBody: node.rawBody
|
|
41
40
|
})),
|
|
42
|
-
[data]
|
|
41
|
+
[data]
|
|
43
42
|
)
|
|
44
43
|
|
|
45
44
|
const [results, setResults] = React.useState(list)
|