Skip to content

Commit 183f120

Browse files
committed
chore: remove theme workspace and merge all files into root
1 parent d1bb51d commit 183f120

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

60 files changed

+348
-669
lines changed

.eslintrc.js

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -12,15 +12,8 @@ module.exports = {
1212
'plugin:import/recommended',
1313
'prettier',
1414
],
15-
settings: {
16-
import: {
17-
ignore: ['^theme$'],
18-
},
19-
},
2015
rules: {
2116
'react/prop-types': 'off',
22-
// our theme use exports which dont work with import/no-unresolved
23-
'import/no-unresolved': ['error', {ignore: ['^theme$']}],
2417
},
2518
overrides: [
2619
{

.github/workflows/ci-theme.yml

Lines changed: 0 additions & 175 deletions
This file was deleted.

.github/workflows/ci.yml

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,13 +7,11 @@ on:
77
pull_request:
88
paths-ignore:
99
- cli/**
10-
- theme/**
1110
push:
1211
branches:
1312
- main
1413
paths-ignore:
1514
- cli/**
16-
- theme/**
1715
schedule:
1816
# "At 09:00 UTC (02:00 PT) on Monday" https://crontab.guru/#0_9_*_*_1
1917
- cron: "0 9 * * 1"

.gitignore

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,4 +39,3 @@
3939
!/tap-snapshots/
4040
!/test/
4141
!/cli/
42-
!/theme/

CONTRIBUTING.md

Lines changed: 2 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -10,11 +10,10 @@ This is the documentation for [https://docs.npmjs.com/](https://docs.npmjs.com/)
1010
- [Navigation](#navigation)
1111
- [CLI](#cli)
1212
- [Deploying changes](#deploying-changes)
13-
- [Theme](#theme)
1413

1514
## Quick start
1615

17-
1. `npm install` to download Gatsby, our theme, and the dependencies
16+
1. `npm install` to download Gatsby and all the dependencies
1817
2. `npm run develop`: starts the test server at `http://localhost:8000`.
1918
3. Update the content - it's MDX, which is like Markdown - in the `content` directory.
2019
4. Review your content at `http://localhost:8000`. (Gatsby watches the filesystem and will reload your content changes immediately.)
@@ -109,7 +108,7 @@ The content pages should include [frontmatter](https://jekyllrb.com/docs/front-m
109108

110109
## Navigation
111110

112-
The site's navigation (on the left-hand sidebar of the site) is controlled by `src/theme/nav.yml`. If you add or remove a page from the site, you'll also want to add or remove it from the navigation configuration.
111+
The site's navigation (on the left-hand sidebar of the site) is controlled by `src/nav.yml`. If you add or remove a page from the site, you'll also want to add or remove it from the navigation configuration.
113112

114113
## CLI
115114

@@ -147,7 +146,3 @@ The docs site (https://docs.npmjs.com/) is published from a [GitHub Actions work
147146
3. Merge that pull request
148147

149148
On step three, your changes will be published live! 🎉
150-
151-
## Theme
152-
153-
The Gatsby theme used here is located in the [`theme/`](./theme) directory. It is a variation of [doctocat](https://github.com/primer/doctocat) with some theme changes for npm's design language and additional components to support multiple versions of the CLI documentation.

README.md

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -18,10 +18,6 @@ This is the documentation for [https://docs.npmjs.com/](https://docs.npmjs.com/)
1818

1919
Do you want to know more? Check out our [contributing guide](CONTRIBUTING.md).
2020

21-
## Theme
22-
23-
The gatsby theme used here is located in the [`theme/`](./theme) directory. It is a variation of [doctocat](https://github.com/primer/doctocat) with some theme changes for npm's design language and additional components to support multiple versions of the CLI documentation.
24-
2521
## License
2622

2723
The npm product documentation in the content, and static folders are licensed under a [CC-BY 4.0 license](LICENSE).
File renamed without changes.

gatsby-config.js

Lines changed: 67 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,45 @@
1+
const path = require('path')
2+
const fs = require('fs')
3+
4+
const {NODE_ENV, GATSBY_PARTIAL_CONTENT, GATSBY_CONTENT_DIR = 'content'} = process.env
5+
const DEV = NODE_ENV === 'development'
6+
const CONTENT_DIR = path.resolve(__dirname, '..', GATSBY_CONTENT_DIR)
7+
8+
const walkDirs = dir => {
9+
const dirs = fs
10+
.readdirSync(dir)
11+
.filter(d => fs.statSync(path.join(dir, d)).isDirectory())
12+
.map(p => path.join(dir, p))
13+
const nested = dirs.flatMap(d => walkDirs(d))
14+
return [...dirs, ...nested]
15+
}
16+
17+
const getContentOptions = () => {
18+
if (!DEV || !GATSBY_PARTIAL_CONTENT) {
19+
return
20+
}
21+
22+
const partialContent = (GATSBY_PARTIAL_CONTENT ?? '').split(',')
23+
24+
const paths = walkDirs(CONTENT_DIR)
25+
.map(p => path.relative(CONTENT_DIR, p))
26+
.sort()
27+
.reduce(
28+
(acc, p) => {
29+
const include = partialContent.some(partial => partial.startsWith(p))
30+
acc[include ? 'include' : 'ignore'].push(p)
31+
return acc
32+
},
33+
{include: [], ignore: []},
34+
)
35+
36+
console.log(`Only including the following partial content in dev mode:\n - ${paths.include.join('\n - ')}`)
37+
38+
return {
39+
ignore: paths.ignore,
40+
}
41+
}
42+
143
module.exports = {
244
trailingSlash: 'never',
345
siteMetadata: {
@@ -10,15 +52,34 @@ module.exports = {
1052
},
1153
plugins: [
1254
{
13-
resolve: './theme',
55+
resolve: 'gatsby-plugin-styled-components',
56+
},
57+
'gatsby-plugin-react-helmet',
58+
'gatsby-plugin-catch-links',
59+
'gatsby-transformer-yaml',
60+
{
61+
resolve: 'gatsby-plugin-mdx',
1462
options: {
15-
icon: './src/images/favicon.png',
16-
showContributors: false,
17-
repo: {
18-
url: 'https://github.com/npm/documentation',
19-
defaultBranch: 'main',
63+
extensions: ['.mdx', '.md'],
64+
defaultLayouts: {
65+
default: require.resolve('./src/layout/default.js'),
2066
},
2167
},
2268
},
69+
{
70+
resolve: 'gatsby-source-filesystem',
71+
options: {
72+
name: 'content',
73+
path: CONTENT_DIR,
74+
...getContentOptions(),
75+
},
76+
},
77+
{
78+
resolve: 'gatsby-plugin-manifest',
79+
options: {
80+
icon: path.resolve('./src/images/favicon.png'),
81+
},
82+
},
83+
'gatsby-plugin-meta-redirect',
2384
],
2485
}

0 commit comments

Comments
 (0)