@reggi/path-to-regexp
@reggi/path-to-regexp
dependabot/npm_and_yarn/main/copy-to-clipboard-4.0.2
dependabot/npm_and_yarn/main/eslint-10.4.0
dependabot/npm_and_yarn/main/npmcli/eslint-config-7.0.0
dependabot/npm_and_yarn/main/proc-log-7.0.0
dependabot/npm_and_yarn/npm_and_yarn-826852524d
dependabot/npm_and_yarn/npm_and_yarn-ab9a7f4bc2
deprecate-totp-2fa
dhei/classic-tokens
gat-bypass-2fa-docs
jpg619/fix-accessibility-content-flow
jpg619/version-bump-tar-2
kartykp/gat-bypass-2fa-docs
kartykp/upgrade-path-to-regex
main
maitxn/version-bump-tar
patch-1
reggi/cache-based-on-version
reggi/dev-engines
reggi/fix-transform-prettier
reggi/overrides
update-search-sensitivity
| 1 | import path from 'path' |
| 2 | import fs from 'fs' |
| 3 | import remarkGfm from 'remark-gfm' |
| 4 | import remarkFm from 'remark-frontmatter' |
| 5 | |
| 6 | const {NODE_ENV, GATSBY_CONTENT_ALLOW, GATSBY_CONTENT_IGNORE, GATSBY_CONTENT_DIR = 'content'} = process.env |
| 7 | const DEV = NODE_ENV === 'development' |
| 8 | const CONTENT_DIR = path.resolve(GATSBY_CONTENT_DIR) |
| 9 | |
| 10 | const walkDirs = dir => { |
| 11 | const dirs = fs |
| 12 | .readdirSync(dir) |
| 13 | .filter(d => fs.statSync(path.join(dir, d)).isDirectory()) |
| 14 | .map(p => path.join(dir, p)) |
| 15 | const nested = dirs.flatMap(d => walkDirs(d)) |
| 16 | return [...dirs, ...nested] |
| 17 | } |
| 18 | |
| 19 | const getContentOptions = () => { |
| 20 | if (!DEV || (!GATSBY_CONTENT_ALLOW && !GATSBY_CONTENT_IGNORE)) { |
| 21 | return |
| 22 | } |
| 23 | |
| 24 | const allowContent = (GATSBY_CONTENT_ALLOW ?? '').split(',').filter(Boolean) |
| 25 | const ignoreContent = (GATSBY_CONTENT_IGNORE ?? '').split(',').filter(Boolean) |
| 26 | |
| 27 | const paths = walkDirs(CONTENT_DIR) |
| 28 | .map(p => path.relative(CONTENT_DIR, p)) |
| 29 | .sort() |
| 30 | .reduce( |
| 31 | (acc, p) => { |
| 32 | const allow = allowContent.length ? allowContent.includes(p) : null |
| 33 | const ignore = ignoreContent.length ? ignoreContent.includes(p) : null |
| 34 | if (ignore === true || allow === false) { |
| 35 | acc.ignore.push(p) |
| 36 | } else { |
| 37 | acc.include.push(p) |
| 38 | } |
| 39 | return acc |
| 40 | }, |
| 41 | {include: [], ignore: []}, |
| 42 | ) |
| 43 | |
| 44 | const ignoreGlobs = paths.ignore.map(p => path.join('**', p, '**')) |
| 45 | |
| 46 | console.log(`Only including the following partial content in dev mode`) |
| 47 | console.log(`Allow:\n - ${paths.include.join('\n - ')}`) |
| 48 | console.log(`Ignore:\n - ${ignoreGlobs.join('\n - ')}`) |
| 49 | |
| 50 | return { |
| 51 | ignore: ignoreGlobs, |
| 52 | } |
| 53 | } |
| 54 | |
| 55 | const config = { |
| 56 | trailingSlash: 'never', |
| 57 | siteMetadata: { |
| 58 | title: 'npm Docs', |
| 59 | shortName: 'npm', |
| 60 | description: 'Documentation for the npm registry, website, and command-line interface', |
| 61 | lang: 'en', |
| 62 | imageUrl: 'https://user-images.githubusercontent.com/29712634/81721690-e2fb5d80-9445-11ea-8602-4b2294c964f3.png', |
| 63 | repositoryUrl: 'https://github.com/npm/documentation', |
| 64 | }, |
| 65 | flags: { |
| 66 | DEV_SSR: !!process.env.GATSBY_DEV_SSR, |
| 67 | }, |
| 68 | plugins: [ |
| 69 | 'gatsby-plugin-postcss', |
| 70 | 'gatsby-plugin-styled-components', |
| 71 | 'gatsby-transformer-yaml', |
| 72 | { |
| 73 | resolve: 'gatsby-plugin-mdx', |
| 74 | options: { |
| 75 | mdxOptions: { |
| 76 | remarkPlugins: [remarkGfm, remarkFm], |
| 77 | }, |
| 78 | }, |
| 79 | }, |
| 80 | { |
| 81 | resolve: 'gatsby-source-filesystem', |
| 82 | options: { |
| 83 | name: 'content', |
| 84 | path: CONTENT_DIR, |
| 85 | ...getContentOptions(), |
| 86 | }, |
| 87 | }, |
| 88 | { |
| 89 | resolve: 'gatsby-plugin-manifest', |
| 90 | options: { |
| 91 | icon: path.resolve('./src/favicon.png'), |
| 92 | }, |
| 93 | }, |
| 94 | 'gatsby-plugin-meta-redirect', |
| 95 | ], |
| 96 | } |
| 97 | |
| 98 | export default config |