feat: add "Edit on GitHub" links to each page (#69)

* feat: add "Edit on GitHub" links to certain pages This adds the "edit on GitHub" links to all pages, except policy pages. All pages point to their direct counterpart in either this repo or `npm/cli` with the following exceptions: - Generated index pages in the `/cli/` section point to `npm/cli/edit/<BRANCH>/docs/nav.yml` since those contain the section titles. - The root edit link in the sidebar is removed since it doesn't make sense to link directly to the homepage of this repo when content is split across both repos. - `index.mdx` pages in all other sections are linked to directly since many of them contain at least some canonical content. I added a comment to each page in the source indicating that the hierarchical links in those pages are generated based on `src/nav-base.yml`. Closes #48 * fixup! add back path prefix

Luke Karrys committed Mar 1, 2022 at 15:04 UTC 460d30e16090b1083c5df24b21354590412b5847
55 files changed +204 -199
.github/workflows/stage-pull-request.yml
-12
@@ -47,15 +47,3 @@ jobs:
47 -H "Content-Type: application/json" \
48 --data "{ \"event_type\": \"publish_pr\", \"client_payload\": { \"pr_number\":\"$PR_NUMBER\", \"notify\":\"$NOTIFY\" } }" \
49 https://api.github.com/repos/${{ env.staging_repo }}/dispatches
50 -
51 -# - name: Identify pull request
52 -# if: github.event_name == "pull_request_target"
53 -# uses: actions/github-script@v3
54 -# with:
55 -# script: |
56 -# github.issues.createComment({
57 -# issue_number: context.issue.number,
58 -# owner: context.repo.owner,
59 -# repo: context.repo.repo,
60 -# body: "👋 Thanks for opening a pull request! We're building a staging
61 -# })
cli/cli_import.js
+105 -138
@@ -19,11 +19,10 @@
19 //
20 // 2. Read each directory specified in the `releases.json`. The data in
21 // `docs/content` will be read. Each file will be translated in order
22 -// to add `redirects` (as `redirect_from` frontmatter). Other
23 -// `translations` may be specified to make the data suitable for the
24 -// main documentation from the CLI documentation. Finally, metadata
25 -// will be added so that the gatsby theme knows the GitHub repository
26 -// information for the content.
22 +// to add `redirects` (as `redirect_from` frontmatter). Index pages
23 +// will be created for each section of the CLI documentation. Finally,
24 +// metadata will be added so that the gatsby theme knows the GitHub
25 +// repository information for the content.
26 //
27 // 3. The CLI's navigation (in `docs/nav.yml`) will be added to the
28 // main site's base navigation (in `../src/nav-base.yml`) to produce
@@ -32,12 +31,11 @@
31
32 const fs = require('fs');
33 const path = require('path');
35 -const config = require('./releases.json');
34 +const releases = require('./releases.json');
35 const yaml = require('yaml');
36 const mkdirp = require('mkdirp');
37
38 const githubRepo = 'npm/cli';
40 -const githubUrl = 'https://github.com/npm/cli';
39
40 const docsPath = path.dirname(__dirname);
41 const inputPath = path.join(docsPath, 'cli');
@@ -52,27 +50,6 @@ const cliUrl = '/cli';
50 const cliNavFile = path.join('docs', 'nav.yml');
51 const cliContentPath = path.join('docs', 'content');
52
55 -const indexMarkdown = `<Index depth="1" />`;
56 -
57 -const translations = {
58 - 'index.mdx': {
59 - 'frontmatter': { 'title': 'CLI documentation' },
60 - 'mdx': indexMarkdown,
61 - },
62 - 'commands/index.mdx': {
63 - 'frontmatter': { 'title': 'CLI commands' },
64 - 'mdx': indexMarkdown,
65 - },
66 - 'configuring-npm/index.mdx': {
67 - 'frontmatter': { 'title': 'Configuring npm' },
68 - 'mdx': indexMarkdown,
69 - },
70 - 'using-npm/index.mdx': {
71 - 'frontmatter': { 'title': 'Using npm' },
72 - 'mdx': indexMarkdown,
73 - },
74 -};
75 -
53 const redirects = {
54 'index.mdx': [
55 '/cli-documentation',
@@ -119,8 +96,8 @@ const redirects = {
96 '/files/shrinkwrap.json.html',
97 ],
98 'using-npm/index.mdx': [
122 - 'cli-documentation/misc',
123 - 'cli-documentation/using-npm',
99 + '/cli-documentation/misc',
100 + '/cli-documentation/using-npm',
101 '/misc/index.html',
102 ],
103 'using-npm/removal.md': [
@@ -132,21 +109,46 @@ const redirects = {
109 ],
110 };
111
135 -const pagesForVersion = { }
136 -
137 -config.forEach((version) => {
112 +const pagesForVersion = { };
113 +const navForVersion = { };
114 +
115 +releases.forEach(buildCliVersion);
116 +updateNav();
117 +ensurePagesLinked();
118 +
119 +function buildCliVersion(version) {
120 + const navInputFile = fs.readFileSync(path.join(inputPath, version.id, cliNavFile), 'utf8');
121 + const children = rewriteUrls(version, yaml.parse(navInputFile));
122 + navForVersion[version.id] = {
123 + title: version.title,
124 + shortName: version.id,
125 + url: `${cliUrl}/${version.id}`,
126 + default: version.default ? true : false,
127 + children,
128 + };
129 pagesForVersion[version.id] = copyDocs(version);
139 -});
130 +}
131 +
132 +function rewriteUrls(version, nodes) {
133 + nodes.forEach((n) => {
134 + const path = n.url.startsWith('/') ? n.url.substring(1) : n.url;
135 + const data = translate(version, { path: path });
136
141 -updateNav(config);
142 -ensurePagesLinked(config);
137 + n.url = `${cliUrl}/${version.id}/${data.path}`;
138
144 -function updateNav(config) {
139 + if (n.children) {
140 + rewriteUrls(version, n.children);
141 + }
142 + });
143 + return nodes
144 +}
145 +
146 +function updateNav() {
147 const nav = yaml.parse(fs.readFileSync(baseNavFile, 'utf8'));
148 const variants = new Array();
149
148 - config.forEach((version) => {
149 - variants.push(readNavForVersion(version));
150 + releases.forEach((version) => {
151 + variants.push(navForVersion[version.id]);
152 });
153
154 nav.push({
@@ -158,71 +160,40 @@ function updateNav(config) {
160
161 const output = '# This file is automatically generated. Do not edit.\n' +
162 '# For registry content, edit `src/nav-base.yml in this repository.\n' +
161 - '# For CLI content, edit `docs/nav.yml` in https://github.com/npm/cli.\n' +
163 + `# For CLI content, edit \`${cliNavFile}\` in https://github.com/${githubRepo}.\n` +
164 '\n' +
165 yaml.stringify(nav);
166
167 fs.writeFileSync(outputNavFile, output);
168 }
169
168 -function readNavForVersion(config) {
169 - const navInputFile = path.join(inputPath, config.id, cliNavFile);
170 - const children = yaml.parse(fs.readFileSync(navInputFile, 'utf8'));
171 -
172 - rewriteUrls(config, children);
173 -
174 - return {
175 - "title": config.title,
176 - "shortName": config.id,
177 - "url": `${cliUrl}/${config.id}`,
178 - "default": config.default ? true : false,
179 - "children": children
180 - };
181 -}
182 -
183 -function rewriteUrls(config, nodes) {
184 - nodes.forEach((n) => {
185 - const path = n.url.startsWith('/') ? n.url.substring(1) : n.url;
186 - const data = translate(config, { path: path });
187 -
188 - n.url = `${cliUrl}/${config.id}/${data.path}`;
189 -
190 - if (n.children) {
191 - rewriteUrls(config, n.children);
192 - }
193 - });
194 -}
195 -
196 -function translate(config, data) {
197 - const translation = translations[data.path] ? translations[data.path] : { };
198 - let matches;
199 -
170 +function translate(version, data) {
171 if (!data.frontmatter) {
172 data.frontmatter = { };
173 }
174
204 - if (data.path.match(/^index(?:\.md(x)?)?/)) {
205 - if (config.default && data.frontmatter) {
206 - data.frontmatter['redirect_from'] = [
207 - `/cli`,
208 - ];
209 - }
175 + if (!data.frontmatter.redirect_from) {
176 + data.frontmatter.redirect_from = [ ];
177 }
178
212 - else if ((matches = data.path.match(/(?:(.*)\/)index(?:\.md(x)?)?$/))) {
213 - if (config.default && data.frontmatter) {
214 - const section = matches[1];
179 + let matches;
180 +
181 + if ((matches = data.path.match(/(?:(^|.*?)\/?)index(?:\.md(?:x)?)$/))) {
182 + if (version.default) {
183 + const [, section] = matches;
184
216 - data.frontmatter['redirect_from'] = [
185 + data.frontmatter.redirect_from = section ? [
186 `${section}`,
187 `/cli/${section}`,
219 - ];
188 + ] : [
189 + `/cli`,
190 + ]
191 }
192 }
193
223 - else if (data.path.match(/^commands\/npm(\.md(x)?)?$/)) {
224 - if (config.default && data.frontmatter) {
225 - data.frontmatter['redirect_from'] = [
194 + else if (data.path.match(/^commands\/npm(?:\.md(?:x)?)?$/)) {
195 + if (version.default) {
196 + data.frontmatter.redirect_from = [
197 `/cli/npm`,
198 `/cli/npm.html`,
199 `/cli/commands/npm`,
@@ -232,12 +203,11 @@ function translate(config, data) {
203 }
204 }
205
235 - else if ((matches = data.path.match(/^commands\/npm-(.*?)(\.md(?:x)?)?$/)) != null) {
236 - const command = matches[1];
237 - const extension = matches[2] ? matches[2] : '';
206 + else if ((matches = data.path.match(/^commands\/npm-(.*?)(?:\.md(?:x)?)?$/)) != null) {
207 + const [, command] = matches;
208
239 - if (config.default && data.frontmatter) {
240 - data.frontmatter['redirect_from'] = [
209 + if (version.default) {
210 + data.frontmatter.redirect_from = [
211 `/cli/${command}`,
212 `/cli/${command}.html`,
213 `/cli/commands/${command}`,
@@ -248,26 +218,22 @@ function translate(config, data) {
218 }
219 }
220
251 - else if ((matches = data.path.match(/^(configuring-npm)\/(.*?)(\.md(?:x)?)?$/)) != null) {
252 - const path = matches[1];
253 - const page = matches[2];
254 - const extension = matches[3] ? matches[3] : '';
221 + else if ((matches = data.path.match(/^(configuring-npm)\/(.*?)(?:\.md(?:x)?)?$/)) != null) {
222 + const [, path, page] = matches;
223
256 - if (config.default && data.frontmatter) {
257 - data.frontmatter['redirect_from'] = [
224 + if (version.default) {
225 + data.frontmatter.redirect_from = [
226 `/${path}/${page}`,
227 `/${path}/${page}.html`,
228 ];
229 }
230 }
231
264 - else if ((matches = data.path.match(/^(using-npm)\/(.*?)(\.md(?:x)?)?$/)) != null) {
265 - const path = matches[1];
266 - const page = matches[2];
267 - const extension = matches[3] ? matches[3] : '';
232 + else if ((matches = data.path.match(/^(using-npm)\/(.*?)(?:\.md(?:x)?)?$/)) != null) {
233 + const [, path, page] = matches;
234
269 - if (config.default && data.frontmatter) {
270 - data.frontmatter['redirect_from'] = [
235 + if (version.default) {
236 + data.frontmatter.redirect_from = [
237 `/${path}/${page}`,
238 `/${path}/${page}.html`,
239 `/misc/${page}`,
@@ -276,44 +242,45 @@ function translate(config, data) {
242 }
243 }
244
279 - if (redirects[data.path] && config.default) {
280 - if (!data.frontmatter['redirect_from']) {
281 - data.frontmatter['redirect_from'] = { }
282 - }
245 + data.frontmatter.github_repo = githubRepo;
246 + data.frontmatter.github_branch = version.branch;
247 + data.frontmatter.github_path = `${cliContentPath}/${data.path}`;
248
284 - Array.prototype.push.apply(data.frontmatter['redirect_from'], redirects[data.path]);
249 + if (redirects[data.path] && version.default) {
250 + data.frontmatter.redirect_from.push(...redirects[data.path]);
251 }
286 -
287 - if (data.frontmatter) {
288 - data.frontmatter['github_repo'] = `${githubRepo}`;
289 - data.frontmatter['github_branch'] = `${config.branch}`;
290 - data.frontmatter['github_path'] = `${cliContentPath}/${data.path}`;
252 +
253 + if ((matches = data.path.match(/(?:(^|.*?)\/?)index(?:\.md(?:x)?)$/)) != null && !data.mdx) {
254 + // For virtual index pages (meaning they dont come from the cli
255 + // repo), we get the title from the nav section with a matching url.
256 + // Also point the edit link to the nav file, in case there are
257 + // typos or something to fix there.
258 + const [, section] = matches;
259 +
260 + data.frontmatter.title = section
261 + ? navForVersion[version.id].children.find((c) => path.basename(c.url) === section).title
262 + : cliTitle;
263 + data.frontmatter.github_path = cliNavFile;
264 + data.mdx = '\n<Index depth="1" />\n';
265 }
266
293 - if (data.frontmatter && translation.frontmatter) {
294 - for (let name of Object.keys(translation.frontmatter)) {
295 - data.frontmatter[name] = translation.frontmatter[name];
296 - }
297 - }
267 + if (data.mdx) {
268 + const replacer = (_, p1, p2) => `[${p1}](/cli/${version.id}/${p2})`;
269
299 - if ((data.mdx || !data.contents) && translation.mdx) {
300 - data.mdx = translation.mdx;
301 - }
302 - else if (data.mdx) {
303 - function replacer(matches, p1, p2) {
304 - return `[${p1}](/cli/${config.id}/${p2})`;
305 - }
306 -
307 - data.mdx = data.mdx.replace(/@VERSION@/g, config.version)
270 + data.mdx = data.mdx.replace(/@VERSION@/g, version.version)
271 .replace(/\[([^\]]+)\]\(\/(commands\/[^)]+)\)/g, replacer)
272 .replace(/\[([^\]]+)\]\(\/(configuring-npm\/[^)]+)\)/g, replacer)
273 .replace(/\[([^\]]+)\]\(\/(using-npm\/[^)]+)\)/g, replacer);
274 }
275
276 + if (data?.frontmatter?.redirect_from?.length === 0) {
277 + delete data.frontmatter.redirect_from
278 + }
279 +
280 return data;
281 }
282
316 -function ensurePagesLinked(config) {
283 +function ensurePagesLinked() {
284 const nav = yaml.parse(fs.readFileSync(outputNavFile, 'utf8'));
285 let pages = { }
286 let success = true
@@ -336,7 +303,7 @@ function ensurePagesLinked(config) {
303 // identify pages that aren't listed in the nav
304 walkNavigation(nav, (n) => { delete pages[n.url] });
305
339 - Object.keys(pages).filter(p => !p.match("^(.*\/)?index\.md(x)?$")).forEach((page) => {
306 + Object.keys(pages).filter(p => !p.match("^(.*\/)?index\.md(?:x)?$")).forEach((page) => {
307 console.log(`warning: ${page} is not included in navigation`);
308 success = false;
309 });
@@ -360,8 +327,8 @@ function walkNavigation(nodes, fn) {
327 })
328 }
329
363 -function copyDocs(config, relativedir) {
364 - const contentRoot = path.join(inputPath, config.id, cliContentPath);
330 +function copyDocs(version, relativedir) {
331 + const contentRoot = path.join(inputPath, version.id, cliContentPath);
332 const dirPath = relativedir ? path.join(contentRoot, relativedir) : contentRoot;
333
334 let paths = [ ]
@@ -378,7 +345,7 @@ function copyDocs(config, relativedir) {
345 const exists = fs.existsSync(childpath);
346
347 if (exists && fs.lstatSync(childpath).isDirectory()) {
381 - const childpaths = copyDocs(config, relativechild);
348 + const childpaths = copyDocs(version, relativechild);
349 paths = paths.concat(childpaths);
350 }
351 else {
@@ -387,13 +354,13 @@ function copyDocs(config, relativedir) {
354 let output;
355
356 let filedata = {
390 - 'path': relativechild,
391 - 'contents': contents,
392 - 'frontmatter': components ? yaml.parse(components[1]) : null,
393 - 'mdx': components ? components[2] : null
357 + path: relativechild,
358 + contents: contents,
359 + frontmatter: components ? yaml.parse(components[1]) : null,
360 + mdx: components ? components[2] : null
361 };
362
396 - filedata = translate(config, filedata);
363 + filedata = translate(version, filedata);
364
365 if (filedata) {
366 output = "---\n" + yaml.stringify(filedata.frontmatter) + "---\n" + filedata.mdx;
@@ -401,7 +368,7 @@ function copyDocs(config, relativedir) {
368 output = contents;
369 }
370
404 - const filePath = path.join('cli', config.id, filedata.path);
371 + const filePath = path.join('cli', version.id, filedata.path);
372 const outputFilePath = path.join(outputPath, filePath);
373 mkdirp.sync(path.dirname(outputFilePath));
374 fs.writeFileSync(outputFilePath, output);
content/cli/v6/commands/index.mdx
+4 -3
@@ -1,7 +1,8 @@
1 ---
2 github_repo: npm/cli
3 github_branch: v6-docs
4 -github_path: docs/content/commands/index.mdx
5 -title: CLI commands
4 +github_path: docs/nav.yml
5 +title: CLI Commands
6 ---
7 -<Index depth="1" />
\ No newline at end of file
7 +
8 +<Index depth="1" />
content/cli/v6/configuring-npm/index.mdx
+3 -2
@@ -1,7 +1,8 @@
1 ---
2 github_repo: npm/cli
3 github_branch: v6-docs
4 -github_path: docs/content/configuring-npm/index.mdx
4 +github_path: docs/nav.yml
5 title: Configuring npm
6 ---
7 -<Index depth="1" />
\ No newline at end of file
7 +
8 +<Index depth="1" />
content/cli/v6/index.mdx
+4 -3
@@ -1,7 +1,8 @@
1 ---
2 github_repo: npm/cli
3 github_branch: v6-docs
4 -github_path: docs/content/index.mdx
5 -title: CLI documentation
4 +github_path: docs/nav.yml
5 +title: npm CLI
6 ---
7 -<Index depth="1" />
\ No newline at end of file
7 +
8 +<Index depth="1" />
content/cli/v6/using-npm/index.mdx
+3 -2
@@ -1,7 +1,8 @@
1 ---
2 github_repo: npm/cli
3 github_branch: v6-docs
4 -github_path: docs/content/using-npm/index.mdx
4 +github_path: docs/nav.yml
5 title: Using npm
6 ---
7 -<Index depth="1" />
\ No newline at end of file
7 +
8 +<Index depth="1" />
content/cli/v7/commands/index.mdx
+4 -3
@@ -1,7 +1,8 @@
1 ---
2 github_repo: npm/cli
3 github_branch: v7
4 -github_path: docs/content/commands/index.mdx
5 -title: CLI commands
4 +github_path: docs/nav.yml
5 +title: CLI Commands
6 ---
7 -<Index depth="1" />
\ No newline at end of file
7 +
8 +<Index depth="1" />
content/cli/v7/configuring-npm/index.mdx
+3 -2
@@ -1,7 +1,8 @@
1 ---
2 github_repo: npm/cli
3 github_branch: v7
4 -github_path: docs/content/configuring-npm/index.mdx
4 +github_path: docs/nav.yml
5 title: Configuring npm
6 ---
7 -<Index depth="1" />
\ No newline at end of file
7 +
8 +<Index depth="1" />
content/cli/v7/index.mdx
+4 -3
@@ -1,7 +1,8 @@
1 ---
2 github_repo: npm/cli
3 github_branch: v7
4 -github_path: docs/content/index.mdx
5 -title: CLI documentation
4 +github_path: docs/nav.yml
5 +title: npm CLI
6 ---
7 -<Index depth="1" />
\ No newline at end of file
7 +
8 +<Index depth="1" />
content/cli/v7/using-npm/index.mdx
+3 -2
@@ -1,7 +1,8 @@
1 ---
2 github_repo: npm/cli
3 github_branch: v7
4 -github_path: docs/content/using-npm/index.mdx
4 +github_path: docs/nav.yml
5 title: Using npm
6 ---
7 -<Index depth="1" />
\ No newline at end of file
7 +
8 +<Index depth="1" />
content/cli/v8/commands/index.mdx
+4 -3
@@ -6,7 +6,8 @@ redirect_from:
6 - /cli-documentation/cli-commands
7 github_repo: npm/cli
8 github_branch: latest
9 -github_path: docs/content/commands/index.mdx
10 -title: CLI commands
9 +github_path: docs/nav.yml
10 +title: CLI Commands
11 ---
12 -<Index depth="1" />
\ No newline at end of file
12 +
13 +<Index depth="1" />
content/cli/v8/configuring-npm/index.mdx
+3 -2
@@ -6,7 +6,8 @@ redirect_from:
6 - /cli-documentation/files
7 github_repo: npm/cli
8 github_branch: latest
9 -github_path: docs/content/configuring-npm/index.mdx
9 +github_path: docs/nav.yml
10 title: Configuring npm
11 ---
12 -<Index depth="1" />
\ No newline at end of file
12 +
13 +<Index depth="1" />
content/cli/v8/index.mdx
+4 -3
@@ -4,7 +4,8 @@ redirect_from:
4 - /cli-documentation
5 github_repo: npm/cli
6 github_branch: latest
7 -github_path: docs/content/index.mdx
8 -title: CLI documentation
7 +github_path: docs/nav.yml
8 +title: npm CLI
9 ---
10 -<Index depth="1" />
\ No newline at end of file
10 +
11 +<Index depth="1" />
content/cli/v8/using-npm/index.mdx
+5 -4
@@ -2,12 +2,13 @@
2 redirect_from:
3 - using-npm
4 - /cli/using-npm
5 - - cli-documentation/misc
6 - - cli-documentation/using-npm
5 + - /cli-documentation/misc
6 + - /cli-documentation/using-npm
7 - /misc/index.html
8 github_repo: npm/cli
9 github_branch: latest
10 -github_path: docs/content/using-npm/index.mdx
10 +github_path: docs/nav.yml
11 title: Using npm
12 ---
13 -<Index depth="1" />
\ No newline at end of file
13 +
14 +<Index depth="1" />
content/getting-started/configuring-your-local-environment/index.mdx
+1
@@ -2,4 +2,5 @@
2 title: Configuring your local environment
3 ---
4
5 +<!-- edit the output of Index in `src/nav-base.yml` -->
6 <Index />
content/getting-started/index.mdx
+1
@@ -2,4 +2,5 @@
2 title: Getting started
3 ---
4
5 +<!-- edit the output of Index in `src/nav-base.yml` -->
6 <Index />
content/getting-started/managing-your-npm-user-account/index.mdx
+1
@@ -2,4 +2,5 @@
2 title: Managing your npm user account
3 ---
4
5 +<!-- edit the output of Index in `src/nav-base.yml` -->
6 <Index />
content/getting-started/paying-for-your-npm-user-account/index.mdx
+1
@@ -2,4 +2,5 @@
2 title: Paying for your npm user account
3 ---
4
5 +<!-- edit the output of Index in `src/nav-base.yml` -->
6 <Index />
content/getting-started/setting-up-your-npm-user-account/index.mdx
+1
@@ -2,4 +2,5 @@
2 title: Setting up your npm user account
3 ---
4
5 +<!-- edit the output of Index in `src/nav-base.yml` -->
6 <Index />
content/getting-started/troubleshooting/index.mdx
+1
@@ -2,4 +2,5 @@
2 title: Troubleshooting
3 ---
4
5 +<!-- edit the output of Index in `src/nav-base.yml` -->
6 <Index />
content/index.mdx
+4 -3
@@ -1,9 +1,10 @@
1 ---
2 title: npm Documentation
3 +github_path: src/nav-base.yml
4 ---
4 -import {HeroLayout} from 'gatsby-theme-doctornpm'
5 -import {Index} from 'gatsby-theme-doctornpm'
5 +
6 +import {HeroLayout, Index} from 'gatsby-theme-doctornpm'
7 export default HeroLayout
8
9 +<!-- edit the output of Index in `src/nav-base.yml` -->
10 <Index depth='1' />
9 -
content/integrations/index.mdx
+1
@@ -2,4 +2,5 @@
2 title: Integrations
3 ---
4
5 +<!-- edit the output of Index in `src/nav-base.yml` -->
6 <Index />
content/integrations/integrating-npm-with-external-services/index.mdx
+1
@@ -2,4 +2,5 @@
2 title: Integrating npm with external services
3 ---
4
5 +<!-- edit the output of Index in `src/nav-base.yml` -->
6 <Index />
content/organizations/creating-and-managing-organizations/index.mdx
+1
@@ -4,4 +4,5 @@ redirect_from:
4 - /orgs/creating-and-managing-orgs
5 ---
6
7 +<!-- edit the output of Index in `src/nav-base.yml` -->
8 <Index />
content/organizations/index.mdx
+2
@@ -4,9 +4,11 @@ redirect_from:
4 - /getting-started/working-with-orgs
5 - /orgs
6 ---
7 +
8 import {Link} from '@primer/components'
9 import shared from '../../src/shared.js'
10
11 <>Organizations allow teams of contributors to read, write, and public and private packages. Organizations are free when they publish public packages. When organizations publish private packages, an npm Teams subscription is required. For more information on npm Teams pricing, see our <Link href="https://www.npmjs.com/pricing">products page</Link>.</>
12
13 +<!-- edit the output of Index in `src/nav-base.yml` -->
14 <Index />
content/organizations/managing-organization-members/index.mdx
+1
@@ -4,4 +4,5 @@ redirect_from:
4 - /orgs/managing-org-members
5 ---
6
7 +<!-- edit the output of Index in `src/nav-base.yml` -->
8 <Index />
content/organizations/managing-organization-packages/index.mdx
+1
@@ -4,4 +4,5 @@ redirect_from:
4 - /orgs/managing-org-packages
5 ---
6
7 +<!-- edit the output of Index in `src/nav-base.yml` -->
8 <Index />
content/organizations/managing-teams/index.mdx
+1
@@ -4,4 +4,5 @@ redirect_from:
4 - /orgs/managing-teams
5 ---
6
7 +<!-- edit the output of Index in `src/nav-base.yml` -->
8 <Index />
content/organizations/paying-for-your-organization/index.mdx
+1
@@ -4,4 +4,5 @@ redirect_from:
4 - /orgs/paying-for-your-org
5 ---
6
7 +<!-- edit the output of Index in `src/nav-base.yml` -->
8 <Index />
content/packages-and-modules/contributing-packages-to-the-registry/index.mdx
+1
@@ -3,4 +3,5 @@ title: Contributing packages to the registry
3 redirect_from: [ /getting-started/publishing-npm-packages ]
4 ---
5
6 +<!-- edit the output of Index in `src/nav-base.yml` -->
7 <Index />
content/packages-and-modules/getting-packages-from-the-registry/index.mdx
+1
@@ -2,4 +2,5 @@
2 title: Getting packages from the registry
3 ---
4
5 +<!-- edit the output of Index in `src/nav-base.yml` -->
6 <Index />
content/packages-and-modules/index.mdx
+1
@@ -2,4 +2,5 @@
2 title: Packages and modules
3 ---
4
5 +<!-- edit the output of Index in `src/nav-base.yml` -->
6 <Index />
content/packages-and-modules/introduction-to-packages-and-modules/index.mdx
+1
@@ -2,4 +2,5 @@
2 title: Introduction to packages and modules
3 ---
4
5 +<!-- edit the output of Index in `src/nav-base.yml` -->
6 <Index />
content/packages-and-modules/securing-your-code/index.mdx
+1
@@ -2,4 +2,5 @@
2 title: Securing your code
3 ---
4
5 +<!-- edit the output of Index in `src/nav-base.yml` -->
6 <Index />
content/packages-and-modules/updating-and-managing-your-published-packages/index.mdx
+1
@@ -2,4 +2,5 @@
2 title: Updating and managing your published packages
3 ---
4
5 +<!-- edit the output of Index in `src/nav-base.yml` -->
6 <Index />
content/policies/business-solution-terms.mdx
+1
@@ -1,5 +1,6 @@
1 ---
2 title: npm Business Solution Terms
3 +edit_on_github: false
4 ---
5
6 Version 4.2.1
content/policies/conduct.mdx
+1
@@ -1,5 +1,6 @@
1 ---
2 title: npm Code of Conduct
3 +edit_on_github: false
4 ---
5 npm exists to facilitate sharing code, by making it easy for
6 JavaScript module developers to publish and distribute packages.
content/policies/crawlers.mdx
+1
@@ -1,5 +1,6 @@
1 ---
2 title: Crawler policy
3 +edit_on_github: false
4 ---
5
6 npm's full public dataset is available via the [public registry](https://docs.npmjs.com/misc/registry). Using CouchDB replication, you can get a full copy of all metadata, and it is acceptable within our terms of use to download copies of tarballs for inspection or experimentation.
content/policies/disputes.mdx
+1
@@ -1,5 +1,6 @@
1 ---
2 title: Dispute Resolution
3 +edit_on_github: false
4 ---
5
6 This document describes the steps that you should take to resolve
content/policies/dmca.mdx
+1
@@ -1,5 +1,6 @@
1 ---
2 title: Copyright Policy
3 +edit_on_github: false
4 ---
5
6 This policy describes how we at npm, Inc., the company behind npmjs.com
content/policies/domains.mdx
+1
@@ -1,5 +1,6 @@
1 ---
2 title: What domains does npm use?
3 +edit_on_github: false
4 ---
5
6 How can you tell an email or domain really belongs to npm and isn't a phishing attempt? Here's a full list:
content/policies/index.mdx
+2
@@ -1,9 +1,11 @@
1 ---
2 title: Policies
3 +edit_on_github: false
4 ---
5
6 These are the legal policies of npm, Inc.
7
8 +<!-- edit the output of Index in `src/nav-base.yml` -->
9 <Index />
10
11 These are updated from time to time. Their sources are stored in a git repository at [https://github.com/npm/documentation/tree/main/content/policies](https://github.com/npm/documentation/tree/main/content/policies).
content/policies/npm-license.mdx
+1
@@ -1,5 +1,6 @@
1 ---
2 title: npm License
3 +edit_on_github: false
4 ---
5
6 Copyright (c) npm, Inc. and Contributors
content/policies/open-source-terms.mdx
+1
@@ -1,5 +1,6 @@
1 ---
2 title: npm Open-Source Terms
3 +edit_on_github: false
4 ---
5 <!-- TODO: Replace last-updated date for every published change -->
6 These npm Open Source terms of use (these _Terms_) govern access to
content/policies/orgs-plan.mdx
+1
@@ -1,5 +1,6 @@
1 ---
2 title: npm Orgs Payment Plan
3 +edit_on_github: false
4 ---
5
6 This npm Orgs Payment Plan (this _Payment Plan_) supplements
content/policies/privacy.mdx
+1
@@ -1,5 +1,6 @@
1 ---
2 title: Privacy Questions and Answers
3 +edit_on_github: false
4 ---
5
6 This notice describes how [npm, Inc.](https://www.npmjs.com/about), or _npm_ for short, collects and uses data about you.
content/policies/private-terms.mdx
+1
@@ -1,5 +1,6 @@
1 ---
2 title: npm Paid Services Terms
3 +edit_on_github: false
4 ---
5
6 These npm Paid Services Terms of Use (these _npm Paid Services Terms_)
content/policies/security.mdx
+1
@@ -1,5 +1,6 @@
1 ---
2 title: npm Security Policy
3 +edit_on_github: false
4 ---
5
6 Outlined in this document are the practices and policies that npm
content/policies/solo-plan.mdx
+1
@@ -1,5 +1,6 @@
1 ---
2 title: Solo Payment Plan
3 +edit_on_github: false
4 ---
5
6 This npm Solo Payment Plan (this _Payment Plan_) supplements
content/policies/terms.mdx
+1
@@ -1,5 +1,6 @@
1 ---
2 title: Terms and Licenses
3 +edit_on_github: false
4 ---
5 npm, Inc. offers software and services under a few different licenses
6 and terms of use.
content/policies/trademark.mdx
+1
@@ -1,5 +1,6 @@
1 ---
2 title: npm Trademark Policy
3 +edit_on_github: false
4 ---
5
6 This policy describes npm trademarks and how you may use them.
content/policies/unpublish.mdx
+1
@@ -1,5 +1,6 @@
1 ---
2 title: npm Unpublish Policy
3 +edit_on_github: false
4 ---
5
6 This document describes your options when looking to unpublish a package published to the public registry.
gatsby-config.js
+3 -2
@@ -11,8 +11,9 @@ module.exports = {
11 resolve: 'gatsby-theme-doctornpm',
12 options: {
13 icon: './src/images/npm-favicon.png',
14 - editOnGitHub: false,
14 + editOnGitHub: true,
15 showContributors: false,
16 + showSidebarEditLink: false,
17 repo: {
18 url: 'https://github.com/npm/documentation',
19 defaultBranch: 'main',
@@ -21,5 +22,5 @@ module.exports = {
22 },
23 'gatsby-plugin-meta-redirect'
24 ],
24 - pathPrefix: process.env.PATH_PREFIX || ''
25 + pathPrefix: process.env.PATH_PREFIX || '',
26 }
package-lock.json
+7 -7
@@ -10,7 +10,7 @@
10 "dependencies": {
11 "gatsby": "^2.32.7",
12 "gatsby-plugin-meta-redirect": "^1.1.1",
13 - "gatsby-theme-doctornpm": "^1.8.0",
13 + "gatsby-theme-doctornpm": "^1.9.0",
14 "react": "^16.14.0",
15 "react-dom": "^16.14.0"
16 }
@@ -12074,9 +12074,9 @@
12074 }
12075 },
12076 "node_modules/gatsby-theme-doctornpm": {
12077 - "version": "1.8.0",
12078 - "resolved": "https://registry.npmjs.org/gatsby-theme-doctornpm/-/gatsby-theme-doctornpm-1.8.0.tgz",
12079 - "integrity": "sha512-+gT6PoFXjQCtQsPTvTv2E/DN/naoL0qax+fodcPRFINqYOW/DqSPDk5ZzQ49NzjJqZNzpLNPZSn5QbjsqgpTHQ==",
12077 + "version": "1.9.0",
12078 + "resolved": "https://registry.npmjs.org/gatsby-theme-doctornpm/-/gatsby-theme-doctornpm-1.9.0.tgz",
12079 + "integrity": "sha512-J2D9HUlpySTchXx6uqqffjSa/rD3KQ+VoQHCPCsbA3R//v3zjrI7yjhRJRrmC53/BMGskaKg6tP+Q2Z664Oj3A==",
12080 "dependencies": {
12081 "@babel/preset-env": "^7.5.5",
12082 "@babel/preset-react": "^7.0.0",
@@ -40162,9 +40162,9 @@
40162 }
40163 },
40164 "gatsby-theme-doctornpm": {
40165 - "version": "1.8.0",
40166 - "resolved": "https://registry.npmjs.org/gatsby-theme-doctornpm/-/gatsby-theme-doctornpm-1.8.0.tgz",
40167 - "integrity": "sha512-+gT6PoFXjQCtQsPTvTv2E/DN/naoL0qax+fodcPRFINqYOW/DqSPDk5ZzQ49NzjJqZNzpLNPZSn5QbjsqgpTHQ==",
40165 + "version": "1.9.0",
40166 + "resolved": "https://registry.npmjs.org/gatsby-theme-doctornpm/-/gatsby-theme-doctornpm-1.9.0.tgz",
40167 + "integrity": "sha512-J2D9HUlpySTchXx6uqqffjSa/rD3KQ+VoQHCPCsbA3R//v3zjrI7yjhRJRrmC53/BMGskaKg6tP+Q2Z664Oj3A==",
40168 "requires": {
40169 "@babel/preset-env": "^7.5.5",
40170 "@babel/preset-react": "^7.0.0",
package.json
+2 -5
@@ -6,15 +6,12 @@
6 "scripts": {
7 "develop": "gatsby develop",
8 "build": "gatsby build",
9 - "build-prefix-paths": "gatsby build --prefix-paths",
10 - "now-build": "npm run build",
11 - "serve": "gatsby serve",
12 - "serve-prefix-paths": "gatsby serve --prefix-paths"
9 + "serve": "gatsby serve"
10 },
11 "dependencies": {
12 "gatsby": "^2.32.7",
13 "gatsby-plugin-meta-redirect": "^1.1.1",
17 - "gatsby-theme-doctornpm": "^1.8.0",
14 + "gatsby-theme-doctornpm": "^1.9.0",
15 "react": "^16.14.0",
16 "react-dom": "^16.14.0"
17 }