Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
63 changes: 32 additions & 31 deletions docs/lib/build.js
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,8 @@ const pAll = async (obj) => {
}, {})
}

const run = async ({ content, template, nav, man, html, md }) => {
const run = async (params) => {
const { content, template, nav, man, html, md } = params
await rmAll(man, html, md)
const [contentPaths, navFile, options] = await Promise.all([
readDocs(content),
Expand Down Expand Up @@ -91,36 +92,36 @@ const run = async ({ content, template, nav, man, html, md }) => {
...(fullName === 'using-npm/config'
? [transform.shorthands, transform.config]
: []),
])

if (data.section) {
const manSrc = applyTransforms(transformedSrc, [
transform.helpLinks,
transform.man,
])
const manPaths = [
name,
fullName === 'configuring-npm/package-json' && 'npm-json',
fullName === 'configuring-npm/folders' && 'npm-global',
].filter(Boolean).map(p => applyTransforms(p, [transform.manPath]))

acc.man.push(...manPaths.map((manPath) => ({
path: manPath,
fullPath: join(man, manPath),
src: manSrc,
})))
}

acc.html.push({
path: `${fullName}.html`,
fullPath: join(html, `${fullName}.html`),
src: applyTransforms(transformedSrc, [transform.html]),
})

acc.md.push({
path: childPath,
fullPath: join(md, childPath),
src: applyTransforms(transformedSrc, [transform.md]),
]);

['man', 'html', 'md'].forEach((type) => {
const isMan = type === 'man'
const DUPLICATED_FOLDER_PATH = 'configuring-npm/'
const FOLDER_PREFIX = isMan ? '' : DUPLICATED_FOLDER_PATH
const trs = [transform[type]]

let paths = [
isMan ? name : fullName,
fullName === `${DUPLICATED_FOLDER_PATH}package-json` && `${FOLDER_PREFIX}npm-json`,
fullName === `${DUPLICATED_FOLDER_PATH}folders` && `${FOLDER_PREFIX}npm-global`,
].filter(Boolean)

if (isMan && data.section) {
paths = paths.map(p => applyTransforms(p, [transform.manPath]))
trs.unshift(transform.helpLinks)
const manSrc = applyTransforms(transformedSrc, trs)
acc.man.push(...paths.map((manPath) => ({
path: manPath,
fullPath: join(man, manPath),
src: manSrc,
})))
} else {
acc[type].push(...paths.map((path) => ({
path: `${path}.${type}`,
fullPath: join(params[type], `${path}.${type}`),
src: applyTransforms(transformedSrc, trs),
})))
}
})
return acc
}, { man: [], html: [], md: [] })
Expand Down
6 changes: 6 additions & 0 deletions docs/lib/content/nav.yml
Original file line number Diff line number Diff line change
Expand Up @@ -215,6 +215,9 @@
- title: Folders
url: /configuring-npm/folders
description: Folder structures used by npm
- title: Folders
url: /configuring-npm/npm-global
description: Folder structures used by npm
- title: .npmrc
url: /configuring-npm/npmrc
description: The npm config files
Expand All @@ -224,6 +227,9 @@
- title: package.json
url: /configuring-npm/package-json
description: Specifics of npm's package.json handling
- title: package.json
url: /configuring-npm/npm-json
description: Specifics of npm's package.json handling
- title: package-lock.json
url: /configuring-npm/package-lock-json
description: A manifestation of the manifest
Expand Down