@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
package/.eslintrc.json
ADDED
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
{
|
|
2
|
+
"parserOptions": {
|
|
3
|
+
"ecmaVersion": "latest",
|
|
4
|
+
"ecmaFeatures": {
|
|
5
|
+
"jsx": true
|
|
6
|
+
}
|
|
7
|
+
},
|
|
8
|
+
"extends": [
|
|
9
|
+
"plugin:react/recommended",
|
|
10
|
+
"plugin:jsx-a11y/recommended",
|
|
11
|
+
"plugin:prettier/recommended",
|
|
12
|
+
"plugin:primer-react/recommended"
|
|
13
|
+
],
|
|
14
|
+
"settings": {
|
|
15
|
+
"react": {
|
|
16
|
+
"version": "detect"
|
|
17
|
+
}
|
|
18
|
+
},
|
|
19
|
+
"rules": {
|
|
20
|
+
"react/prop-types": "off",
|
|
21
|
+
"react/display-name": "off",
|
|
22
|
+
"eslint-comments/no-use": "off",
|
|
23
|
+
"no-shadow": "off"
|
|
24
|
+
}
|
|
25
|
+
}
|
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,49 @@
|
|
|
1
1
|
# @primer/gatsby-theme-doctocat
|
|
2
2
|
|
|
3
|
+
## 3.1.0
|
|
4
|
+
|
|
5
|
+
### Minor Changes
|
|
6
|
+
|
|
7
|
+
- [`3767651`](https://github.com/primer/doctocat/commit/37676515f1d7485ca7b5e932e115d96e3ef0285b) [#318](https://github.com/primer/doctocat/pull/318) Thanks [@colebemis](https://github.com/colebemis)! - Add a step to build process that will output a static `components.json` file with component status info if the site that its building has markdown files containing `componentId` frontmatter.
|
|
8
|
+
|
|
9
|
+
## 3.0.1
|
|
10
|
+
|
|
11
|
+
### Patch Changes
|
|
12
|
+
|
|
13
|
+
- [`ff74ece`](https://github.com/primer/doctocat/commit/ff74ecea1b373469034c2122d94a54ca3e964158) [#301](https://github.com/primer/doctocat/pull/301) Thanks [@jfuchs](https://github.com/jfuchs)! - Removed styled system prop usage on Primer React components.
|
|
14
|
+
|
|
15
|
+
## 3.0.0
|
|
16
|
+
|
|
17
|
+
### Major Changes
|
|
18
|
+
|
|
19
|
+
- [`c2037d8`](https://github.com/primer/doctocat/commit/c2037d8352fca4ce3055e801b365d4ff1b5eefe9) [#295](https://github.com/primer/doctocat/pull/295) Thanks [@colebemis](https://github.com/colebemis)! - Remove checklist feature
|
|
20
|
+
|
|
21
|
+
### Minor Changes
|
|
22
|
+
|
|
23
|
+
- [`a94e0a9`](https://github.com/primer/doctocat/commit/a94e0a962e8013901e4285c7a3cabc3a0b691a92) [#294](https://github.com/primer/doctocat/pull/294) Thanks [@colebemis](https://github.com/colebemis)! - You can now make custom React components globally available (no import required) to all markdown files in your site.
|
|
24
|
+
|
|
25
|
+
### Patch Changes
|
|
26
|
+
|
|
27
|
+
- [`31a62df`](https://github.com/primer/doctocat/commit/31a62dfb7eb7a467a4e03a991adad995564ae4d1) [#262](https://github.com/primer/doctocat/pull/262) Thanks [@SferaDev](https://github.com/SferaDev)! - Fix scroll flickering of table of contents
|
|
28
|
+
|
|
29
|
+
* [`9972de8`](https://github.com/primer/doctocat/commit/9972de88224e1b868dad051abe62a92daf8796ef) [#291](https://github.com/primer/doctocat/pull/291) Thanks [@jonrohan](https://github.com/jonrohan)! - Fix release
|
|
30
|
+
|
|
31
|
+
## 2.1.0
|
|
32
|
+
|
|
33
|
+
### Minor Changes
|
|
34
|
+
|
|
35
|
+
- [`9ddaa08`](https://github.com/primer/doctocat/commit/9ddaa08395a5d08fc0cd6f7dc0de4d1e19252fa7) [#267](https://github.com/primer/doctocat/pull/267) Thanks [@colebemis](https://github.com/colebemis)! - Add support for checklists. See the [checklists](https://primer.style/doctocat/usage/checklists) documentation for more details.
|
|
36
|
+
|
|
37
|
+
### Patch Changes
|
|
38
|
+
|
|
39
|
+
- [`43a78eb`](https://github.com/primer/doctocat/commit/43a78eb93e453f9659488c125f7e5889633b3540) [#254](https://github.com/primer/doctocat/pull/254) Thanks [@dependabot](https://github.com/apps/dependabot)! - Bump axios from 0.19.2 to 0.21.2
|
|
40
|
+
|
|
41
|
+
* [`a730972`](https://github.com/primer/doctocat/commit/a7309725faa1636d7e53a5d63c65007bbe340e53) [#258](https://github.com/primer/doctocat/pull/258) Thanks [@dependabot](https://github.com/apps/dependabot)! - Bump tmpl from 1.0.4 to 1.0.5
|
|
42
|
+
|
|
43
|
+
- [`5efe933`](https://github.com/primer/doctocat/commit/5efe93324e3b078cac84c41cbec7de4ee9c2c800) [#216](https://github.com/primer/doctocat/pull/216) Thanks [@dependabot](https://github.com/apps/dependabot)! - Bump socket.io from 2.3.0 to 2.4.1
|
|
44
|
+
|
|
45
|
+
* [`6dcddf2`](https://github.com/primer/doctocat/commit/6dcddf2bd77019251b058c5e3081d815f7eaafed) [#256](https://github.com/primer/doctocat/pull/256) Thanks [@dependabot](https://github.com/apps/dependabot)! - Bump prismjs from 1.22.0 to 1.25.0
|
|
46
|
+
|
|
3
47
|
## 2.0.0
|
|
4
48
|
|
|
5
49
|
### Major Changes
|
package/babel.config.js
CHANGED
package/gatsby-config.js
CHANGED
|
@@ -6,8 +6,7 @@ module.exports = themeOptions => {
|
|
|
6
6
|
title: 'Doctocat',
|
|
7
7
|
shortName: 'Doctocat',
|
|
8
8
|
description: 'A Gatsby theme for creating Primer documentation sites',
|
|
9
|
-
imageUrl:
|
|
10
|
-
'https://user-images.githubusercontent.com/10384315/53922681-2f6d3100-402a-11e9-9719-5d1811c8110a.png',
|
|
9
|
+
imageUrl: 'https://user-images.githubusercontent.com/10384315/53922681-2f6d3100-402a-11e9-9719-5d1811c8110a.png'
|
|
11
10
|
},
|
|
12
11
|
plugins: [
|
|
13
12
|
'gatsby-plugin-styled-components',
|
|
@@ -20,25 +19,23 @@ module.exports = themeOptions => {
|
|
|
20
19
|
options: {
|
|
21
20
|
extensions: ['.mdx', '.md'],
|
|
22
21
|
defaultLayouts: {
|
|
23
|
-
default: require.resolve('./src/components/layout.js')
|
|
24
|
-
}
|
|
25
|
-
}
|
|
22
|
+
default: require.resolve('./src/components/layout.js')
|
|
23
|
+
}
|
|
24
|
+
}
|
|
26
25
|
},
|
|
27
26
|
{
|
|
28
27
|
resolve: 'gatsby-source-filesystem',
|
|
29
28
|
options: {
|
|
30
29
|
name: 'content',
|
|
31
|
-
path: path.resolve('./content')
|
|
32
|
-
}
|
|
30
|
+
path: path.resolve('./content')
|
|
31
|
+
}
|
|
33
32
|
},
|
|
34
33
|
{
|
|
35
34
|
resolve: 'gatsby-plugin-manifest',
|
|
36
35
|
options: {
|
|
37
|
-
icon: themeOptions.icon
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
},
|
|
42
|
-
],
|
|
36
|
+
icon: themeOptions.icon ? path.resolve(themeOptions.icon) : require.resolve('./src/images/favicon.png')
|
|
37
|
+
}
|
|
38
|
+
}
|
|
39
|
+
]
|
|
43
40
|
}
|
|
44
41
|
}
|
package/gatsby-node.js
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
const path = require('path')
|
|
2
|
+
const fs = require('fs')
|
|
2
3
|
const readPkgUp = require('read-pkg-up')
|
|
3
4
|
const getPkgRepo = require('get-pkg-repo')
|
|
4
5
|
const axios = require('axios')
|
|
@@ -12,7 +13,7 @@ exports.createPages = async ({graphql, actions}, themeOptions) => {
|
|
|
12
13
|
const repo = getPkgRepo(readPkgUp.sync().package)
|
|
13
14
|
|
|
14
15
|
const {data} = await graphql(`
|
|
15
|
-
{
|
|
16
|
+
query {
|
|
16
17
|
allMdx {
|
|
17
18
|
nodes {
|
|
18
19
|
fileAbsolutePath
|
|
@@ -29,49 +30,26 @@ exports.createPages = async ({graphql, actions}, themeOptions) => {
|
|
|
29
30
|
}
|
|
30
31
|
`)
|
|
31
32
|
|
|
32
|
-
if (
|
|
33
|
-
|
|
34
|
-
!process.env.NOW_GITHUB_DEPLOYMENT &&
|
|
35
|
-
!process.env.VERCEL_GITHUB_DEPLOYMENT
|
|
36
|
-
) {
|
|
37
|
-
console.error(
|
|
38
|
-
`Non-deploy build and no GITHUB_TOKEN environment variable set; skipping GitHub API calls`,
|
|
39
|
-
)
|
|
33
|
+
if (!process.env.GITHUB_TOKEN && !process.env.NOW_GITHUB_DEPLOYMENT && !process.env.VERCEL_GITHUB_DEPLOYMENT) {
|
|
34
|
+
console.error(`Non-deploy build and no GITHUB_TOKEN environment variable set; skipping GitHub API calls`)
|
|
40
35
|
}
|
|
41
36
|
|
|
42
37
|
// Turn every MDX file into a page.
|
|
43
|
-
|
|
38
|
+
await Promise.all(
|
|
44
39
|
data.allMdx.nodes.map(async node => {
|
|
45
40
|
const pagePath = path
|
|
46
|
-
.join(
|
|
47
|
-
node.parent.relativeDirectory,
|
|
48
|
-
node.parent.name === 'index' ? '/' : node.parent.name,
|
|
49
|
-
)
|
|
41
|
+
.join(node.parent.relativeDirectory, node.parent.name === 'index' ? '/' : node.parent.name)
|
|
50
42
|
.replace(/\\/g, '/') // Convert Windows backslash paths to forward slash paths: foo\\bar → foo/bar
|
|
51
43
|
|
|
52
|
-
const rootAbsolutePath = path.resolve(
|
|
53
|
-
process.cwd(),
|
|
54
|
-
themeOptions.repoRootPath || '.',
|
|
55
|
-
)
|
|
44
|
+
const rootAbsolutePath = path.resolve(process.cwd(), themeOptions.repoRootPath || '.')
|
|
56
45
|
|
|
57
|
-
const fileRelativePath = path.relative(
|
|
58
|
-
rootAbsolutePath,
|
|
59
|
-
node.fileAbsolutePath,
|
|
60
|
-
)
|
|
46
|
+
const fileRelativePath = path.relative(rootAbsolutePath, node.fileAbsolutePath)
|
|
61
47
|
const defaultBranch = themeOptions.defaultBranch || 'master'
|
|
62
48
|
const editUrl = getEditUrl(repo, fileRelativePath, defaultBranch)
|
|
63
49
|
|
|
64
50
|
let contributors = []
|
|
65
|
-
if (
|
|
66
|
-
process.env.GITHUB_TOKEN
|
|
67
|
-
process.env.NOW_GITHUB_DEPLOYMENT ||
|
|
68
|
-
process.env.VERCEL_GITHUB_DEPLOYMENT
|
|
69
|
-
) {
|
|
70
|
-
contributors = await fetchContributors(
|
|
71
|
-
repo,
|
|
72
|
-
fileRelativePath,
|
|
73
|
-
process.env.GITHUB_TOKEN,
|
|
74
|
-
)
|
|
51
|
+
if (process.env.GITHUB_TOKEN || process.env.NOW_GITHUB_DEPLOYMENT || process.env.VERCEL_GITHUB_DEPLOYMENT) {
|
|
52
|
+
contributors = await fetchContributors(repo, fileRelativePath, process.env.GITHUB_TOKEN)
|
|
75
53
|
}
|
|
76
54
|
|
|
77
55
|
// Copied from gatsby-plugin-mdx (https://git.io/JUs3H)
|
|
@@ -90,13 +68,47 @@ exports.createPages = async ({graphql, actions}, themeOptions) => {
|
|
|
90
68
|
// for us here, and does on the first build,
|
|
91
69
|
// but when HMR kicks in the frontmatter is lost.
|
|
92
70
|
// The solution is to include it here explicitly.
|
|
93
|
-
frontmatter
|
|
94
|
-
}
|
|
71
|
+
frontmatter
|
|
72
|
+
}
|
|
95
73
|
})
|
|
96
|
-
})
|
|
74
|
+
})
|
|
97
75
|
)
|
|
98
76
|
}
|
|
99
77
|
|
|
78
|
+
exports.onPostBuild = async ({graphql}) => {
|
|
79
|
+
try {
|
|
80
|
+
const {data} = await graphql(`
|
|
81
|
+
query {
|
|
82
|
+
allSitePage(filter: {context: {frontmatter: {componentId: {ne: null}}}}) {
|
|
83
|
+
nodes {
|
|
84
|
+
path
|
|
85
|
+
context {
|
|
86
|
+
frontmatter {
|
|
87
|
+
componentId
|
|
88
|
+
status
|
|
89
|
+
}
|
|
90
|
+
}
|
|
91
|
+
}
|
|
92
|
+
}
|
|
93
|
+
}
|
|
94
|
+
`)
|
|
95
|
+
|
|
96
|
+
const components = data.allSitePage.nodes.map(node => {
|
|
97
|
+
return {
|
|
98
|
+
id: node.context.frontmatter.componentId,
|
|
99
|
+
path: node.path,
|
|
100
|
+
status: node.context.frontmatter.status.toLowerCase()
|
|
101
|
+
}
|
|
102
|
+
})
|
|
103
|
+
|
|
104
|
+
fs.writeFileSync(path.resolve(process.cwd(), 'public/components.json'), JSON.stringify(components))
|
|
105
|
+
} catch (error) {
|
|
106
|
+
// This is not necessarily an error, so we just log a warning instead of failing the build.
|
|
107
|
+
// Some sites won't have any markdown files with `componentId` frontmatter and that's okay.
|
|
108
|
+
console.warn('Unable to build components.json')
|
|
109
|
+
}
|
|
110
|
+
}
|
|
111
|
+
|
|
100
112
|
function getEditUrl(repo, filePath, defaultBranch) {
|
|
101
113
|
return `https://github.com/${repo.user}/${repo.project}/edit/${defaultBranch}/${filePath}`
|
|
102
114
|
}
|
|
@@ -112,12 +124,12 @@ async function fetchContributors(repo, filePath, accessToken = '') {
|
|
|
112
124
|
const req = {
|
|
113
125
|
method: 'get',
|
|
114
126
|
baseURL: 'https://api.github.com/',
|
|
115
|
-
url: `/repos/${repo.user}/${repo.project}/commits?path=${filePath}&per_page=100
|
|
127
|
+
url: `/repos/${repo.user}/${repo.project}/commits?path=${filePath}&per_page=100`
|
|
116
128
|
}
|
|
117
129
|
|
|
118
130
|
if (accessToken && accessToken.length) {
|
|
119
131
|
req.headers = {
|
|
120
|
-
Authorization: `token ${accessToken}
|
|
132
|
+
Authorization: `token ${accessToken}`
|
|
121
133
|
}
|
|
122
134
|
}
|
|
123
135
|
|
|
@@ -128,8 +140,8 @@ async function fetchContributors(repo, filePath, accessToken = '') {
|
|
|
128
140
|
login: commit.author && commit.author.login,
|
|
129
141
|
latestCommit: {
|
|
130
142
|
date: commit.commit.author.date,
|
|
131
|
-
url: commit.html_url
|
|
132
|
-
}
|
|
143
|
+
url: commit.html_url
|
|
144
|
+
}
|
|
133
145
|
}))
|
|
134
146
|
.filter(contributor => Boolean(contributor.login))
|
|
135
147
|
|
|
@@ -137,9 +149,7 @@ async function fetchContributors(repo, filePath, accessToken = '') {
|
|
|
137
149
|
CONTRIBUTOR_CACHE.set(hash, result)
|
|
138
150
|
return result
|
|
139
151
|
} catch (error) {
|
|
140
|
-
console.error(
|
|
141
|
-
`[ERROR] Unable to fetch contributors for ${filePath}. ${error.message}`,
|
|
142
|
-
)
|
|
152
|
+
console.error(`[ERROR] Unable to fetch contributors for ${filePath}. ${error.message}`)
|
|
143
153
|
return []
|
|
144
154
|
}
|
|
145
155
|
}
|
package/jest.config.js
CHANGED
package/package.json
CHANGED
|
@@ -1,13 +1,24 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@primer/gatsby-theme-doctocat",
|
|
3
|
-
"version": "
|
|
3
|
+
"version": "3.1.0",
|
|
4
4
|
"main": "index.js",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"scripts": {
|
|
7
|
-
"test": "jest"
|
|
7
|
+
"test": "jest",
|
|
8
|
+
"lint": "eslint '**/*.{js,ts,tsx}'",
|
|
9
|
+
"lint:fix": "yarn lint -- --fix"
|
|
8
10
|
},
|
|
11
|
+
"prettier": "@github/prettier-config",
|
|
9
12
|
"devDependencies": {
|
|
13
|
+
"@github/prettier-config": "^0.0.4",
|
|
14
|
+
"eslint": "^8.0.1",
|
|
15
|
+
"eslint-config-prettier": "^8.3.0",
|
|
16
|
+
"eslint-plugin-jsx-a11y": "^6.4.1",
|
|
17
|
+
"eslint-plugin-prettier": "^4.0.0",
|
|
18
|
+
"eslint-plugin-primer-react": "0.5",
|
|
19
|
+
"eslint-plugin-react": "^7.26.1",
|
|
10
20
|
"gatsby": "^2.24.52",
|
|
21
|
+
"prettier": "^2.4.1",
|
|
11
22
|
"react": "^16.13.1",
|
|
12
23
|
"react-dom": "^16.13.1"
|
|
13
24
|
},
|
|
@@ -27,7 +38,7 @@
|
|
|
27
38
|
"@styled-system/theme-get": "^5.0.12",
|
|
28
39
|
"@testing-library/jest-dom": "^4.1.0",
|
|
29
40
|
"@testing-library/react": "^9.1.3",
|
|
30
|
-
"axios": "^0.
|
|
41
|
+
"axios": "^0.21.2",
|
|
31
42
|
"babel-jest": "^24.9.0",
|
|
32
43
|
"copy-to-clipboard": "^3.2.0",
|
|
33
44
|
"date-fns": "^2.0.1",
|
|
@@ -47,7 +58,7 @@
|
|
|
47
58
|
"gatsby-transformer-yaml": "^2.2.0",
|
|
48
59
|
"get-pkg-repo": "^4.1.0",
|
|
49
60
|
"github-slugger": "^1.2.1",
|
|
50
|
-
"html-react-parser": "^
|
|
61
|
+
"html-react-parser": "^1.4.0",
|
|
51
62
|
"jest": "^24.9.0",
|
|
52
63
|
"lodash.debounce": "4.0.8",
|
|
53
64
|
"lodash.uniqby": "^4.7.0",
|
|
@@ -55,7 +66,7 @@
|
|
|
55
66
|
"pluralize": "^8.0.0",
|
|
56
67
|
"preval.macro": "^3.0.0",
|
|
57
68
|
"prism-react-renderer": "^1.2.0",
|
|
58
|
-
"prismjs": "^1.
|
|
69
|
+
"prismjs": "^1.25.0",
|
|
59
70
|
"react-addons-text-content": "^0.0.4",
|
|
60
71
|
"react-element-to-jsx-string": "^14.0.3",
|
|
61
72
|
"react-focus-on": "^3.3.0",
|
|
@@ -10,18 +10,18 @@ test('renders contributors', () => {
|
|
|
10
10
|
login: 'colebemis',
|
|
11
11
|
latestCommit: {
|
|
12
12
|
url: '#',
|
|
13
|
-
date: '2019-08-15T23:40:19Z'
|
|
14
|
-
}
|
|
13
|
+
date: '2019-08-15T23:40:19Z'
|
|
14
|
+
}
|
|
15
15
|
},
|
|
16
16
|
{
|
|
17
17
|
login: 'emplums',
|
|
18
18
|
latestCommit: {
|
|
19
19
|
url: '#',
|
|
20
|
-
date: '2019-08-14T00:19:54Z'
|
|
21
|
-
}
|
|
22
|
-
}
|
|
20
|
+
date: '2019-08-14T00:19:54Z'
|
|
21
|
+
}
|
|
22
|
+
}
|
|
23
23
|
]}
|
|
24
|
-
|
|
24
|
+
/>
|
|
25
25
|
)
|
|
26
26
|
|
|
27
27
|
expect(queryByText(/2 contributors/)).toBeInTheDocument()
|
|
@@ -31,9 +31,7 @@ test('renders contributors', () => {
|
|
|
31
31
|
})
|
|
32
32
|
|
|
33
33
|
test('does not render "last edited by" if latest contributor does not have a latest commit', () => {
|
|
34
|
-
const {queryByText} = render(
|
|
35
|
-
<Contributors contributors={[{login: 'ashygee'}]} />,
|
|
36
|
-
)
|
|
34
|
+
const {queryByText} = render(<Contributors contributors={[{login: 'ashygee'}]} />)
|
|
37
35
|
|
|
38
36
|
expect(queryByText(/1 contributor/)).toBeInTheDocument()
|
|
39
37
|
expect(queryByText(/Last edited by/)).toBeNull()
|
|
@@ -55,18 +53,18 @@ test('does not render duplicate contributors', () => {
|
|
|
55
53
|
login: 'colebemis',
|
|
56
54
|
latestCommit: {
|
|
57
55
|
url: '#',
|
|
58
|
-
date: '2019-08-15T23:40:19Z'
|
|
59
|
-
}
|
|
56
|
+
date: '2019-08-15T23:40:19Z'
|
|
57
|
+
}
|
|
60
58
|
},
|
|
61
59
|
{
|
|
62
60
|
login: 'colebemis',
|
|
63
61
|
latestCommit: {
|
|
64
62
|
url: '#',
|
|
65
|
-
date: '2019-08-14T00:19:54Z'
|
|
66
|
-
}
|
|
67
|
-
}
|
|
63
|
+
date: '2019-08-14T00:19:54Z'
|
|
64
|
+
}
|
|
65
|
+
}
|
|
68
66
|
]}
|
|
69
|
-
|
|
67
|
+
/>
|
|
70
68
|
)
|
|
71
69
|
|
|
72
70
|
expect(queryByText(/1 contributor/)).toBeInTheDocument()
|
|
@@ -3,9 +3,7 @@ import React from 'react'
|
|
|
3
3
|
import PageFooter from '../page-footer'
|
|
4
4
|
|
|
5
5
|
test('renders correctly when editUrl and contributors are defined', () => {
|
|
6
|
-
const {queryByText} = render(
|
|
7
|
-
<PageFooter editUrl="#" contributors={[{login: 'broccolini'}]} />,
|
|
8
|
-
)
|
|
6
|
+
const {queryByText} = render(<PageFooter editUrl="#" contributors={[{login: 'broccolini'}]} />)
|
|
9
7
|
|
|
10
8
|
expect(queryByText(/Edit this page on GitHub/)).toBeInTheDocument()
|
|
11
9
|
expect(queryByText(/contributor/)).toBeInTheDocument()
|
|
@@ -26,9 +24,7 @@ test('renders correctly when editUrl is defined but contributors is undefined',
|
|
|
26
24
|
})
|
|
27
25
|
|
|
28
26
|
test('renders correctly when contributors is defined but editUrl is undefined', () => {
|
|
29
|
-
const {queryByText} = render(
|
|
30
|
-
<PageFooter contributors={[{login: 'broccolini'}]} />,
|
|
31
|
-
)
|
|
27
|
+
const {queryByText} = render(<PageFooter contributors={[{login: 'broccolini'}]} />)
|
|
32
28
|
|
|
33
29
|
expect(queryByText(/Edit this page on GitHub/)).toBeNull()
|
|
34
30
|
expect(queryByText(/contributor/)).toBeInTheDocument()
|
|
@@ -24,9 +24,9 @@ function ClipboardCopy({value}) {
|
|
|
24
24
|
sx={{px: 2}}
|
|
25
25
|
>
|
|
26
26
|
{copied ? (
|
|
27
|
-
<StyledOcticon icon={CheckIcon} color
|
|
27
|
+
<StyledOcticon icon={CheckIcon} sx={{color: 'success.fg'}} />
|
|
28
28
|
) : (
|
|
29
|
-
<StyledOcticon icon={CopyIcon} color
|
|
29
|
+
<StyledOcticon icon={CopyIcon} sx={{color: 'fg.muted'}} />
|
|
30
30
|
)}
|
|
31
31
|
</Button>
|
|
32
32
|
)
|
package/src/components/code.js
CHANGED
|
@@ -21,19 +21,13 @@ function Code({className, children, live, noinline}) {
|
|
|
21
21
|
// https://stackoverflow.com/a/14406386
|
|
22
22
|
display: 'table',
|
|
23
23
|
tableLayout: 'fixed',
|
|
24
|
-
width: '100%'
|
|
24
|
+
width: '100%'
|
|
25
25
|
}}
|
|
26
26
|
>
|
|
27
|
-
<Absolute
|
|
27
|
+
<Absolute sx={{top: 0, right: 0, p: 2}}>
|
|
28
28
|
<ClipboardCopy value={code} />
|
|
29
29
|
</Absolute>
|
|
30
|
-
<Highlight
|
|
31
|
-
{...defaultProps}
|
|
32
|
-
Prism={Prism}
|
|
33
|
-
code={code}
|
|
34
|
-
language={language}
|
|
35
|
-
theme={githubTheme}
|
|
36
|
-
>
|
|
30
|
+
<Highlight {...defaultProps} Prism={Prism} code={code} language={language} theme={githubTheme}>
|
|
37
31
|
{({className, style, tokens, getLineProps, getTokenProps}) => (
|
|
38
32
|
<Box
|
|
39
33
|
as="pre"
|
|
@@ -48,12 +42,7 @@ function Code({className, children, live, noinline}) {
|
|
|
48
42
|
{tokens.map((line, i) => (
|
|
49
43
|
<div key={i} {...getLineProps({line, key: i})}>
|
|
50
44
|
{line.map((token, key) => (
|
|
51
|
-
<Text
|
|
52
|
-
key={key}
|
|
53
|
-
fontFamily="mono"
|
|
54
|
-
fontSize={1}
|
|
55
|
-
{...getTokenProps({token, key})}
|
|
56
|
-
/>
|
|
45
|
+
<Text key={key} fontFamily="mono" fontSize={1} {...getTokenProps({token, key})} />
|
|
57
46
|
))}
|
|
58
47
|
</div>
|
|
59
48
|
))}
|
|
@@ -14,21 +14,16 @@ function Contributors({contributors}) {
|
|
|
14
14
|
<div>
|
|
15
15
|
<Box display="flex" alignItems="center">
|
|
16
16
|
<Text mr={2}>
|
|
17
|
-
{uniqueContributors.length}{'
|
|
18
|
-
{pluralize('contributor', uniqueContributors.length)}
|
|
17
|
+
{uniqueContributors.length} {pluralize('contributor', uniqueContributors.length)}
|
|
19
18
|
</Text>
|
|
20
19
|
{uniqueContributors.map(contributor => (
|
|
21
20
|
<Link
|
|
22
21
|
key={contributor.login}
|
|
23
22
|
href={`https://github.com/${contributor.login}`}
|
|
24
|
-
lineHeight
|
|
25
|
-
sx={{mr: 2}}
|
|
23
|
+
sx={{mr: 2, lineHeight: 'condensedUltra'}}
|
|
26
24
|
>
|
|
27
25
|
<Tooltip key={contributor.login} aria-label={contributor.login}>
|
|
28
|
-
<Avatar
|
|
29
|
-
src={`https://github.com/${contributor.login}.png?size=40`}
|
|
30
|
-
alt={contributor.login}
|
|
31
|
-
/>
|
|
26
|
+
<Avatar src={`https://github.com/${contributor.login}.png?size=40`} alt={contributor.login} />
|
|
32
27
|
</Tooltip>
|
|
33
28
|
</Link>
|
|
34
29
|
))}
|
|
@@ -36,10 +31,7 @@ function Contributors({contributors}) {
|
|
|
36
31
|
|
|
37
32
|
{latestContributor.latestCommit ? (
|
|
38
33
|
<Text fontSize={1} color="fg.muted" mt={1}>
|
|
39
|
-
Last edited by{' '}
|
|
40
|
-
<Link href={`https://github.com/${latestContributor.login}`}>
|
|
41
|
-
{latestContributor.login}
|
|
42
|
-
</Link>{' '}
|
|
34
|
+
Last edited by <Link href={`https://github.com/${latestContributor.login}`}>{latestContributor.login}</Link>{' '}
|
|
43
35
|
on{' '}
|
|
44
36
|
<Link href={latestContributor.latestCommit.url}>
|
|
45
37
|
{format(new Date(latestContributor.latestCommit.date), 'MMMM d, y')}
|
|
@@ -4,63 +4,34 @@ import React from 'react'
|
|
|
4
4
|
|
|
5
5
|
export function DoDontContainer({stacked, children}) {
|
|
6
6
|
return (
|
|
7
|
-
<Box
|
|
8
|
-
display="grid"
|
|
9
|
-
gridTemplateColumns={['1fr', null, stacked ? '1fr' : '1fr 1fr']}
|
|
10
|
-
gridGap={4}
|
|
11
|
-
mb={4}
|
|
12
|
-
>
|
|
7
|
+
<Box display="grid" gridTemplateColumns={['1fr', null, stacked ? '1fr' : '1fr 1fr']} gridGap={4} mb={4}>
|
|
13
8
|
{children}
|
|
14
9
|
</Box>
|
|
15
10
|
)
|
|
16
11
|
}
|
|
17
12
|
|
|
18
13
|
DoDontContainer.defaultProps = {
|
|
19
|
-
stacked: false
|
|
14
|
+
stacked: false
|
|
20
15
|
}
|
|
21
16
|
|
|
22
17
|
export function Do(props) {
|
|
23
|
-
return
|
|
24
|
-
<DoDontBase
|
|
25
|
-
{...props}
|
|
26
|
-
title="Do"
|
|
27
|
-
icon={CheckCircleFillIcon}
|
|
28
|
-
iconBg="success.fg"
|
|
29
|
-
/>
|
|
30
|
-
)
|
|
18
|
+
return <DoDontBase {...props} title="Do" icon={CheckCircleFillIcon} iconBg="success.fg" />
|
|
31
19
|
}
|
|
32
20
|
|
|
33
21
|
export function Dont(props) {
|
|
34
|
-
return
|
|
35
|
-
<DoDontBase
|
|
36
|
-
{...props}
|
|
37
|
-
title="Don't"
|
|
38
|
-
icon={XCircleFillIcon}
|
|
39
|
-
iconBg="danger.fg"
|
|
40
|
-
/>
|
|
41
|
-
)
|
|
22
|
+
return <DoDontBase {...props} title="Don't" icon={XCircleFillIcon} iconBg="danger.fg" />
|
|
42
23
|
}
|
|
43
24
|
|
|
44
25
|
function DoDontBase({children, title, icon: Icon, iconBg}) {
|
|
45
26
|
return (
|
|
46
27
|
<Box display="flex" flexDirection="column">
|
|
47
|
-
<Box
|
|
48
|
-
|
|
49
|
-
alignSelf="start"
|
|
50
|
-
flexDirection="row"
|
|
51
|
-
alignItems="center"
|
|
52
|
-
mb="2"
|
|
53
|
-
>
|
|
54
|
-
<StyledOcticon icon={Icon} color={iconBg} />
|
|
28
|
+
<Box display="flex" alignSelf="start" flexDirection="row" alignItems="center" mb="2">
|
|
29
|
+
<StyledOcticon icon={Icon} sx={{color: iconBg}} />
|
|
55
30
|
<Text fontWeight="bold" color="fg.default" ml={2}>
|
|
56
31
|
{title}
|
|
57
32
|
</Text>
|
|
58
33
|
</Box>
|
|
59
|
-
<Box
|
|
60
|
-
display="flex"
|
|
61
|
-
flexDirection="column"
|
|
62
|
-
sx={{'& *:last-child': {mb: 0}, img: {maxWidth: '100%'}}}
|
|
63
|
-
>
|
|
34
|
+
<Box display="flex" flexDirection="column" sx={{'& *:last-child': {mb: 0}, img: {maxWidth: '100%'}}}>
|
|
64
35
|
{children}
|
|
65
36
|
</Box>
|
|
66
37
|
</Box>
|
package/src/components/drawer.js
CHANGED
|
@@ -7,6 +7,7 @@ function Drawer({isOpen, onDismiss, children}) {
|
|
|
7
7
|
return (
|
|
8
8
|
<AnimatePresence>
|
|
9
9
|
{isOpen ? (
|
|
10
|
+
// eslint-disable-next-line jsx-a11y/click-events-have-key-events,jsx-a11y/no-static-element-interactions
|
|
10
11
|
<div
|
|
11
12
|
// These event handlers fix a bug that caused links below the fold
|
|
12
13
|
// to be unclickable in macOS Safari.
|
|
@@ -22,12 +23,8 @@ function Drawer({isOpen, onDismiss, children}) {
|
|
|
22
23
|
animate={{opacity: 1}}
|
|
23
24
|
exit={{opacity: 0}}
|
|
24
25
|
transition={{type: 'tween'}}
|
|
25
|
-
top={0}
|
|
26
|
-
right={0}
|
|
27
|
-
bottom={0}
|
|
28
|
-
left={0}
|
|
29
|
-
bg="rgba(0, 0, 0, 0.5)"
|
|
30
26
|
onClick={() => onDismiss()}
|
|
27
|
+
sx={{top: 0, right: 0, bottom: 0, left: 0, bg: 'rgba(0, 0, 0, 0.5)'}}
|
|
31
28
|
/>
|
|
32
29
|
|
|
33
30
|
<Fixed
|
|
@@ -37,12 +34,8 @@ function Drawer({isOpen, onDismiss, children}) {
|
|
|
37
34
|
animate={{x: 0}}
|
|
38
35
|
exit={{x: '100%'}}
|
|
39
36
|
transition={{type: 'tween', duration: 0.2}}
|
|
40
|
-
width={300}
|
|
41
|
-
top={0}
|
|
42
|
-
right={0}
|
|
43
|
-
bottom={0}
|
|
44
|
-
bg="gray.0"
|
|
45
37
|
style={{zIndex: 1}}
|
|
38
|
+
sx={{width: 300, top: 0, right: 0, bottom: 0, bg: 'gray.0'}}
|
|
46
39
|
>
|
|
47
40
|
{children}
|
|
48
41
|
</Fixed>
|
package/src/components/head.js
CHANGED
|
@@ -4,9 +4,7 @@ import useSiteMetadata from '../use-site-metadata'
|
|
|
4
4
|
|
|
5
5
|
function Head(props) {
|
|
6
6
|
const siteMetadata = useSiteMetadata()
|
|
7
|
-
const title = props.title
|
|
8
|
-
? `${props.title} | ${siteMetadata.title}`
|
|
9
|
-
: siteMetadata.title
|
|
7
|
+
const title = props.title ? `${props.title} | ${siteMetadata.title}` : siteMetadata.title
|
|
10
8
|
const description = props.description || siteMetadata.description
|
|
11
9
|
|
|
12
10
|
return (
|