Skip to content

Commit

Permalink
chore: remove theme workspace and merge all files into root
Browse files Browse the repository at this point in the history
  • Loading branch information
lukekarrys committed Oct 23, 2023
1 parent d1bb51d commit 183f120
Show file tree
Hide file tree
Showing 60 changed files with 348 additions and 669 deletions.
7 changes: 0 additions & 7 deletions .eslintrc.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,15 +12,8 @@ module.exports = {
'plugin:import/recommended',
'prettier',
],
settings: {
import: {
ignore: ['^theme$'],
},
},
rules: {
'react/prop-types': 'off',
// our theme use exports which dont work with import/no-unresolved
'import/no-unresolved': ['error', {ignore: ['^theme$']}],
},
overrides: [
{
Expand Down
175 changes: 0 additions & 175 deletions .github/workflows/ci-theme.yml

This file was deleted.

2 changes: 0 additions & 2 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,13 +7,11 @@ on:
pull_request:
paths-ignore:
- cli/**
- theme/**
push:
branches:
- main
paths-ignore:
- cli/**
- theme/**
schedule:
# "At 09:00 UTC (02:00 PT) on Monday" https://crontab.guru/#0_9_*_*_1
- cron: "0 9 * * 1"
Expand Down
1 change: 0 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -39,4 +39,3 @@
!/tap-snapshots/
!/test/
!/cli/
!/theme/
9 changes: 2 additions & 7 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,11 +10,10 @@ This is the documentation for [https://docs.npmjs.com/](https://docs.npmjs.com/)
- [Navigation](#navigation)
- [CLI](#cli)
- [Deploying changes](#deploying-changes)
- [Theme](#theme)

## Quick start

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

## Navigation

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.
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.

## CLI

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

On step three, your changes will be published live! 🎉

## Theme

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.
4 changes: 0 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -18,10 +18,6 @@ This is the documentation for [https://docs.npmjs.com/](https://docs.npmjs.com/)

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

## Theme

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.

## License

The npm product documentation in the content, and static folders are licensed under a [CC-BY 4.0 license](LICENSE).
Expand Down
File renamed without changes.
73 changes: 67 additions & 6 deletions gatsby-config.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,45 @@
const path = require('path')
const fs = require('fs')

const {NODE_ENV, GATSBY_PARTIAL_CONTENT, GATSBY_CONTENT_DIR = 'content'} = process.env
const DEV = NODE_ENV === 'development'
const CONTENT_DIR = path.resolve(__dirname, '..', GATSBY_CONTENT_DIR)

const walkDirs = dir => {
const dirs = fs
.readdirSync(dir)
.filter(d => fs.statSync(path.join(dir, d)).isDirectory())
.map(p => path.join(dir, p))
const nested = dirs.flatMap(d => walkDirs(d))
return [...dirs, ...nested]
}

const getContentOptions = () => {
if (!DEV || !GATSBY_PARTIAL_CONTENT) {
return
}

const partialContent = (GATSBY_PARTIAL_CONTENT ?? '').split(',')

const paths = walkDirs(CONTENT_DIR)
.map(p => path.relative(CONTENT_DIR, p))
.sort()
.reduce(
(acc, p) => {
const include = partialContent.some(partial => partial.startsWith(p))
acc[include ? 'include' : 'ignore'].push(p)
return acc
},
{include: [], ignore: []},
)

console.log(`Only including the following partial content in dev mode:\n - ${paths.include.join('\n - ')}`)

return {
ignore: paths.ignore,
}
}

module.exports = {
trailingSlash: 'never',
siteMetadata: {
Expand All @@ -10,15 +52,34 @@ module.exports = {
},
plugins: [
{
resolve: './theme',
resolve: 'gatsby-plugin-styled-components',
},
'gatsby-plugin-react-helmet',
'gatsby-plugin-catch-links',
'gatsby-transformer-yaml',
{
resolve: 'gatsby-plugin-mdx',
options: {
icon: './src/images/favicon.png',
showContributors: false,
repo: {
url: 'https://github.com/npm/documentation',
defaultBranch: 'main',
extensions: ['.mdx', '.md'],
defaultLayouts: {
default: require.resolve('./src/layout/default.js'),
},
},
},
{
resolve: 'gatsby-source-filesystem',
options: {
name: 'content',
path: CONTENT_DIR,
...getContentOptions(),
},
},
{
resolve: 'gatsby-plugin-manifest',
options: {
icon: path.resolve('./src/images/favicon.png'),
},
},
'gatsby-plugin-meta-redirect',
],
}
Loading

0 comments on commit 183f120

Please sign in to comment.