Refactor theme (#757)
- Separate theme components, layouts, and hooks into directories - Allow shared to be imported with a relative path in content - Remove unused components and their dependencies - Remove one-off deps in favor of inline solutions - Remove edit links from index pages without any content
Luke Karrys committed
Oct 13, 2023 at 22:41 UTC
1a109b4f86c31dac35e16bc0d7ffbec2e8e5d738
117 files changed
+354
-963
.reuse/dep5
+2
-2
@@ -3,10 +3,10 @@ Upstream-Name: documentation
3
Upstream-Contact: Myles Borins <mylesborins@github.com>
4
Source: https://github.com/npm/documentation
5
6
-Files: content/* static/*
6
+Files: content/* static/* src/*
7
Copyright: 2020 GitHub
8
License: CC-BY-4.0
9
10
-Files: scripts/* cli/* theme/* src/* .github/* *.md *.js *.json .npmrc .gitignore .nvmrc
10
+Files: scripts/* cli/* theme/* .github/* *.md *.js *.json .npmrc .gitignore .nvmrc
11
Copyright: 2020 GitHub
12
License: MIT
CONTENT-MODEL.md
+1
-1
@@ -95,7 +95,7 @@ You can use this template when starting a new article. For more information abou
95
---
96
title:
97
---
98
-import shared form '../../../src/shared.js'
98
+import shared from '~/shared.js'
99
100
// Conceptual content: What feature is the article about?
101
// Prerequisites (if applicable): Who can use the feature?
CONTRIBUTING.md
+4
-2
@@ -89,13 +89,15 @@ m login dialog" />)
89
```
90
91
Since MDX is reactive, you can import the shared data at the top of the
92
-file, just beneath your frontmatter:
92
+file, just beneath your frontmatter. It uses the special path `~/shared.js`
93
+so it can be imported the same way from any nested file without needing to
94
+figure out the appropriate relative path:
95
96
```
97
---
98
title: Using shared content
99
---
98
-import shared form '../../../src/shared.js'
100
+import shared form '~/shared.js'
101
```
102
103
And then reference the shared content within `<>`:
content/about-npm/index.mdx
+2
-1
@@ -1,6 +1,7 @@
1
---
2
title: About npm
3
-redirect_from: [ /getting-started/what-is-npm ]
3
+redirect_from:
4
+ - /getting-started/what-is-npm
5
---
6
7
npm is the world's largest software registry. Open source developers from every continent use npm to share and borrow packages, and many organizations use npm to manage private development as well.
content/getting-started/configuring-your-local-environment/downloading-and-installing-node-js-and-npm.mdx
+2
-1
@@ -1,6 +1,7 @@
1
---
2
title: Downloading and installing Node.js and npm
3
-redirect_from: [ /getting-started/installing-node ]
3
+redirect_from:
4
+ - /getting-started/installing-node
5
---
6
7
To publish and install packages to and from the public npm registry or a private npm registry, you must install Node.js and the npm command line interface using either a Node version manager or a Node installer. **We strongly recommend using a Node version manager like [nvm](https://github.com/nvm-sh/nvm) to install Node.js and npm.** We do not recommend using a Node installer, since the Node installation process installs npm in a directory with local permissions and can cause permissions errors when you run npm packages globally.
content/getting-started/configuring-your-local-environment/index.mdx
+1
-1
@@ -1,6 +1,6 @@
1
---
2
title: Configuring your local environment
3
+edit_on_github: false
4
---
5
5
-<!-- edit the output of Index in `src/nav-base.yml` -->
6
<Index />
content/getting-started/index.mdx
+1
-1
@@ -1,6 +1,6 @@
1
---
2
title: Getting started
3
+edit_on_github: false
4
---
5
5
-<!-- edit the output of Index in `src/nav-base.yml` -->
6
<Index />
content/getting-started/managing-your-npm-user-account/changing-your-npm-username.mdx
+1
-1
@@ -1,7 +1,7 @@
1
---
2
title: Changing your npm username
3
---
4
-import shared from '../../../src/shared.js'
4
+import shared from '~/shared.js'
5
6
It is not currently possible to change your npm username. You'll need to
7
create a new account and migrate the data to the new account manually.
content/getting-started/managing-your-npm-user-account/deleting-your-npm-user-account.mdx
+1
-1
@@ -1,7 +1,7 @@
1
---
2
title: Deleting your npm user account
3
---
4
-import shared from '../../../src/shared.js'
4
+import shared from '~/shared.js'
5
6
From the web, you can delete your npm user account.
7
content/getting-started/managing-your-npm-user-account/index.mdx
+1
-1
@@ -1,6 +1,6 @@
1
---
2
title: Managing your npm user account
3
+edit_on_github: false
4
---
5
5
-<!-- edit the output of Index in `src/nav-base.yml` -->
6
<Index />
content/getting-started/managing-your-npm-user-account/managing-your-profile-settings.mdx
+1
-1
@@ -3,7 +3,7 @@ title: Managing your profile settings
3
redirect_from:
4
- /getting-started/modifying_your_profile_from_command_line
5
---
6
-import shared from '../../../src/shared.js'
6
+import shared from '~/shared.js'
7
8
You can manage settings for your user account profile from the web or command line.
9
content/getting-started/paying-for-your-npm-user-account/downgrading-to-a-free-user-account-plan.mdx
+1
-1
@@ -1,7 +1,7 @@
1
---
2
title: Downgrading to a free user account plan
3
---
4
-import shared from '../../../src/shared.js'
4
+import shared from '~/shared.js'
5
6
<Note>
7
content/getting-started/paying-for-your-npm-user-account/index.mdx
+1
-1
@@ -1,6 +1,6 @@
1
---
2
title: Paying for your npm user account
3
+edit_on_github: false
4
---
5
5
-<!-- edit the output of Index in `src/nav-base.yml` -->
6
<Index />
content/getting-started/paying-for-your-npm-user-account/updating-user-account-billing-settings.mdx
+1
-1
@@ -1,7 +1,7 @@
1
---
2
title: Updating user account billing settings
3
---
4
-import shared from '../../../src/shared.js'
4
+import shared from '~/shared.js'
5
6
<Note>
7
content/getting-started/paying-for-your-npm-user-account/upgrading-to-a-paid-user-account-plan.mdx
+1
-1
@@ -1,7 +1,7 @@
1
---
2
title: Upgrading to a paid user account plan
3
---
4
-import shared from '../../../src/shared.js'
4
+import shared from '~/shared.js'
5
6
<Note>
7
content/getting-started/paying-for-your-npm-user-account/viewing-downloading-and-emailing-receipts-for-your-user-account.mdx
+1
-1
@@ -1,7 +1,7 @@
1
---
2
title: Viewing, downloading, and emailing receipts for your npm user account
3
---
4
-import shared from '../../../src/shared.js'
4
+import shared from '~/shared.js'
5
6
<Note>
7
content/getting-started/setting-up-your-npm-user-account/about-two-factor-authentication.mdx
+2
-1
@@ -1,6 +1,7 @@
1
---
2
title: About two-factor authentication
3
-redirect_from: [ /getting-started/using-two-factor-authentication ]
3
+redirect_from:
4
+ - /getting-started/using-two-factor-authentication
5
---
6
7
[Two-factor authentication (2FA)][2fa] protects against unauthorized access to your account by confirming your identity using:
content/getting-started/setting-up-your-npm-user-account/accessing-npm-using-2fa.mdx
+3
-2
@@ -1,8 +1,9 @@
1
---
2
title: Accessing npm using two-factor authentication
3
-redirect_from: [ /getting-started/using-two-factor-authentication ]
3
+redirect_from:
4
+ - /getting-started/using-two-factor-authentication
5
---
5
-import shared from '../../../src/shared.js'
6
+import shared from '~/shared.js'
7
8
## Sign in from the command line using security-key flow
9
content/getting-started/setting-up-your-npm-user-account/configuring-two-factor-authentication.mdx
+1
-1
@@ -1,7 +1,7 @@
1
---
2
title: Configuring two-factor authentication
3
---
4
-import shared from '../../../src/shared.js'
4
+import shared from '~/shared.js'
5
6
You can enable two-factor authentication (2FA) on your npm user account to protect against unauthorized access to your account and packages, either by using a [security-key][webauthn] or [time-based one-time password (TOTP)][totp] from a mobile app.
7
content/getting-started/setting-up-your-npm-user-account/index.mdx
+1
-1
@@ -1,6 +1,6 @@
1
---
2
title: Setting up your npm user account
3
+edit_on_github: false
4
---
5
5
-<!-- edit the output of Index in `src/nav-base.yml` -->
6
<Index />
content/getting-started/setting-up-your-npm-user-account/receiving-a-one-time-password-over-email.mdx
+1
-1
@@ -1,7 +1,7 @@
1
---
2
title: Receiving a one-time password over email
3
---
4
-import shared from '../../../src/shared.js'
4
+import shared from '~/shared.js'
5
6
For your security, npm may require additional verification to allow you to log in to your account. If you do not have [two-factor authentication](configuring-two-factor-authentication) enabled, you may be asked to verify yourself with a one-time password sent to the email address configured for your account.
7
content/getting-started/setting-up-your-npm-user-account/recovering-your-2fa-enabled-account.mdx
+1
-1
@@ -1,7 +1,7 @@
1
---
2
title: Recovering your 2FA-enabled account
3
---
4
-import shared from '../../../src/shared.js'
4
+import shared from '~/shared.js'
5
6
When you have two-factor access enabled on your account, and you lose access to your 2FA device, you may be able to recover your account using the following methods.
7
content/getting-started/troubleshooting/generating-and-locating-npm-debug.log-files.mdx
+1
-1
@@ -3,7 +3,7 @@ title: Generating and locating npm-debug.log files
3
redirect_from:
4
- /generating-and-locating-npm-debug-log-files
5
---
6
-import shared from '../../../src/shared.js'
6
+import shared from '~/shared.js'
7
8
When a package fails to install or publish, the npm CLI will generate an `npm-debug.log` file. This log file can help you figure out what went wrong.
9
content/getting-started/troubleshooting/index.mdx
+1
-1
@@ -1,6 +1,6 @@
1
---
2
title: Troubleshooting
3
+edit_on_github: false
4
---
5
5
-<!-- edit the output of Index in `src/nav-base.yml` -->
6
<Index />
content/index.mdx
+3
-3
@@ -1,10 +1,10 @@
1
---
2
title: npm Documentation
3
-github_path: src/nav-base.yml
3
+github_path: src/nav.yml
4
+edit_on_github: false
5
---
6
6
-import {HeroLayout, Index} from 'theme'
7
+import HeroLayout from 'theme/src/layout/hero'
8
export default HeroLayout
9
9
-<!-- edit the output of Index in `src/nav-base.yml` -->
10
<Index depth='1' />
content/integrations/index.mdx
+1
-1
@@ -1,6 +1,6 @@
1
---
2
title: Integrations
3
+edit_on_github: false
4
---
5
5
-<!-- edit the output of Index in `src/nav-base.yml` -->
6
<Index />
content/integrations/integrating-npm-with-external-services/creating-and-viewing-access-tokens.mdx
+2
-1
@@ -1,6 +1,7 @@
1
---
2
title: Creating and viewing access tokens
3
-redirect_from: [ /creating-and-viewing-authentication-tokens ]
3
+redirect_from:
4
+ - /creating-and-viewing-authentication-tokens
5
---
6
7
You can [create](#creating-access-tokens) and [view](#viewing-access-tokens) access tokens from the website and command line interface (CLI).
content/integrations/integrating-npm-with-external-services/index.mdx
+1
-1
@@ -1,6 +1,6 @@
1
---
2
title: Integrating npm with external services
3
+edit_on_github: false
4
---
5
5
-<!-- edit the output of Index in `src/nav-base.yml` -->
6
<Index />
content/integrations/integrating-npm-with-external-services/revoking-access-tokens.mdx
+2
-1
@@ -1,6 +1,7 @@
1
---
2
title: Revoking access tokens
3
-redirect_from: [ /revoking-authentication-tokens ]
3
+redirect_from:
4
+ - /revoking-authentication-tokens
5
---
6
7
To keep your account and packages secure, we strongly recommend revoking (deleting) tokens you no longer need or that have been compromised. You can revoke any token you have created.
content/organizations/creating-and-managing-organizations/converting-your-user-account-to-an-organization.mdx
+1
-1
@@ -3,7 +3,7 @@ title: Converting your user account to an organization
3
redirect_from:
4
- /converting-your-user-account-to-an-org
5
---
6
-import shared from '../../../src/shared.js'
6
+import shared from '~/shared.js'
7
8
If you have an npm user account, you can convert your user account to an organization. When you convert your user account to an organization, we will:
9
content/organizations/creating-and-managing-organizations/creating-an-organization.mdx
+1
-1
@@ -4,7 +4,7 @@ redirect_from:
4
- /orgs/creating-an-org
5
- /creating-an-org
6
---
7
-import shared from '../../../src/shared.js'
7
+import shared from '~/shared.js'
8
9
Any npm user can create an organization to manage contributor access to packages governed by the organization.
10
content/organizations/creating-and-managing-organizations/deleting-an-organization.mdx
+1
-1
@@ -3,7 +3,7 @@ title: Deleting an organization
3
redirect_from:
4
- /deleting-an-org
5
---
6
-import shared from '../../../src/shared.js'
6
+import shared from '~/shared.js'
7
8
An organization administrator can delete the organization; packages in
9
the organization will also [be deleted](/unpublishing-packages-from-the-registry) if they fulfill the
content/organizations/creating-and-managing-organizations/index.mdx
+1
-1
@@ -2,7 +2,7 @@
2
title: Creating and managing organizations
3
redirect_from:
4
- /orgs/creating-and-managing-orgs
5
+edit_on_github: false
6
---
7
7
-<!-- edit the output of Index in `src/nav-base.yml` -->
8
<Index />
content/organizations/creating-and-managing-organizations/requiring-two-factor-authentication-in-your-organization.mdx
+1
-1
@@ -1,7 +1,7 @@
1
---
2
title: Requiring two-factor authentication in your organization
3
---
4
-import shared from '../../../src/shared.js'
4
+import shared from '~/shared.js'
5
6
Organization owners can require organization members to enable two-factor authentication for their personal accounts, making it harder for malicious actors to access an organization's packages and settings
7
content/organizations/index.mdx
+1
-4
@@ -3,12 +3,9 @@ title: Organizations
3
redirect_from:
4
- /getting-started/working-with-orgs
5
- /orgs
6
+edit_on_github: false
7
---
8
8
-import {Link} from '@primer/components'
9
-import shared from '../../src/shared.js'
10
-
9
<>Organizations allow teams of contributors to read and write 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>.</>
10
13
-<!-- edit the output of Index in `src/nav-base.yml` -->
11
<Index />
content/organizations/managing-organization-members/adding-members-to-your-organization.mdx
+1
-1
@@ -3,7 +3,7 @@ title: Adding members to your organization
3
redirect_from:
4
- /adding-members-to-your-org
5
---
6
-import shared from '../../../src/shared.js'
6
+import shared from '~/shared.js'
7
8
As an organization owner, you can add other npm users to your organization to give them read or read and write access to public and private packages within your organization's scope, as well as public unscoped packages governed by your organization.
9
content/organizations/managing-organization-members/index.mdx
+1
-1
@@ -2,7 +2,7 @@
2
title: Managing organization members
3
redirect_from:
4
- /orgs/managing-org-members
5
+edit_on_github: false
6
---
7
7
-<!-- edit the output of Index in `src/nav-base.yml` -->
8
<Index />
content/organizations/managing-organization-members/managing-organization-permissions.mdx
+1
-1
@@ -3,7 +3,7 @@ title: Managing organization permissions
3
redirect_from:
4
- /managing-org-permissions
5
---
6
-import shared from '../../../src/shared.js'
6
+import shared from '~/shared.js'
7
8
As an organization owner, you can change the role of any member of your organization to add or remove permissions on the organization for that member.
9
content/organizations/managing-organization-members/organization-roles-and-permissions.mdx
+1
-1
@@ -3,7 +3,7 @@ title: Organization roles and permissions
3
redirect_from:
4
- /org-roles-and-permissions
5
---
6
-import shared from '../../../src/shared.js'
6
+import shared from '~/shared.js'
7
8
There are three roles in an organization:
9
content/organizations/managing-organization-members/removing-members-from-your-organization.mdx
+1
-1
@@ -3,7 +3,7 @@ title: Removing members from your organization
3
redirect_from:
4
- /removing-members-from-your-org
5
---
6
-import shared from '../../../src/shared.js'
6
+import shared from '~/shared.js'
7
8
As an organization owner, you can remove members from your organization if they are no longer collaborating on packages owned or governed by your organization.
9
content/organizations/managing-organization-packages/configuring-your-npm-client-with-your-organization-settings.mdx
+1
-1
@@ -3,7 +3,7 @@ title: Configuring your npm client with your organization settings
3
redirect_from:
4
- /configuring-your-npm-client-with-your-org-settings
5
---
6
-import shared from '../../../src/shared.js'
6
+import shared from '~/shared.js'
7
8
As an organization member, you can configure your npm client to:
9
content/organizations/managing-organization-packages/creating-and-publishing-an-organization-scoped-package.mdx
+1
-1
@@ -3,7 +3,7 @@ title: Creating and publishing an organization scoped package
3
redirect_from:
4
- /creating-and-publishing-an-org-scoped-package
5
---
6
-import shared from '../../../src/shared.js'
6
+import shared from '~/shared.js'
7
8
As an organization member, you can create and publish public and private packages within the organization's scope.
9
content/organizations/managing-organization-packages/index.mdx
+1
-1
@@ -2,7 +2,7 @@
2
title: Managing organization packages
3
redirect_from:
4
- /orgs/managing-org-packages
5
+edit_on_github: false
6
---
7
7
-<!-- edit the output of Index in `src/nav-base.yml` -->
8
<Index />
content/organizations/managing-teams/adding-organization-members-to-teams.mdx
+1
-1
@@ -3,7 +3,7 @@ title: Adding organization members to teams
3
redirect_from:
4
- /adding-org-members-to-teams
5
---
6
-import shared from '../../../src/shared.js'
6
+import shared from '~/shared.js'
7
8
As an organization owner or team admin, you can add organization members to teams to give them access to a specific set of packages governed by the organization.
9
content/organizations/managing-teams/creating-teams.mdx
+1
-1
@@ -1,7 +1,7 @@
1
---
2
title: Creating teams
3
---
4
-import shared from '../../../src/shared.js'
4
+import shared from '~/shared.js'
5
6
As an organization owner or team admin, you can create teams to manage access to sets of packages governed by your organization.
7
content/organizations/managing-teams/index.mdx
+1
-1
@@ -2,7 +2,7 @@
2
title: Managing teams
3
redirect_from:
4
- /orgs/managing-teams
5
+edit_on_github: false
6
---
7
7
-<!-- edit the output of Index in `src/nav-base.yml` -->
8
<Index />
content/organizations/managing-teams/managing-team-access-to-organization-packages.mdx
+1
-1
@@ -4,7 +4,7 @@ redirect_from:
4
- /managing-team-access-to-org-packages
5
- /managing-team-access-to-packages
6
---
7
-import shared from '../../../src/shared.js'
7
+import shared from '~/shared.js'
8
9
As an organization owner or team admin, you can add or remove package access to or from teams in your organization.
10
content/organizations/managing-teams/removing-organization-members-from-teams.mdx
+1
-1
@@ -3,7 +3,7 @@ title: Removing organization members from teams
3
redirect_from:
4
- /removing-org-members-from-teams
5
---
6
-import shared from '../../../src/shared.js'
6
+import shared from '~/shared.js'
7
8
As an organization owner or team admin, you can remove organization members from teams if they no longer need access to packages accessible to the team.
9
content/organizations/managing-teams/removing-teams.mdx
+1
-1
@@ -1,7 +1,7 @@
1
---
2
title: Removing teams
3
---
4
-import shared from '../../../src/shared.js'
4
+import shared from '~/shared.js'
5
6
As an organization owner or team admin, you can remove teams that no longer need access to a set of packages governed by your organization. Removing the team will not remove the team members or packages from your organization.
7
content/organizations/paying-for-your-organization/downgrading-to-a-free-organization-plan.mdx
+1
-1
@@ -3,7 +3,7 @@ title: Downgrading to a free organization plan
3
redirect_from:
4
- /downgrading-to-a-free-org-plan
5
---
6
-import shared from '../../../src/shared.js'
6
+import shared from '~/shared.js'
7
8
<Note>
9
content/organizations/paying-for-your-organization/index.mdx
+1
-1
@@ -2,7 +2,7 @@
2
title: Paying for your organization
3
redirect_from:
4
- /orgs/paying-for-your-org
5
+edit_on_github: false
6
---
7
7
-<!-- edit the output of Index in `src/nav-base.yml` -->
8
<Index />
content/organizations/paying-for-your-organization/updating-organization-billing-settings.mdx
+1
-1
@@ -3,7 +3,7 @@ title: Updating organization billing settings
3
redirect_from:
4
- /updating-org-billing-settings
5
---
6
-import shared from '../../../src/shared.js'
6
+import shared from '~/shared.js'
7
8
<Note>
9
content/organizations/paying-for-your-organization/upgrading-to-a-paid-organization-plan.mdx
+1
-1
@@ -3,7 +3,7 @@ title: Upgrading to a paid organization plan
3
redirect_from:
4
- /upgrading-to-a-paid-org-plan
5
---
6
-import shared from '../../../src/shared.js'
6
+import shared from '~/shared.js'
7
8
<Note>
9
content/organizations/paying-for-your-organization/viewing-downloading-and-emailing-receipts-for-your-organization.mdx
+1
-1
@@ -3,7 +3,7 @@ title: Viewing, downloading, and emailing receipts for your organization
3
redirect_from:
4
- /viewing-downloading-and-emailing-receipts-for-your-org
5
---
6
-import shared from '../../../src/shared.js'
6
+import shared from '~/shared.js'
7
8
<Note>
9
content/packages-and-modules/contributing-packages-to-the-registry/creating-and-publishing-private-packages.mdx
+1
-1
@@ -3,7 +3,7 @@ title: Creating and publishing private packages
3
redirect_from:
4
- /private-modules/intro
5
---
6
-import shared from '../../../src/shared.js'
6
+import shared from '~/shared.js'
7
8
To share your code with a limited set of users or teams, you can publish private user-scoped or organization-scoped packages to the npm registry.
9
content/packages-and-modules/contributing-packages-to-the-registry/creating-and-publishing-scoped-public-packages.mdx
+1
-1
@@ -1,7 +1,7 @@
1
---
2
title: Creating and publishing scoped public packages
3
---
4
-import shared from '../../../src/shared.js'
4
+import shared from '~/shared.js'
5
6
To share your code publicly in a user or organization namespace, you can publish public user-scoped or organization-scoped packages to the npm registry.
7
content/packages-and-modules/contributing-packages-to-the-registry/index.mdx
+3
-2
@@ -1,7 +1,8 @@
1
---
2
title: Contributing packages to the registry
3
-redirect_from: [ /getting-started/publishing-npm-packages ]
3
+redirect_from:
4
+ - /getting-started/publishing-npm-packages
5
+edit_on_github: false
6
---
7
6
-<!-- edit the output of Index in `src/nav-base.yml` -->
8
<Index />
content/packages-and-modules/getting-packages-from-the-registry/index.mdx
+1
-1
@@ -1,6 +1,6 @@
1
---
2
title: Getting packages from the registry
3
+edit_on_github: false
4
---
5
5
-<!-- edit the output of Index in `src/nav-base.yml` -->
6
<Index />
content/packages-and-modules/index.mdx
+1
-1
@@ -1,6 +1,6 @@
1
---
2
title: Packages and modules
3
+edit_on_github: false
4
---
5
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
-1
@@ -1,6 +1,6 @@
1
---
2
title: Introduction to packages and modules
3
+edit_on_github: false
4
---
5
5
-<!-- edit the output of Index in `src/nav-base.yml` -->
6
<Index />
content/packages-and-modules/securing-your-code/index.mdx
+1
-1
@@ -1,6 +1,6 @@
1
---
2
title: Securing your code
3
+edit_on_github: false
4
---
5
5
-<!-- edit the output of Index in `src/nav-base.yml` -->
6
<Index />
content/packages-and-modules/securing-your-code/requiring-2fa-for-package-publishing-and-settings-modification.mdx
+1
-1
@@ -1,7 +1,7 @@
1
---
2
title: Requiring 2FA for package publishing and settings modification
3
---
4
-import shared from '../../../src/shared.js'
4
+import shared from '~/shared.js'
5
6
To protect your packages, as a package publisher, you can require everyone who has write access to a package to have two-factor authentication (2FA) enabled. This will require that users provide 2FA credentials in addition to their login token when they publish the package. For more information, see "[Configuring two-factor authentication][config-2fa]".
7
content/packages-and-modules/updating-and-managing-your-published-packages/deprecating-and-undeprecating-packages-or-package-versions.mdx
+1
-1
@@ -1,7 +1,7 @@
1
---
2
title: Deprecating and undeprecating packages or package versions
3
---
4
-import shared from '../../../src/shared.js'
4
+import shared from '~/shared.js'
5
6
If you no longer wish to maintain a package, or if you would like to encourage users to update to a new or different version, you can [deprecate][deprecate-cli] it. Deprecating a package or version will print a message to the terminal when a user installs it.
7
content/packages-and-modules/updating-and-managing-your-published-packages/index.mdx
+1
-1
@@ -1,6 +1,6 @@
1
---
2
title: Updating and managing your published packages
3
+edit_on_github: false
4
---
5
5
-<!-- edit the output of Index in `src/nav-base.yml` -->
6
<Index />
content/packages-and-modules/updating-and-managing-your-published-packages/unpublishing-packages-from-the-registry.mdx
+1
-1
@@ -1,7 +1,7 @@
1
---
2
title: Unpublishing packages from the registry
3
---
4
-import shared from '../../../src/shared.js'
4
+import shared from '~/shared.js'
5
6
As a package owner or collaborator, if your package has no dependents, you can permanently remove it from the npm registry by using the CLI. You can [unpublish](https://docs.npmjs.com/cli/commands/npm-unpublish) within 72 hours of the initial publish; beyond 72 hours, you can still unpublish your package if [it meets certain criteria](https://www.npmjs.com/policies/unpublish).
7
content/policies/index.mdx
-1
@@ -5,7 +5,6 @@ edit_on_github: false
5
6
These are the legal policies of npm, Inc.
7
8
-<!-- edit the output of Index in `src/nav-base.yml` -->
8
<Index />
9
10
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).
gatsby-config.js
+1
-2
@@ -12,7 +12,7 @@ module.exports = {
12
{
13
resolve: './theme',
14
options: {
15
- icon: './src/images/npm-favicon.png',
15
+ icon: './src/images/favicon.png',
16
showContributors: false,
17
repo: {
18
url: 'https://github.com/npm/documentation',
@@ -20,6 +20,5 @@ module.exports = {
20
},
21
},
22
},
23
- 'gatsby-plugin-meta-redirect',
23
],
24
}
gatsby-node.js
+21
-13
@@ -1,25 +1,33 @@
1
-exports.onCreateNode = ({ node, actions, getNode }) => {
2
- const { createNodeField } = actions
1
+const path = require('path')
2
3
+exports.onCreateNode = ({ node, actions, getNode }) => {
4
if (node.internal.type === 'Mdx') {
5
- const file = getNode(node.parent)
5
+ const { name, relativeDirectory: dir } = getNode(node.parent)
6
7
- // cli paths are unchanged
8
- if (file.relativeDirectory.startsWith('cli/')) {
9
- return
10
- }
11
-
12
- // directory index paths and policy are unchanged
13
- if (file.name === 'index' ||
14
- file.relativeDirectory.match(/^policies(\/.*)?$/)) {
7
+ // These paths are unchanged:
8
+ // - directory indexes
9
+ // - all cli paths
10
+ // - all policies paths
11
+ if (name === 'index' || dir.startsWith('cli/') || dir.startsWith('policies/')) {
12
return
13
}
14
15
// otherwise, omit the directory path and use the filename as the slug
19
- createNodeField({
16
+ actions.createNodeField({
17
name: 'slug',
18
node,
22
- value: file.name,
19
+ value: name,
20
})
21
}
22
}
23
+
24
+exports.onCreateWebpackConfig = ({ actions }) => {
25
+ actions.setWebpackConfig({
26
+ resolve: {
27
+ alias: {
28
+ '~': path.resolve(__dirname, 'src/'),
29
+ },
30
+ extensions: ['.js'],
31
+ },
32
+ })
33
+}
package-lock.json
+4
-380
@@ -1,11 +1,11 @@
1
{
2
- "name": "npm-documentation",
2
+ "name": "documentation",
3
"version": "1.0.0",
4
"lockfileVersion": 3,
5
"requires": true,
6
"packages": {
7
"": {
8
- "name": "npm-documentation",
8
+ "name": "documentation",
9
"version": "1.0.0",
10
"workspaces": [
11
"cli/",
@@ -13,7 +13,6 @@
13
],
14
"dependencies": {
15
"gatsby": "^4.25.7",
16
- "gatsby-plugin-meta-redirect": "^1.1.1",
16
"react": "^17.0.2",
17
"react-dom": "^17.0.2",
18
"theme": "^1.0.0"
@@ -2383,11 +2382,6 @@
2382
"node": ">=6.9.0"
2383
}
2384
},
2386
- "node_modules/@base2/pretty-print-object": {
2387
- "version": "1.0.1",
2388
- "resolved": "https://registry.npmjs.org/@base2/pretty-print-object/-/pretty-print-object-1.0.1.tgz",
2389
- "integrity": "sha512-4iri8i1AqYHJE2DstZYkyEprg6Pq6sKx3xn5FpySk9sNhH7qN2LLlHJCfDTZRILNwQNPD7mATWM0TBui7uC1pA=="
2390
- },
2385
"node_modules/@bcoe/v8-coverage": {
2386
"version": "0.2.3",
2387
"resolved": "https://registry.npmjs.org/@bcoe/v8-coverage/-/v8-coverage-0.2.3.tgz",
@@ -7830,14 +7824,6 @@
7824
"@babel/types": "^7.20.7"
7825
}
7826
},
7833
- "node_modules/@types/buble": {
7834
- "version": "0.20.3",
7835
- "resolved": "https://registry.npmjs.org/@types/buble/-/buble-0.20.3.tgz",
7836
- "integrity": "sha512-JMXi6r4hCWLNIfseCCga1SEQj3+ozVZXTvm3bLz3z0wGf7Cb0kRexblxZYydYZWh3ixYmA+IBd1zzZ+bSEUByg==",
7837
- "dependencies": {
7838
- "magic-string": "^0.25.0"
7839
- }
7840
- },
7827
"node_modules/@types/cacheable-request": {
7828
"version": "6.0.3",
7829
"resolved": "https://registry.npmjs.org/@types/cacheable-request/-/cacheable-request-6.0.3.tgz",
@@ -10371,132 +10357,6 @@
10357
"node-int64": "^0.4.0"
10358
}
10359
},
10374
- "node_modules/buble": {
10375
- "version": "0.19.6",
10376
- "resolved": "https://registry.npmjs.org/buble/-/buble-0.19.6.tgz",
10377
- "integrity": "sha512-9kViM6nJA1Q548Jrd06x0geh+BG2ru2+RMDkIHHgJY/8AcyCs34lTHwra9BX7YdPrZXd5aarkpr/SY8bmPgPdg==",
10378
- "dependencies": {
10379
- "chalk": "^2.4.1",
10380
- "magic-string": "^0.25.1",
10381
- "minimist": "^1.2.0",
10382
- "os-homedir": "^1.0.1",
10383
- "regexpu-core": "^4.2.0",
10384
- "vlq": "^1.0.0"
10385
- },
10386
- "bin": {
10387
- "buble": "bin/buble"
10388
- }
10389
- },
10390
- "node_modules/buble/node_modules/ansi-styles": {
10391
- "version": "3.2.1",
10392
- "resolved": "https://registry.npmjs.org/ansi-styles/-/ansi-styles-3.2.1.tgz",
10393
- "integrity": "sha512-VT0ZI6kZRdTh8YyJw3SMbYm/u+NqfsAxEpWO0Pf9sq8/e94WxxOpPKx9FR1FlyCtOVDNOQ+8ntlqFxiRc+r5qA==",
10394
- "dependencies": {
10395
- "color-convert": "^1.9.0"
10396
- },
10397
- "engines": {
10398
- "node": ">=4"
10399
- }
10400
- },
10401
- "node_modules/buble/node_modules/chalk": {
10402
- "version": "2.4.2",
10403
- "resolved": "https://registry.npmjs.org/chalk/-/chalk-2.4.2.tgz",
10404
- "integrity": "sha512-Mti+f9lpJNcwF4tWV8/OrTTtF1gZi+f8FqlyAdouralcFWFQWF2+NgCHShjkCb+IFBLq9buZwE1xckQU4peSuQ==",
10405
- "dependencies": {
10406
- "ansi-styles": "^3.2.1",
10407
- "escape-string-regexp": "^1.0.5",
10408
- "supports-color": "^5.3.0"
10409
- },
10410
- "engines": {
10411
- "node": ">=4"
10412
- }
10413
- },
10414
- "node_modules/buble/node_modules/color-convert": {
10415
- "version": "1.9.3",
10416
- "resolved": "https://registry.npmjs.org/color-convert/-/color-convert-1.9.3.tgz",
10417
- "integrity": "sha512-QfAUtd+vFdAtFQcC8CCyYt1fYWxSqAiK2cSD6zDB8N3cpsEBAvRxp9zOGg6G/SHHJYAT88/az/IuDGALsNVbGg==",
10418
- "dependencies": {
10419
- "color-name": "1.1.3"
10420
- }
10421
- },
10422
- "node_modules/buble/node_modules/color-name": {
10423
- "version": "1.1.3",
10424
- "resolved": "https://registry.npmjs.org/color-name/-/color-name-1.1.3.tgz",
10425
- "integrity": "sha512-72fSenhMw2HZMTVHeCA9KCmpEIbzWiQsjN+BHcBbS9vr1mtt+vJjPdksIBNUmKAW8TFUDPJK5SUU3QhE9NEXDw=="
10426
- },
10427
- "node_modules/buble/node_modules/escape-string-regexp": {
10428
- "version": "1.0.5",
10429
- "resolved": "https://registry.npmjs.org/escape-string-regexp/-/escape-string-regexp-1.0.5.tgz",
10430
- "integrity": "sha512-vbRorB5FUQWvla16U8R/qgaFIya2qGzwDrNmCZuYKrbdSUMG6I1ZCGQRefkRVhuOkIGVne7BQ35DSfo1qvJqFg==",
10431
- "engines": {
10432
- "node": ">=0.8.0"
10433
- }
10434
- },
10435
- "node_modules/buble/node_modules/has-flag": {
10436
- "version": "3.0.0",
10437
- "resolved": "https://registry.npmjs.org/has-flag/-/has-flag-3.0.0.tgz",
10438
- "integrity": "sha512-sKJf1+ceQBr4SMkvQnBDNDtf4TXpVhVGateu0t918bl30FnbE2m4vNLX+VWe/dpjlb+HugGYzW7uQXH98HPEYw==",
10439
- "engines": {
10440
- "node": ">=4"
10441
- }
10442
- },
10443
- "node_modules/buble/node_modules/jsesc": {
10444
- "version": "0.5.0",
10445
- "resolved": "https://registry.npmjs.org/jsesc/-/jsesc-0.5.0.tgz",
10446
- "integrity": "sha512-uZz5UnB7u4T9LvwmFqXii7pZSouaRPorGs5who1Ip7VO0wxanFvBL7GkM6dTHlgX+jhBApRetaWpnDabOeTcnA==",
10447
- "bin": {
10448
- "jsesc": "bin/jsesc"
10449
- }
10450
- },
10451
- "node_modules/buble/node_modules/regenerate-unicode-properties": {
10452
- "version": "9.0.0",
10453
- "resolved": "https://registry.npmjs.org/regenerate-unicode-properties/-/regenerate-unicode-properties-9.0.0.tgz",
10454
- "integrity": "sha512-3E12UeNSPfjrgwjkR81m5J7Aw/T55Tu7nUyZVQYCKEOs+2dkxEY+DpPtZzO4YruuiPb7NkYLVcyJC4+zCbk5pA==",
10455
- "dependencies": {
10456
- "regenerate": "^1.4.2"
10457
- },
10458
- "engines": {
10459
- "node": ">=4"
10460
- }
10461
- },
10462
- "node_modules/buble/node_modules/regexpu-core": {
10463
- "version": "4.8.0",
10464
- "resolved": "https://registry.npmjs.org/regexpu-core/-/regexpu-core-4.8.0.tgz",
10465
- "integrity": "sha512-1F6bYsoYiz6is+oz70NWur2Vlh9KWtswuRuzJOfeYUrfPX2o8n74AnUVaOGDbUqVGO9fNHu48/pjJO4sNVwsOg==",
10466
- "dependencies": {
10467
- "regenerate": "^1.4.2",
10468
- "regenerate-unicode-properties": "^9.0.0",
10469
- "regjsgen": "^0.5.2",
10470
- "regjsparser": "^0.7.0",
10471
- "unicode-match-property-ecmascript": "^2.0.0",
10472
- "unicode-match-property-value-ecmascript": "^2.0.0"
10473
- },
10474
- "engines": {
10475
- "node": ">=4"
10476
- }
10477
- },
10478
- "node_modules/buble/node_modules/regjsparser": {
10479
- "version": "0.7.0",
10480
- "resolved": "https://registry.npmjs.org/regjsparser/-/regjsparser-0.7.0.tgz",
10481
- "integrity": "sha512-A4pcaORqmNMDVwUjWoTzuhwMGpP+NykpfqAsEgI1FSH/EzC7lrN5TMd+kN8YCovX+jMpu8eaqXgXPCa0g8FQNQ==",
10482
- "dependencies": {
10483
- "jsesc": "~0.5.0"
10484
- },
10485
- "bin": {
10486
- "regjsparser": "bin/parser"
10487
- }
10488
- },
10489
- "node_modules/buble/node_modules/supports-color": {
10490
- "version": "5.5.0",
10491
- "resolved": "https://registry.npmjs.org/supports-color/-/supports-color-5.5.0.tgz",
10492
- "integrity": "sha512-QjVjwdXIt408MIiAqCX4oUKsgU2EqAGzs2Ppkm4aQYbjm+ZEWEcW4SfFNTr4uMNZma0ey4f5lgLrkB0aX0QMow==",
10493
- "dependencies": {
10494
- "has-flag": "^3.0.0"
10495
- },
10496
- "engines": {
10497
- "node": ">=4"
10498
- }
10499
- },
10360
"node_modules/buffer": {
10361
"version": "5.7.1",
10362
"resolved": "https://registry.npmjs.org/buffer/-/buffer-5.7.1.tgz",
@@ -11591,16 +11451,6 @@
11451
"dot-prop": "^5.1.0"
11452
}
11453
},
11594
- "node_modules/component-props": {
11595
- "version": "1.1.1",
11596
- "resolved": "https://registry.npmjs.org/component-props/-/component-props-1.1.1.tgz",
11597
- "integrity": "sha512-69pIRJs9fCCHRqCz3390YF2LV1Lu6iEMZ5zuVqqUn+G20V9BNXlMs0cWawWeW9g4Ynmg29JmkG6R7/lUJoGd1Q=="
11598
- },
11599
- "node_modules/component-xor": {
11600
- "version": "0.0.4",
11601
- "resolved": "https://registry.npmjs.org/component-xor/-/component-xor-0.0.4.tgz",
11602
- "integrity": "sha512-ZIt6sla8gfo+AFVRZoZOertcnD5LJaY2T9CKE2j13NJxQt/mUafD69Bl7/Y4AnpI2LGjiXH7cOfJDx/n2G9edA=="
11603
- },
11454
"node_modules/compressible": {
11455
"version": "2.0.18",
11456
"resolved": "https://registry.npmjs.org/compressible/-/compressible-2.0.18.tgz",
@@ -13042,15 +12892,6 @@
12892
"utila": "~0.4"
12893
}
12894
},
13045
- "node_modules/dom-iterator": {
13046
- "version": "1.0.0",
13047
- "resolved": "https://registry.npmjs.org/dom-iterator/-/dom-iterator-1.0.0.tgz",
13048
- "integrity": "sha512-7dsMOQI07EMU98gQM8NSB3GsAiIeBYIPKpnxR3c9xOvdvBjChAcOM0iJ222I3p5xyiZO9e5oggkNaCusuTdYig==",
13049
- "dependencies": {
13050
- "component-props": "1.1.1",
13051
- "component-xor": "0.0.4"
13052
- }
13053
- },
12895
"node_modules/dom-serializer": {
12896
"version": "1.4.1",
12897
"resolved": "https://registry.npmjs.org/dom-serializer/-/dom-serializer-1.4.1.tgz",
@@ -13366,17 +13207,6 @@
13207
"node": ">=8.6"
13208
}
13209
},
13369
- "node_modules/entities": {
13370
- "version": "3.0.1",
13371
- "resolved": "https://registry.npmjs.org/entities/-/entities-3.0.1.tgz",
13372
- "integrity": "sha512-WiyBqoomrwMdFG1e0kqvASYfnlb0lp8M5o5Fw2OFq1hNZxxcNk8Ik0Xm7LxzBhuidnZB/UtBqVCgUz3kBOP51Q==",
13373
- "engines": {
13374
- "node": ">=0.12"
13375
- },
13376
- "funding": {
13377
- "url": "https://github.com/fb55/entities?sponsor=1"
13378
- }
13379
- },
13210
"node_modules/env-paths": {
13211
"version": "2.2.1",
13212
"resolved": "https://registry.npmjs.org/env-paths/-/env-paths-2.2.1.tgz",
@@ -17483,11 +17313,6 @@
17313
"url": "https://github.com/sponsors/ljharb"
17314
}
17315
},
17486
- "node_modules/get-node-dimensions": {
17487
- "version": "1.2.1",
17488
- "resolved": "https://registry.npmjs.org/get-node-dimensions/-/get-node-dimensions-1.2.1.tgz",
17489
- "integrity": "sha512-2MSPMu7S1iOTL+BOa6K1S62hB2zUAYNF/lV0gSVlOaacd087lc6nR1H1r0e3B1CerTo+RceOmi1iJW+vp21xcQ=="
17490
- },
17316
"node_modules/get-nonce": {
17317
"version": "1.0.1",
17318
"resolved": "https://registry.npmjs.org/get-nonce/-/get-nonce-1.0.1.tgz",
@@ -18181,15 +18006,6 @@
18006
"node": "^14.17.0 || ^16.13.0 || >=18.0.0"
18007
}
18008
},
18184
- "node_modules/html-dom-parser": {
18185
- "version": "1.2.0",
18186
- "resolved": "https://registry.npmjs.org/html-dom-parser/-/html-dom-parser-1.2.0.tgz",
18187
- "integrity": "sha512-2HIpFMvvffsXHFUFjso0M9LqM+1Lm22BF+Df2ba+7QHJXjk63pWChEnI6YG27eaWqUdfnh5/Vy+OXrNTtepRsg==",
18188
- "dependencies": {
18189
- "domhandler": "4.3.1",
18190
- "htmlparser2": "7.2.0"
18191
- }
18192
- },
18009
"node_modules/html-encoding-sniffer": {
18010
"version": "3.0.0",
18011
"resolved": "https://registry.npmjs.org/html-encoding-sniffer/-/html-encoding-sniffer-3.0.0.tgz",
@@ -18223,20 +18039,6 @@
18039
"integrity": "sha512-H2iMtd0I4Mt5eYiapRdIDjp+XzelXQ0tFE4JS7YFwFevXXMmOp9myNrUvCg0D6ws8iqkRPBfKHgbwig1SmlLfg==",
18040
"dev": true
18041
},
18226
- "node_modules/html-react-parser": {
18227
- "version": "1.4.14",
18228
- "resolved": "https://registry.npmjs.org/html-react-parser/-/html-react-parser-1.4.14.tgz",
18229
- "integrity": "sha512-pxhNWGie8Y+DGDpSh8cTa0k3g8PsDcwlfolA+XxYo1AGDeB6e2rdlyv4ptU9bOTiZ2i3fID+6kyqs86MN0FYZQ==",
18230
- "dependencies": {
18231
- "domhandler": "4.3.1",
18232
- "html-dom-parser": "1.2.0",
18233
- "react-property": "2.0.0",
18234
- "style-to-js": "1.1.1"
18235
- },
18236
- "peerDependencies": {
18237
- "react": "0.14 || 15 || 16 || 17 || 18"
18238
- }
18239
- },
18042
"node_modules/html-void-elements": {
18043
"version": "1.0.5",
18044
"resolved": "https://registry.npmjs.org/html-void-elements/-/html-void-elements-1.0.5.tgz",
@@ -18246,24 +18048,6 @@
18048
"url": "https://github.com/sponsors/wooorm"
18049
}
18050
},
18249
- "node_modules/htmlparser2": {
18250
- "version": "7.2.0",
18251
- "resolved": "https://registry.npmjs.org/htmlparser2/-/htmlparser2-7.2.0.tgz",
18252
- "integrity": "sha512-H7MImA4MS6cw7nbyURtLPO1Tms7C5H602LRETv95z1MxO/7CP7rDVROehUYeYBUYEON94NXXDEPmZuq+hX4sog==",
18253
- "funding": [
18254
- "https://github.com/fb55/htmlparser2?sponsor=1",
18255
- {
18256
- "type": "github",
18257
- "url": "https://github.com/sponsors/fb55"
18258
- }
18259
- ],
18260
- "dependencies": {
18261
- "domelementtype": "^2.0.1",
18262
- "domhandler": "^4.2.2",
18263
- "domutils": "^2.8.0",
18264
- "entities": "^3.0.1"
18265
- }
18266
- },
18051
"node_modules/http-cache-semantics": {
18052
"version": "4.1.1",
18053
"resolved": "https://registry.npmjs.org/http-cache-semantics/-/http-cache-semantics-4.1.1.tgz",
@@ -21149,11 +20933,6 @@
20933
"resolved": "https://registry.npmjs.org/lodash.uniq/-/lodash.uniq-4.5.0.tgz",
20934
"integrity": "sha512-xfBaXQd9ryd9dlSDvnvI0lvxfLJlYAZzXomUYzLKtUeOQvOP5piqAWuGtrhWeqaXK9hhoM/iyJc5AV+XfsX3HQ=="
20935
},
21152
- "node_modules/lodash.uniqby": {
21153
- "version": "4.7.0",
21154
- "resolved": "https://registry.npmjs.org/lodash.uniqby/-/lodash.uniqby-4.7.0.tgz",
21155
- "integrity": "sha512-e/zcLx6CSbmaEgFHCA7BnoQKyCtKMxnuWrJygbwPs/AIn+IMKl66L8/s+wBUn5LRw2pZx3bUHibiV1b6aTWIww=="
21156
- },
20936
"node_modules/lodash.upperfirst": {
20937
"version": "4.3.1",
20938
"resolved": "https://registry.npmjs.org/lodash.upperfirst/-/lodash.upperfirst-4.3.1.tgz",
@@ -21220,14 +20999,6 @@
20999
"es5-ext": "~0.10.2"
21000
}
21001
},
21223
- "node_modules/magic-string": {
21224
- "version": "0.25.9",
21225
- "resolved": "https://registry.npmjs.org/magic-string/-/magic-string-0.25.9.tgz",
21226
- "integrity": "sha512-RmF0AsMzgt25qzqqLc1+MbHmhdx0ojF2Fvs4XnOqz2ZOBXzzkEwc/dJQZCYHAn7v1jbVOjAZfK8msRn4BxO4VQ==",
21227
- "dependencies": {
21228
- "sourcemap-codec": "^1.4.8"
21229
- }
21230
- },
21002
"node_modules/make-dir": {
21003
"version": "3.1.0",
21004
"resolved": "https://registry.npmjs.org/make-dir/-/make-dir-3.1.0.tgz",
@@ -23585,14 +23356,6 @@
23356
"resolved": "https://registry.npmjs.org/ordered-binary/-/ordered-binary-1.4.1.tgz",
23357
"integrity": "sha512-9LtiGlPy982CsgxZvJGNNp2/NnrgEr6EAyN3iIEP3/8vd3YLgAZQHbQ75ZrkfBRGrNg37Dk3U6tuVb+B4Xfslg=="
23358
},
23588
- "node_modules/os-homedir": {
23589
- "version": "1.0.2",
23590
- "resolved": "https://registry.npmjs.org/os-homedir/-/os-homedir-1.0.2.tgz",
23591
- "integrity": "sha512-B5JU3cabzk8c67mRRd3ECmROafjYMXbuzlwtqdM8IbS8ktlTix8aFGb2bAGKrSRIlnfKwovGUUr72JUPyOb6kQ==",
23592
- "engines": {
23593
- "node": ">=0.10.0"
23594
- }
23595
- },
23359
"node_modules/os-tmpdir": {
23360
"version": "1.0.2",
23361
"resolved": "https://registry.npmjs.org/os-tmpdir/-/os-tmpdir-1.0.2.tgz",
@@ -24557,14 +24320,6 @@
24320
"resolved": "https://registry.npmjs.org/platform/-/platform-1.3.6.tgz",
24321
"integrity": "sha512-fnWVljUchTro6RiCFvCXBbNhJc2NijN7oIQxbwsyL0buWJPG85v81ehlHI9fXrJsMNgTofEoWIQeClKpgxFLrg=="
24322
},
24560
- "node_modules/pluralize": {
24561
- "version": "8.0.0",
24562
- "resolved": "https://registry.npmjs.org/pluralize/-/pluralize-8.0.0.tgz",
24563
- "integrity": "sha512-Nc3IT5yHzflTfbjgqWcCPpo7DaKy4FnpB0l/zCAW0Tc7jxAiuqSxHasntB3D7887LSrA93kDJ9IXovxJYxyLCA==",
24564
- "engines": {
24565
- "node": ">=4"
24566
- }
24567
- },
24323
"node_modules/polished": {
24324
"version": "3.5.2",
24325
"resolved": "https://registry.npmjs.org/polished/-/polished-3.5.2.tgz",
@@ -25764,25 +25519,6 @@
25519
"react": "17.0.2"
25520
}
25521
},
25767
- "node_modules/react-element-to-jsx-string": {
25768
- "version": "14.3.4",
25769
- "resolved": "https://registry.npmjs.org/react-element-to-jsx-string/-/react-element-to-jsx-string-14.3.4.tgz",
25770
- "integrity": "sha512-t4ZwvV6vwNxzujDQ+37bspnLwA4JlgUPWhLjBJWsNIDceAf6ZKUTCjdm08cN6WeZ5pTMKiCJkmAYnpmR4Bm+dg==",
25771
- "dependencies": {
25772
- "@base2/pretty-print-object": "1.0.1",
25773
- "is-plain-object": "5.0.0",
25774
- "react-is": "17.0.2"
25775
- },
25776
- "peerDependencies": {
25777
- "react": "^0.14.8 || ^15.0.1 || ^16.0.0 || ^17.0.1",
25778
- "react-dom": "^0.14.8 || ^15.0.1 || ^16.0.0 || ^17.0.1"
25779
- }
25780
- },
25781
- "node_modules/react-element-to-jsx-string/node_modules/react-is": {
25782
- "version": "17.0.2",
25783
- "resolved": "https://registry.npmjs.org/react-is/-/react-is-17.0.2.tgz",
25784
- "integrity": "sha512-w2GsyukL62IJnlaff/nRegPQR94C/XXamvMWmSHRJ4y7Ts/4ocGRmTHvOs8PSE6pB3dWOrD/nueuU5sduBsQ4w=="
25785
- },
25522
"node_modules/react-error-overlay": {
25523
"version": "6.0.11",
25524
"resolved": "https://registry.npmjs.org/react-error-overlay/-/react-error-overlay-6.0.11.tgz",
@@ -25841,16 +25577,6 @@
25577
}
25578
}
25579
},
25844
- "node_modules/react-frame-component": {
25845
- "version": "4.1.3",
25846
- "resolved": "https://registry.npmjs.org/react-frame-component/-/react-frame-component-4.1.3.tgz",
25847
- "integrity": "sha512-4PurhctiqnmC1F5prPZ+LdsalH7pZ3SFA5xoc0HBe8mSHctdLLt4Cr2WXfXOoajHBYq/yiipp9zOgx+vy8GiEA==",
25848
- "peerDependencies": {
25849
- "prop-types": "^15.5.9",
25850
- "react": ">= 16.3",
25851
- "react-dom": ">= 16.3"
25852
- }
25853
- },
25580
"node_modules/react-helmet": {
25581
"version": "6.1.0",
25582
"resolved": "https://registry.npmjs.org/react-helmet/-/react-helmet-6.1.0.tgz",
@@ -25883,33 +25609,6 @@
25609
"resolved": "https://registry.npmjs.org/react-lifecycles-compat/-/react-lifecycles-compat-3.0.4.tgz",
25610
"integrity": "sha512-fBASbA6LnOU9dOU2eW7aQ8xmYBSXUIWr+UmF9b1efZBazGNO+rcXT/icdKnYm2pTwcRylVUYwW7H1PHfLekVzA=="
25611
},
25886
- "node_modules/react-live": {
25887
- "version": "2.4.1",
25888
- "resolved": "https://registry.npmjs.org/react-live/-/react-live-2.4.1.tgz",
25889
- "integrity": "sha512-r+32f7oV/kBs3QZBRvaT+9vOkQW47UZrDpgwUe5FiIMOl7sdo5pmISgb7Zpj5PGHgY6XQaiXs3FEh+IWw3KbRg==",
25890
- "dependencies": {
25891
- "@types/buble": "^0.20.0",
25892
- "buble": "0.19.6",
25893
- "core-js": "^3.14.0",
25894
- "dom-iterator": "^1.0.0",
25895
- "prism-react-renderer": "^1.2.1",
25896
- "prop-types": "^15.7.2",
25897
- "react-simple-code-editor": "^0.11.0",
25898
- "unescape": "^1.0.1"
25899
- },
25900
- "engines": {
25901
- "node": ">= 0.12.0",
25902
- "npm": ">= 2.0.0"
25903
- }
25904
- },
25905
- "node_modules/react-live/node_modules/prism-react-renderer": {
25906
- "version": "1.3.5",
25907
- "resolved": "https://registry.npmjs.org/prism-react-renderer/-/prism-react-renderer-1.3.5.tgz",
25908
- "integrity": "sha512-IJ+MSwBWKG+SM3b2SUfdrhC+gu01QkV2KmRQgREThBfSQRoufqRfxfHUxpG1WcaFjP+kojcFyO9Qqtpgt3qLCg==",
25909
- "peerDependencies": {
25910
- "react": ">=0.14.9"
25911
- }
25912
- },
25612
"node_modules/react-markdown": {
25613
"version": "8.0.7",
25614
"resolved": "https://registry.npmjs.org/react-markdown/-/react-markdown-8.0.7.tgz",
@@ -26115,26 +25814,6 @@
25814
"url": "https://opencollective.com/unified"
25815
}
25816
},
26118
- "node_modules/react-measure": {
26119
- "version": "2.5.2",
26120
- "resolved": "https://registry.npmjs.org/react-measure/-/react-measure-2.5.2.tgz",
26121
- "integrity": "sha512-M+rpbTLWJ3FD6FXvYV6YEGvQ5tMayQ3fGrZhRPHrE9bVlBYfDCLuDcgNttYfk8IqfOI03jz6cbpqMRTUclQnaA==",
26122
- "dependencies": {
26123
- "@babel/runtime": "^7.2.0",
26124
- "get-node-dimensions": "^1.2.1",
26125
- "prop-types": "^15.6.2",
26126
- "resize-observer-polyfill": "^1.5.0"
26127
- },
26128
- "peerDependencies": {
26129
- "react": ">0.13.0",
26130
- "react-dom": ">0.13.0"
26131
- }
26132
- },
26133
- "node_modules/react-property": {
26134
- "version": "2.0.0",
26135
- "resolved": "https://registry.npmjs.org/react-property/-/react-property-2.0.0.tgz",
26136
- "integrity": "sha512-kzmNjIgU32mO4mmH5+iUyrqlpFQhF8K2k7eZ4fdLSOPFrD1XgEuSBv9LDEgxRXTMBqMd8ppT0x6TIzqE5pdGdw=="
26137
- },
25817
"node_modules/react-refresh": {
25818
"version": "0.14.0",
25819
"resolved": "https://registry.npmjs.org/react-refresh/-/react-refresh-0.14.0.tgz",
@@ -26196,15 +25875,6 @@
25875
"react": "^16.3.0 || ^17.0.0 || ^18.0.0"
25876
}
25877
},
26199
- "node_modules/react-simple-code-editor": {
26200
- "version": "0.11.3",
26201
- "resolved": "https://registry.npmjs.org/react-simple-code-editor/-/react-simple-code-editor-0.11.3.tgz",
26202
- "integrity": "sha512-7bVI4Yd1aNCeuldErXUt8ksaAG5Fi+GZ6vp3mtFBnckKdzsQtrgkDvdwMFXIhwTGG+mUYmk5ZpMo0axSW9JBzA==",
26203
- "peerDependencies": {
26204
- "react": "*",
26205
- "react-dom": "*"
26206
- }
26207
- },
25878
"node_modules/react-style-singleton": {
25879
"version": "2.2.1",
25880
"resolved": "https://registry.npmjs.org/react-style-singleton/-/react-style-singleton-2.2.1.tgz",
@@ -26666,11 +26336,6 @@
26336
"node": ">=8"
26337
}
26338
},
26669
- "node_modules/regjsgen": {
26670
- "version": "0.5.2",
26671
- "resolved": "https://registry.npmjs.org/regjsgen/-/regjsgen-0.5.2.tgz",
26672
- "integrity": "sha512-OFFT3MfrH90xIW8OOSyUrk6QHD5E9JOTeGodiJeBS3J6IwlgzJMNE/1bZklWz5oTg+9dCMyEetclvCVXOPoN3A=="
26673
- },
26339
"node_modules/regjsparser": {
26340
"version": "0.9.1",
26341
"resolved": "https://registry.npmjs.org/regjsparser/-/regjsparser-0.9.1.tgz",
@@ -27490,11 +27155,6 @@
27155
"integrity": "sha512-KigOCHcocU3XODJxsu8i/j8T9tzT4adHiecwORRQ0ZZFcp7ahwXuRU1m+yuO90C5ZUyGeGfocHDI14M3L3yDAQ==",
27156
"dev": true
27157
},
27493
- "node_modules/resize-observer-polyfill": {
27494
- "version": "1.5.1",
27495
- "resolved": "https://registry.npmjs.org/resize-observer-polyfill/-/resize-observer-polyfill-1.5.1.tgz",
27496
- "integrity": "sha512-LwZrotdHOo12nQuZlHEmtuXdqGoOD0OhaxopaNFxWzInpEgaLWoVuAMbTzixuosCx2nEG58ngzW3vxdWoxIgdg=="
27497
- },
27158
"node_modules/resolve": {
27159
"version": "1.22.8",
27160
"resolved": "https://registry.npmjs.org/resolve/-/resolve-1.22.8.tgz",
@@ -28383,12 +28043,6 @@
28043
"node": ">=0.10.0"
28044
}
28045
},
28386
- "node_modules/sourcemap-codec": {
28387
- "version": "1.4.8",
28388
- "resolved": "https://registry.npmjs.org/sourcemap-codec/-/sourcemap-codec-1.4.8.tgz",
28389
- "integrity": "sha512-9NykojV5Uih4lgo5So5dtw+f0JgJX30KCNI8gwhz2J9A15wD0Ml6tjHKwf6fTSa6fAdVBdZeNOs9eJ71qCk8vA==",
28390
- "deprecated": "Please use @jridgewell/sourcemap-codec instead"
28391
- },
28046
"node_modules/space-separated-tokens": {
28047
"version": "1.1.5",
28048
"resolved": "https://registry.npmjs.org/space-separated-tokens/-/space-separated-tokens-1.1.5.tgz",
@@ -29048,14 +28702,6 @@
28702
"webpack": "^4.0.0 || ^5.0.0"
28703
}
28704
},
29051
- "node_modules/style-to-js": {
29052
- "version": "1.1.1",
29053
- "resolved": "https://registry.npmjs.org/style-to-js/-/style-to-js-1.1.1.tgz",
29054
- "integrity": "sha512-RJ18Z9t2B02sYhZtfWKQq5uplVctgvjTfLWT7+Eb1zjUjIrWzX5SdlkwLGQozrqarTmEzJJ/YmdNJCUNI47elg==",
29055
- "dependencies": {
29056
- "style-to-object": "0.3.0"
29057
- }
29058
- },
28705
"node_modules/style-to-object": {
28706
"version": "0.3.0",
28707
"resolved": "https://registry.npmjs.org/style-to-object/-/style-to-object-0.3.0.tgz",
@@ -32502,17 +32148,6 @@
32148
"node": ">=14.0"
32149
}
32150
},
32505
- "node_modules/unescape": {
32506
- "version": "1.0.1",
32507
- "resolved": "https://registry.npmjs.org/unescape/-/unescape-1.0.1.tgz",
32508
- "integrity": "sha512-O0+af1Gs50lyH1nUu3ZyYS1cRh01Q/kUKatTOkSs7jukXE6/NebucDVxyiDsA9AQ4JC1V1jUH9EO8JX2nMDgGQ==",
32509
- "dependencies": {
32510
- "extend-shallow": "^2.0.1"
32511
- },
32512
- "engines": {
32513
- "node": ">=0.10.0"
32514
- }
32515
- },
32151
"node_modules/unherit": {
32152
"version": "1.1.3",
32153
"resolved": "https://registry.npmjs.org/unherit/-/unherit-1.1.3.tgz",
@@ -33199,11 +32834,6 @@
32834
"url": "https://opencollective.com/unified"
32835
}
32836
},
33202
- "node_modules/vlq": {
33203
- "version": "1.0.1",
33204
- "resolved": "https://registry.npmjs.org/vlq/-/vlq-1.0.1.tgz",
33205
- "integrity": "sha512-gQpnTgkubC6hQgdIcRdYGDSDc+SaujOdyesZQMv6JlfQee/9Mp0Qhnys6WxDWvQnL5WZdT7o2Ul187aSt0Rq+w=="
33206
- },
32837
"node_modules/w3c-xmlserializer": {
32838
"version": "4.0.0",
32839
"resolved": "https://registry.npmjs.org/w3c-xmlserializer/-/w3c-xmlserializer-4.0.0.tgz",
@@ -34078,8 +33708,8 @@
33708
"@primer/octicons-react": "^19.8.0",
33709
"@primer/react": "^35.31.0",
33710
"@styled-system/theme-get": "^5.1.2",
33711
+ "babel-plugin-styled-components": "^2.1.4",
33712
"copy-to-clipboard": "^3.3.3",
34082
- "date-fns": "^2.30.0",
33713
"details-element-polyfill": "^2.4.0",
33714
"downshift": "^8.2.2",
33715
"framer-motion": "^3.10.6",
@@ -34087,23 +33717,17 @@
33717
"gatsby-plugin-catch-links": "^4.25.0",
33718
"gatsby-plugin-manifest": "^4.25.0",
33719
"gatsby-plugin-mdx": "^3.20.0",
33720
+ "gatsby-plugin-meta-redirect": "^1.1.1",
33721
"gatsby-plugin-react-helmet": "^5.25.0",
33722
"gatsby-plugin-styled-components": "^5.25.0",
33723
"gatsby-source-filesystem": "^4.25.0",
33724
"gatsby-transformer-yaml": "^4.25.0",
33725
"github-slugger": "^2.0.0",
34095
- "html-react-parser": "^1.4.14",
33726
"lodash.debounce": "4.0.8",
34097
- "lodash.uniqby": "^4.7.0",
34098
- "pluralize": "^8.0.0",
33727
"prism-react-renderer": "^0.2.0",
33728
"react-addons-text-content": "^0.0.4",
34101
- "react-element-to-jsx-string": "^14.3.4",
33729
"react-focus-on": "^3.9.1",
34103
- "react-frame-component": "^4.1.3",
33730
"react-helmet": "^6.1.0",
34105
- "react-live": "^2.4.1",
34106
- "react-measure": "^2.5.2",
33731
"styled-components": "^5.3.11",
33732
"styled-system": "^5.1.5"
33733
},
package.json
+3
-4
@@ -1,5 +1,5 @@
1
{
2
- "name": "npm-documentation",
2
+ "name": "documentation",
3
"version": "1.0.0",
4
"repository": {
5
"type": "git",
@@ -7,8 +7,8 @@
7
},
8
"private": true,
9
"scripts": {
10
- "develop": "gatsby develop",
11
- "build": "NODE_OPTIONS=--max-old-space-size=7168 gatsby build --verbose --log-pages",
10
+ "develop": "NODE_OPTIONS=--max-old-space-size=8192 gatsby develop",
11
+ "build": "NODE_OPTIONS=--max-old-space-size=8192 gatsby build --verbose --log-pages",
12
"clean": "rm -rf .cache/ public/",
13
"serve": "gatsby serve",
14
"lint": "eslint \"**/*.js\"",
@@ -27,7 +27,6 @@
27
],
28
"dependencies": {
29
"gatsby": "^4.25.7",
30
- "gatsby-plugin-meta-redirect": "^1.1.1",
30
"react": "^17.0.2",
31
"react-dom": "^17.0.2",
32
"theme": "^1.0.0"
src/images/favicon.png
renamed
src/images/npm-favicon.png
Binary files a/src/images/npm-favicon.png and /dev/null differ
src/shared.js
+3
-4
@@ -1,8 +1,9 @@
1
import React from 'react'
2
import { Link } from '@primer/components'
3
-import { Note, Screenshot } from 'theme'
3
+import Screenshot from '../theme/src/components/screenshot'
4
+import Note from '../theme/src/components/note'
5
5
-const shared = {
6
+export default {
7
/* User login */
8
'user-login': {
9
text: (<>On the npm "<Link href="https://www.npmjs.com/login">Sign In</Link>" page, enter your account details and click <strong>Sign In</strong>.</>),
@@ -212,5 +213,3 @@ const shared = {
213
text: (<Note><><strong>Note:</strong> Using <code><a href="https://www.npmjs.com/package/pneumatic-tubes">pneumatic-tubes</a></code> for migration requires <ul><li>Node 8+</li><li>npm 5+ (to install or upgrade, run <code>npm install npm@latest -g</code>)</li></ul></></Note>),
214
},
215
}
215
-
216
-export default shared
theme/README.md
+6
-15
@@ -1,32 +1,23 @@
1
# theme
2
3
-This theme is a simple fork of the excellent gatsby-theme-doctocat included in primer's [primer.style/doctocat](https://primer.style/doctocat).
4
-
5
-This theme just gives it a little more npm flavor.
6
-
3
```javascript
4
// gatsby-config.js
5
6
module.exports = {
11
- siteMetadata: {
12
- ...
13
- },
7
plugins: [
15
- ...
8
{
9
resolve: './theme',
10
options: {
19
- icon: './src/images/npm-favicon.png',
11
+ icon: './path/to/favicon.png',
12
showContributors: false,
13
repo: {
22
- url: 'https://github.com/npm/documentation',
23
- defaultBranch: 'main'
24
- }
14
+ url: 'https://github.com/org/repo',
15
+ defaultBranch: 'main',
16
+ },
17
},
26
- }
18
+ },
19
],
20
}
29
-
21
```
22
23
## Theme Options
@@ -35,4 +26,4 @@ module.exports = {
26
| ---------------- | -------- | ------- | ------- | ------------------------------------------------------- |
27
| icon | yes | n/a | string | The favicon to display |
28
| showContributors | yes | n/a | boolean | Determines if the repository contributors are displayed |
38
-| repo | yes | n/a | object | `url`, `defaultBranch` and `path` to repository |
29
+| repo | yes | n/a | object | `url` and `defaultBranch` to repository |
theme/gatsby-browser.js
+2
-2
@@ -1,2 +1,2 @@
1
-export {default as wrapPageElement} from './src/components/wrap-page-element'
2
-export {default as wrapRootElement} from './src/components/wrap-root-element'
1
+export {default as wrapPageElement} from './src/wrap/page-element'
2
+export {default as wrapRootElement} from './src/wrap/root-element'
theme/gatsby-config.js
+66
-29
@@ -1,36 +1,73 @@
1
const path = require('path')
2
+const fs = require('fs')
3
+
4
+const {NODE_ENV, GATSBY_PARTIAL_CONTENT} = process.env
5
+const CONTENT_DIR = path.resolve(__dirname, '..', 'content')
6
+
7
+const walkDirs = dir => {
8
+ const dirs = fs
9
+ .readdirSync(dir)
10
+ .filter(d => fs.statSync(path.join(dir, d)).isDirectory())
11
+ .map(p => path.join(dir, p))
12
+ const nested = dirs.flatMap(d => walkDirs(d))
13
+ return [...dirs, ...nested]
14
+}
15
+
16
+const getContentOptions = () => {
17
+ if (NODE_ENV !== 'development' || !GATSBY_PARTIAL_CONTENT) {
18
+ return
19
+ }
20
+
21
+ const partialContent = (GATSBY_PARTIAL_CONTENT ?? '').split(',')
22
+
23
+ const paths = walkDirs(CONTENT_DIR)
24
+ .map(p => path.relative(CONTENT_DIR, p))
25
+ .sort()
26
+ .reduce(
27
+ (acc, p) => {
28
+ const include = partialContent.some(partial => partial.startsWith(p))
29
+ acc[include ? 'include' : 'ignore'].push(p)
30
+ return acc
31
+ },
32
+ {include: [], ignore: []},
33
+ )
34
+
35
+ console.log(`Only including the following partial content in dev mode:\n - ${paths.include.join('\n - ')}`)
36
3
-module.exports = themeOptions => {
37
return {
5
- plugins: [
6
- 'gatsby-plugin-styled-components',
7
- 'gatsby-plugin-react-helmet',
8
- 'gatsby-plugin-catch-links',
9
- 'gatsby-transformer-yaml',
10
- {
11
- resolve: 'gatsby-plugin-mdx',
12
- options: {
13
- extensions: ['.mdx', '.md'],
14
- defaultLayouts: {
15
- default: require.resolve('./src/components/layout.js'),
16
- },
38
+ ignore: paths.ignore,
39
+ }
40
+}
41
+
42
+module.exports = ({icon}) => ({
43
+ plugins: [
44
+ 'gatsby-plugin-styled-components',
45
+ 'gatsby-plugin-react-helmet',
46
+ 'gatsby-plugin-catch-links',
47
+ 'gatsby-transformer-yaml',
48
+ {
49
+ resolve: 'gatsby-plugin-mdx',
50
+ options: {
51
+ extensions: ['.mdx', '.md'],
52
+ defaultLayouts: {
53
+ default: require.resolve('./src/layout/index.js'),
54
},
55
},
19
- {
20
- resolve: 'gatsby-source-filesystem',
21
- options: {
22
- name: 'content',
23
- path: process.env.GATSBY_PARTIAL_CONTENT
24
- ? path.resolve(`./content/${process.env.GATSBY_PARTIAL_CONTENT}`)
25
- : path.resolve('./content'),
26
- },
56
+ },
57
+ {
58
+ resolve: 'gatsby-source-filesystem',
59
+ options: {
60
+ name: 'content',
61
+ path: CONTENT_DIR,
62
+ ...getContentOptions(),
63
},
28
- {
29
- resolve: 'gatsby-plugin-manifest',
30
- options: {
31
- icon: themeOptions.icon ? path.resolve(themeOptions.icon) : require.resolve('./src/images/favicon.png'),
32
- },
64
+ },
65
+ {
66
+ resolve: 'gatsby-plugin-manifest',
67
+ options: {
68
+ icon: path.resolve(icon),
69
},
34
- ],
35
- }
36
-}
70
+ },
71
+ 'gatsby-plugin-meta-redirect',
72
+ ],
73
+})
theme/gatsby-node.js
+43
-57
@@ -1,7 +1,4 @@
1
const path = require('path')
2
-const uniqBy = require('lodash.uniqby')
3
-
4
-const CONTRIBUTOR_CACHE = new Map()
2
3
exports.createSchemaCustomization = ({actions: {createTypes}}) => {
4
createTypes(`
@@ -23,8 +20,8 @@ exports.createSchemaCustomization = ({actions: {createTypes}}) => {
20
`)
21
}
22
26
-exports.createPages = async ({graphql, actions}, themeOptions) => {
27
- const repo = themeOptions.repo
23
+exports.createPages = async ({graphql, actions}, {repo, showContributors}) => {
24
+ const rootAbsolutePath = process.cwd()
25
26
const {data} = await graphql(`
27
{
@@ -59,20 +56,17 @@ exports.createPages = async ({graphql, actions}, themeOptions) => {
56
// Turn every MDX file into a page.
57
return Promise.all(
58
data.allMdx.nodes.map(async node => {
62
- const pagePath = getPath(node)
59
+ const {id, frontmatter, fileAbsolutePath, tableOfContents = {}} = node
60
64
- const rootAbsolutePath = path.resolve(process.cwd(), themeOptions.repoRootPath || '.')
65
-
66
- const fileRelativePath = path.relative(rootAbsolutePath, node.fileAbsolutePath)
67
-
68
- const editUrl = getEditUrl(repo, fileRelativePath, node.frontmatter)
61
+ const pagePath = getPath(node)
62
+ const relativePath = path.relative(rootAbsolutePath, fileAbsolutePath)
63
+ const editUrl = getEditUrl(repo, relativePath, frontmatter)
64
70
- const contributors =
71
- themeOptions.showContributors !== false ? await fetchContributors(repo, fileRelativePath, node.frontmatte) : []
65
+ const contributors = showContributors ? await fetchContributors(repo, relativePath, frontmatter) : []
66
67
// Fix some old CLI pages which have mismatched headings at the top level.
68
// All top level headings should be the same level.
75
- const tableOfContents = node.tableOfContents?.items?.reduce((acc, item) => {
69
+ const toc = tableOfContents.items?.reduce((acc, item) => {
70
if (!item.url && Array.isArray(item.items)) {
71
acc.push(...item.items)
72
} else {
@@ -83,34 +77,31 @@ exports.createPages = async ({graphql, actions}, themeOptions) => {
77
78
actions.createPage({
79
path: pagePath,
86
- component: node.fileAbsolutePath,
80
+ component: fileAbsolutePath,
81
context: {
88
- mdxId: node.id,
89
- themeOptions,
82
+ mdxId: id,
83
editUrl,
84
contributors,
92
- tableOfContents,
85
+ tableOfContents: toc,
86
repositoryUrl: repo.url,
87
},
88
})
89
97
- if (node.frontmatter.redirect_from) {
98
- for (const from of node.frontmatter.redirect_from) {
90
+ for (const from of frontmatter.redirect_from ?? []) {
91
+ actions.createRedirect({
92
+ fromPath: from,
93
+ toPath: `/${pagePath}`,
94
+ isPermanent: true,
95
+ redirectInBrowser: true,
96
+ })
97
+
98
+ if (pagePath.startsWith('cli/') && !from.endsWith('index')) {
99
actions.createRedirect({
100
- fromPath: from,
100
+ fromPath: `${from}.html`,
101
toPath: `/${pagePath}`,
102
isPermanent: true,
103
redirectInBrowser: true,
104
})
105
-
106
- if (pagePath.startsWith('cli/') && !from.endsWith('index')) {
107
- actions.createRedirect({
108
- fromPath: `${from}.html`,
109
- toPath: `/${pagePath}`,
110
- isPermanent: true,
111
- redirectInBrowser: true,
112
- })
113
- }
105
}
106
}
107
}),
@@ -134,19 +125,9 @@ function getPath(node) {
125
.replace(/\\/g, '/') // Windows paths to forward slashes
126
}
127
137
-function getNameWithOwner(url) {
138
- const nwo = url.match(/^http(?:s)?:\/\/(?:www\.)?github\.com\/([^/]+\/[^/]+)(?:\/)?$/i)
139
-
140
- if (nwo) {
141
- return nwo[1]
142
- }
143
-
144
- return null
145
-}
146
-
128
function getGitHubData(repo, overrideData, filePath) {
129
const gh = {
149
- nwo: getNameWithOwner(repo.url),
130
+ nwo: new URL(repo.url).pathname.slice(1).split('/'),
131
branch: 'master',
132
}
133
@@ -162,8 +143,6 @@ function getGitHubData(repo, overrideData, filePath) {
143
144
if (overrideData.github_path) {
145
gh.path = overrideData.github_path
165
- } else if (repo.path) {
166
- gh.path = `${repo.path}/${filePath}`
146
} else {
147
gh.path = filePath
148
}
@@ -180,6 +159,8 @@ function getEditUrl(repo, filePath, overrideData = {}) {
159
return `https://github.com/${gh.nwo}/edit/${gh.branch}/${gh.path}`
160
}
161
162
+const CONTRIBUTOR_CACHE = new Map()
163
+
164
async function fetchContributors(repo, filePath, overrideData = {}) {
165
if (!process.env.GITHUB_TOKEN) {
166
console.warn('Skipping fetching contributors because no github token was set')
@@ -187,8 +168,9 @@ async function fetchContributors(repo, filePath, overrideData = {}) {
168
}
169
170
const gh = getGitHubData(repo, overrideData, filePath)
171
+ const key = JSON.stringify(gh)
172
191
- const cached = CONTRIBUTOR_CACHE.get(gh)
173
+ const cached = CONTRIBUTOR_CACHE.get(key)
174
if (cached) {
175
return cached
176
}
@@ -203,20 +185,24 @@ async function fetchContributors(repo, filePath, overrideData = {}) {
185
},
186
)
187
206
- const {data} = await resp.json()
207
-
208
- const commits = data
209
- .map(commit => ({
210
- login: commit.author && commit.author.login,
211
- latestCommit: {
212
- date: commit.commit.author.date,
213
- url: commit.html_url,
214
- },
215
- }))
216
- .filter(contributor => Boolean(contributor.login))
188
+ const logins = new Set()
189
+ let latestCommit = null
190
+
191
+ for (const item of await resp.json().then(r => r.data)) {
192
+ if (item.author?.login) {
193
+ logins.add(item.author.login)
194
+ if (!latestCommit) {
195
+ latestCommit = {
196
+ login: item.author.login,
197
+ date: item.commit.author.date,
198
+ url: item.html_url,
199
+ }
200
+ }
201
+ }
202
+ }
203
218
- const result = uniqBy(commits, 'login')
219
- CONTRIBUTOR_CACHE.set(gh, result)
204
+ const result = {logins: [...logins], latestCommit}
205
+ CONTRIBUTOR_CACHE.set(key, result)
206
return result
207
} catch (error) {
208
console.error(`[ERROR] Unable to fetch contributors for ${filePath}. ${error.message}`)
theme/gatsby-ssr.js
+2
-2
@@ -1,2 +1,2 @@
1
-export {default as wrapPageElement} from './src/components/wrap-page-element'
2
-export {default as wrapRootElement} from './src/components/wrap-root-element'
1
+export {default as wrapPageElement} from './src/wrap/page-element'
2
+export {default as wrapRootElement} from './src/wrap/root-element'
theme/index.js
deleted
-15
@@ -1,15 +0,0 @@
1
-export {default as Caption} from './src/components/caption'
2
-export {default as Container} from './src/components/container'
3
-export {default as Contributors} from './src/components/contributors'
4
-export {Do, DoDontContainer, Dont} from './src/components/do-dont'
5
-export {default as Frame} from './src/components/frame'
6
-export {default as Head} from './src/components/head'
7
-export {default as Header} from './src/components/header'
8
-export {default as Hero} from './src/components/hero'
9
-export {default as HeroLayout} from './src/components/hero-layout'
10
-export {default as Index} from './src/components/index'
11
-export {default as Note} from './src/components/note'
12
-export {default as Screenshot} from './src/components/screenshot'
13
-export {default as Sidebar} from './src/components/sidebar'
14
-export {default as SourceLink} from './src/components/source-link'
15
-export {default as StatusLabel} from './src/components/status-label'
theme/package.json
+2
-8
@@ -32,8 +32,8 @@
32
"@primer/octicons-react": "^19.8.0",
33
"@primer/react": "^35.31.0",
34
"@styled-system/theme-get": "^5.1.2",
35
+ "babel-plugin-styled-components": "^2.1.4",
36
"copy-to-clipboard": "^3.3.3",
36
- "date-fns": "^2.30.0",
37
"details-element-polyfill": "^2.4.0",
38
"downshift": "^8.2.2",
39
"framer-motion": "^3.10.6",
@@ -41,23 +41,17 @@
41
"gatsby-plugin-catch-links": "^4.25.0",
42
"gatsby-plugin-manifest": "^4.25.0",
43
"gatsby-plugin-mdx": "^3.20.0",
44
+ "gatsby-plugin-meta-redirect": "^1.1.1",
45
"gatsby-plugin-react-helmet": "^5.25.0",
46
"gatsby-plugin-styled-components": "^5.25.0",
47
"gatsby-source-filesystem": "^4.25.0",
48
"gatsby-transformer-yaml": "^4.25.0",
49
"github-slugger": "^2.0.0",
49
- "html-react-parser": "^1.4.14",
50
"lodash.debounce": "4.0.8",
51
- "lodash.uniqby": "^4.7.0",
52
- "pluralize": "^8.0.0",
51
"prism-react-renderer": "^0.2.0",
52
"react-addons-text-content": "^0.0.4",
55
- "react-element-to-jsx-string": "^14.3.4",
53
"react-focus-on": "^3.9.1",
57
- "react-frame-component": "^4.1.3",
54
"react-helmet": "^6.1.0",
59
- "react-live": "^2.4.1",
60
- "react-measure": "^2.5.2",
55
"styled-components": "^5.3.11",
56
"styled-system": "^5.1.5"
57
},
theme/src/components/__tests__/contributors.test.js
+7
-40
@@ -5,22 +5,14 @@ import Contributors from '../contributors'
5
test('renders contributors', () => {
6
const {queryByText} = render(
7
<Contributors
8
- contributors={[
9
- {
8
+ contributors={{
9
+ logins: ['colebemis', 'emplums'],
10
+ latestCommit: {
11
login: 'colebemis',
11
- latestCommit: {
12
- url: '#',
13
- date: '2019-08-15T23:40:19Z',
14
- },
12
+ url: '#',
13
+ date: '2019-08-15T23:40:19Z',
14
},
16
- {
17
- login: 'emplums',
18
- latestCommit: {
19
- url: '#',
20
- date: '2019-08-14T00:19:54Z',
21
- },
22
- },
23
- ]}
15
+ }}
16
/>,
17
)
18
@@ -31,7 +23,7 @@ test('renders contributors', () => {
23
})
24
25
test('does not render "last edited by" if latest contributor does not have a latest commit', () => {
34
- const {queryByText} = render(<Contributors contributors={[{login: 'ashygee'}]} />)
26
+ const {queryByText} = render(<Contributors contributors={{logins: ['ashygee']}} />)
27
28
expect(queryByText(/1 contributor/)).toBeInTheDocument()
29
expect(queryByText(/Last edited by/)).toBeNull()
@@ -44,28 +36,3 @@ test('handles no contributors', () => {
36
37
expect(queryByText(/0 contributors/)).toBeInTheDocument()
38
})
47
-
48
-test('does not render duplicate contributors', () => {
49
- const {queryByText} = render(
50
- <Contributors
51
- contributors={[
52
- {
53
- login: 'colebemis',
54
- latestCommit: {
55
- url: '#',
56
- date: '2019-08-15T23:40:19Z',
57
- },
58
- },
59
- {
60
- login: 'colebemis',
61
- latestCommit: {
62
- url: '#',
63
- date: '2019-08-14T00:19:54Z',
64
- },
65
- },
66
- ]}
67
- />,
68
- )
69
-
70
- expect(queryByText(/1 contributor/)).toBeInTheDocument()
71
-})
theme/src/components/caption.js
deleted
-8
@@ -1,8 +0,0 @@
1
-import {Text} from '@primer/components'
2
-import React from 'react'
3
-
4
-function Caption(props) {
5
- return <Text as="p" mt={2} mb={3} fontSize={1} color="gray.5" {...props} />
6
-}
7
-
8
-export default Caption
theme/src/components/clipboard-copy.js
+1
-1
@@ -3,7 +3,7 @@ import {CheckIcon, CopyIcon} from '@primer/octicons-react'
3
import styled from 'styled-components'
4
import copy from 'copy-to-clipboard'
5
import React from 'react'
6
-import {announce} from '../aria-live'
6
+import {announce} from '../util/aria-live'
7
8
const CopyToClipboard = styled(Button)`
9
&:focus {
theme/src/components/code.js
+1
-6
@@ -3,7 +3,6 @@ import Highlight, {defaultProps} from 'prism-react-renderer'
3
import githubTheme from 'prism-react-renderer/themes/github'
4
import React, {useState, useEffect} from 'react'
5
import ClipboardCopy from './clipboard-copy'
6
-import LiveCode from './live-code'
6
7
/**
8
* Resize the scroll handle to the size of the code contents, since the former has to be positioned absolutely.
@@ -39,15 +38,11 @@ const useScrollSize = () => {
38
return {scrollRef, paddingRef, size}
39
}
40
42
-function Code({className, children, live, noinline}) {
41
+function Code({className, children}) {
42
const language = className ? className.replace(/language-/, '') : ''
43
const code = children.trim()
44
const {scrollRef, paddingRef, size} = useScrollSize()
45
47
- if (live) {
48
- return <LiveCode code={code} language={language} noinline={noinline} />
49
- }
50
-
46
return (
47
<Relative>
48
<div ref={paddingRef}>
theme/src/components/contributors.js
+26
-23
@@ -1,42 +1,45 @@
1
import {Avatar, Flex, Link, Text, Tooltip} from '@primer/components'
2
-import {format} from 'date-fns'
3
-import uniqBy from 'lodash.uniqby'
4
-import pluralize from 'pluralize'
2
import React from 'react'
3
7
-// The `contributors` array is fetched in gatsby-node.js at build-time.
4
+const pluralize = (word, count) => `${word}${count === 1 ? '' : 's'}`
5
9
-function Contributors({contributors}) {
10
- const uniqueContributors = uniqBy(contributors, 'login')
11
- const latestContributor = uniqueContributors[0] || {}
6
+const months = [
7
+ 'January',
8
+ 'February',
9
+ 'March',
10
+ 'April',
11
+ 'May',
12
+ 'June',
13
+ 'July',
14
+ 'August',
15
+ 'September',
16
+ 'October',
17
+ 'November',
18
+ 'December',
19
+]
20
+const format = d => `${months[d.getMonth()]} ${d.getDate()}, ${d.getFullYear()}`
21
22
+function Contributors({contributors}) {
23
+ const {logins = [], latestCommit} = contributors
24
return (
25
<div>
26
<Flex alignItems="center">
27
<Text mr={2}>
17
- {uniqueContributors.length} {pluralize('contributor', uniqueContributors.length)}
28
+ {logins.length} {pluralize('contributor', logins.length)}
29
</Text>
19
- {uniqueContributors.map(contributor => (
20
- <Link
21
- key={contributor.login}
22
- href={`https://github.com/${contributor.login}`}
23
- lineHeight="condensedUltra"
24
- mr={2}
25
- >
26
- <Tooltip key={contributor.login} aria-label={contributor.login}>
27
- <Avatar src={`https://github.com/${contributor.login}.png?size=40`} alt={contributor.login} />
30
+ {logins.map(login => (
31
+ <Link key={login} href={`https://github.com/${login}`} lineHeight="condensedUltra" mr={2}>
32
+ <Tooltip key={login} aria-label={login}>
33
+ <Avatar src={`https://github.com/${login}.png?size=40`} alt={login} />
34
</Tooltip>
35
</Link>
36
))}
37
</Flex>
38
33
- {latestContributor.latestCommit ? (
39
+ {latestCommit ? (
40
<Text fontSize={1} color="gray.7" mt={1}>
35
- Last edited by <Link href={`https://github.com/${latestContributor.login}`}>{latestContributor.login}</Link>{' '}
36
- on{' '}
37
- <Link href={latestContributor.latestCommit.url}>
38
- {format(new Date(latestContributor.latestCommit.date), 'MMMM d, y')}
39
- </Link>
41
+ Last edited by <Link href={`https://github.com/${latestCommit.login}`}>{latestCommit.login}</Link> on{' '}
42
+ <Link href={latestCommit.url}>{format(new Date(latestCommit.date))}</Link>
43
</Text>
44
) : null}
45
</div>
theme/src/components/do-dont.js
deleted
-45
@@ -1,45 +0,0 @@
1
-import {Flex, Grid, Text, StyledOcticon} from '@primer/components'
2
-import {CheckIcon, XIcon} from '@primer/octicons-react'
3
-import React from 'react'
4
-import Caption from './caption'
5
-
6
-export function DoDontContainer({stacked, children}) {
7
- return (
8
- <Grid gridTemplateColumns={['1fr', null, stacked ? '1fr' : '1fr 1fr']} gridGap={3} mb={3}>
9
- {children}
10
- </Grid>
11
- )
12
-}
13
-
14
-DoDontContainer.defaultProps = {
15
- stacked: false,
16
-}
17
-
18
-export function Do(props) {
19
- return <DoDontBase {...props} text="Do" icon={CheckIcon} iconBg="green.5" />
20
-}
21
-
22
-export function Dont(props) {
23
- return <DoDontBase {...props} text="Don't" icon={XIcon} iconBg="red.5" />
24
-}
25
-
26
-function DoDontBase({src, alt, children, text, icon: Icon, iconBg}) {
27
- return (
28
- <Flex flexDirection="column">
29
- <Flex alignSelf="start" flexDirection="row" alignItems="center" mb="2">
30
- <Flex bg={iconBg} color="white" p={1} style={{borderRadius: '50%'}}>
31
- <StyledOcticon icon={Icon} verticalAlign="middle" size={12} />
32
- </Flex>
33
- <Text fontWeight="bold" color="gray.9" ml={2}>
34
- {text}
35
- </Text>
36
- </Flex>
37
- <img src={src} alt={alt} width="100%" />
38
- <Caption mb={0}>{children}</Caption>
39
- </Flex>
40
- )
41
-}
42
-
43
-DoDontBase.defaultProps = {
44
- alt: '',
45
-}
theme/src/components/frame.js
deleted
-35
@@ -1,35 +0,0 @@
1
-import React from 'react'
2
-import FrameComponent, {FrameContextConsumer} from 'react-frame-component'
3
-import {StyleSheetManager} from 'styled-components'
4
-import Measure from 'react-measure'
5
-
6
-function Frame({children}) {
7
- const [height, setHeight] = React.useState('auto')
8
- return (
9
- <FrameComponent style={{width: '100%', border: 0, height}}>
10
- <FrameContextConsumer>
11
- {({document}) => {
12
- // By default, styled-components injects styles in the head of the page.
13
- // However, styles from the page's head don't apply inside iframes.
14
- // We're using StyleSheetManager to make styled-components inject styles
15
- // into the head of the iframe instead.
16
- return (
17
- <StyleSheetManager target={document.head}>
18
- <Measure
19
- // iframes don't adjust to the height of their content by default.
20
- // We're using Measure to calculate the size of the content
21
- // and adjust the iframe's height dynamically.
22
- bounds={true}
23
- onResize={rect => setHeight(rect.bounds.height)}
24
- >
25
- {({measureRef}) => <div ref={measureRef}>{children}</div>}
26
- </Measure>
27
- </StyleSheetManager>
28
- )
29
- }}
30
- </FrameContextConsumer>
31
- </FrameComponent>
32
- )
33
-}
34
-
35
-export default Frame
theme/src/components/head.js
+1
-1
@@ -1,6 +1,6 @@
1
import React from 'react'
2
import {Helmet} from 'react-helmet'
3
-import useSiteMetdata from '../use-site-metadata'
3
+import useSiteMetdata from '../hooks/use-site-metadata'
4
5
function Head(props) {
6
const siteMetadata = useSiteMetdata()
theme/src/components/header.js
+7
-9
@@ -3,12 +3,12 @@ import {Link as GatsbyLink} from 'gatsby'
3
import React from 'react'
4
import styled from 'styled-components'
5
import headerNavItems from '../header-nav.yml'
6
-import useSiteMetadata from '../use-site-metadata'
6
+import useSiteMetadata from '../hooks/use-site-metadata'
7
import MobileSearch from './mobile-search'
8
import NavDrawer from './nav-drawer'
9
import Search from './search'
10
import NpmLogo from './npm-logo'
11
-import useSearch from '../use-search'
11
+import useSearch from '../hooks/use-search'
12
13
export const HEADER_HEIGHT = 66
14
@@ -17,7 +17,7 @@ const NpmHeaderBar = styled(Box)`
17
background-image: linear-gradient(139deg, #fb8817, #ff4b01, #c12127, #e02aff);
18
`
19
20
-function Header({location, repositoryUrl, isSearchEnabled = true}) {
20
+function Header({location, repositoryUrl}) {
21
const siteMetadata = useSiteMetadata()
22
const search = useSearch()
23
@@ -39,18 +39,16 @@ function Header({location, repositoryUrl, isSearchEnabled = true}) {
39
<NpmLogo size="32" style={logoStyle} />
40
{siteMetadata.title}
41
</Link>
42
- {isSearchEnabled ? (
43
- <Box display={['none', null, null, 'block']} ml={4}>
44
- <Search {...search} />
45
- </Box>
46
- ) : null}
42
+ <Box display={['none', null, null, 'block']} ml={4}>
43
+ <Search {...search} />
44
+ </Box>
45
</Flex>
46
<Flex>
47
<Box display={['none', null, null, 'block']}>
48
<HeaderNavItems items={headerNavItems} />
49
</Box>
50
<Flex display={['flex', null, null, 'none']}>
53
- {isSearchEnabled ? <MobileSearch {...search} /> : null}
51
+ <MobileSearch {...search} />
52
<NavDrawer location={location} repositoryUrl={repositoryUrl} />
53
</Flex>
54
</Flex>
theme/src/components/heading.js
+1
-1
@@ -5,7 +5,7 @@ import React from 'react'
5
import textContent from 'react-addons-text-content'
6
import styled from 'styled-components'
7
import {HEADER_HEIGHT} from './header'
8
-import {useSlugger} from '../use-slugger'
8
+import {useSlugger} from '../hooks/use-slugger'
9
10
const StyledHeading = styled(Heading)`
11
margin-top: ${themeGet('space.4')};
theme/src/components/hero-layout.js
deleted
-43
@@ -1,43 +0,0 @@
1
-import {Box, Flex} from '@primer/components'
2
-import React from 'react'
3
-import Container from './container'
4
-import PageFooter from './page-footer'
5
-import Head from './head'
6
-import Header from './header'
7
-import Hero from './hero'
8
-import Sidebar from './sidebar'
9
-import * as Slugger from '../use-slugger'
10
-
11
-function HeroLayout({children, pageContext, location}) {
12
- const {additionalContributors = []} = pageContext.frontmatter
13
-
14
- return (
15
- <Slugger.Provider>
16
- <Flex flexDirection="column" minHeight="100vh">
17
- <Head />
18
- <Header
19
- location={location}
20
- repositoryUrl={pageContext.repositoryUrl}
21
- isSearchEnabled={pageContext.isSearchEnabled}
22
- />
23
- <Flex flex="1 1 auto" flexDirection="row" role="main">
24
- <Box display={['none', null, null, 'block']}>
25
- <Sidebar repositoryUrl={pageContext.repositoryUrl} location={location} />
26
- </Box>
27
- <Box width="100%">
28
- <Hero />
29
- <Container>
30
- {children}
31
- <PageFooter
32
- editUrl={pageContext.themeOptions.editUrl}
33
- contributors={pageContext.contributors.concat(additionalContributors.map(login => ({login})))}
34
- />
35
- </Container>
36
- </Box>
37
- </Flex>
38
- </Flex>
39
- </Slugger.Provider>
40
- )
41
-}
42
-
43
-export default HeroLayout
theme/src/components/hero.js
+1
-1
@@ -1,6 +1,6 @@
1
import {Box, Heading, Text} from '@primer/components'
2
import React from 'react'
3
-import useSiteMetadata from '../use-site-metadata'
3
+import useSiteMetadata from '../hooks/use-site-metadata'
4
import Container from './container'
5
6
function Hero() {
theme/src/components/index.js
+1
-1
@@ -3,7 +3,7 @@ import React from 'react'
3
import {Location} from '@reach/router'
4
import {Box, Link} from '@primer/components'
5
import {Link as GatsbyLink} from 'gatsby'
6
-import NavHierarchy from '../nav-hierarchy'
6
+import NavHierarchy from '../util/nav-hierarchy'
7
8
function showHierarchy(items, props, depth = 1) {
9
let hierarchy
theme/src/components/live-code.js
deleted
-71
@@ -1,71 +0,0 @@
1
-import {Absolute, BorderBox, Relative, Text} from '@primer/components'
2
-import htmlReactParser from 'html-react-parser'
3
-import githubTheme from 'prism-react-renderer/themes/github'
4
-import React, {useState} from 'react'
5
-import reactElementToJsxString from 'react-element-to-jsx-string'
6
-import {LiveEditor, LiveError, LivePreview, LiveProvider} from 'react-live'
7
-import {ThemeContext} from 'styled-components'
8
-import scope from '../live-code-scope'
9
-import ClipboardCopy from './clipboard-copy'
10
-import LivePreviewWrapper from './live-preview-wrapper'
11
-
12
-const languageTransformers = {
13
- html: html => htmlToJsx(html),
14
- jsx: jsx => wrapWithFragment(jsx),
15
-}
16
-
17
-function htmlToJsx(html) {
18
- try {
19
- const reactElement = htmlReactParser(removeNewlines(html))
20
- // The output of htmlReactParser could be a single React element
21
- // or an array of React elements. reactElementToJsxString does not accept arrays
22
- // so we have to wrap the output in React fragment.
23
- return reactElementToJsxString(<>{reactElement}</>)
24
- } catch (error) {
25
- return wrapWithFragment(html)
26
- }
27
-}
28
-
29
-function removeNewlines(string) {
30
- return string.replace(/(\r\n|\n|\r)/gm, '')
31
-}
32
-
33
-function wrapWithFragment(jsx) {
34
- return `<React.Fragment>${jsx}</React.Fragment>`
35
-}
36
-
37
-function LiveCode({code, language, noinline}) {
38
- const theme = React.useContext(ThemeContext)
39
- const [liveCode, setLiveCode] = useState(code)
40
- const handleChange = updatedLiveCode => setLiveCode(updatedLiveCode)
41
-
42
- return (
43
- <BorderBox flexDirection="column" mb={3}>
44
- <LiveProvider scope={scope} code={liveCode} transformCode={languageTransformers[language]} noInline={noinline}>
45
- <LivePreviewWrapper>
46
- <LivePreview />
47
- </LivePreviewWrapper>
48
- <Relative>
49
- <LiveEditor
50
- onChange={handleChange}
51
- theme={githubTheme}
52
- ignoreTabKey={true}
53
- padding={theme.space[3]}
54
- style={{
55
- fontFamily: theme.fonts.mono,
56
- fontSize: '85%',
57
- borderBottomLeftRadius: theme.radii[2],
58
- borderBottomRightRadius: theme.radii[2],
59
- }}
60
- />
61
- <Absolute top={0} right={0} p={2}>
62
- <ClipboardCopy value={liveCode} />
63
- </Absolute>
64
- </Relative>
65
- <Text as={LiveError} m={0} p={3} fontFamily="mono" fontSize={1} color="white" bg="red.5" />
66
- </LiveProvider>
67
- </BorderBox>
68
- )
69
-}
70
-
71
-export default LiveCode
theme/src/components/live-preview-wrapper.js
deleted
-17
@@ -1,17 +0,0 @@
1
-import {BaseStyles, Box} from '@primer/components'
2
-import Frame from './frame'
3
-import React from 'react'
4
-
5
-// Users can shadow this file to wrap live previews.
6
-// This is useful for applying global styles.
7
-function LivePreviewWrapper({children}) {
8
- return (
9
- <Frame>
10
- <BaseStyles>
11
- <Box p={3}>{children}</Box>
12
- </BaseStyles>
13
- </Frame>
14
- )
15
-}
16
-
17
-export default LivePreviewWrapper
theme/src/components/mobile-search.js
+1
-1
@@ -6,7 +6,7 @@ import {FocusOn} from 'react-focus-on'
6
import DarkButton from './dark-button'
7
import DarkTextInput from './dark-text-input'
8
import SearchResults from './search-results'
9
-import useSiteMetadata from '../use-site-metadata'
9
+import useSiteMetadata from '../hooks/use-site-metadata'
10
11
function MobileSearch({onDismiss, ...props}) {
12
const siteMetadata = useSiteMetadata()
theme/src/components/nav-drawer.js
+2
-2
@@ -4,11 +4,11 @@ import {Link as GatsbyLink} from 'gatsby'
4
import React from 'react'
5
import navItems from '../nav.yml'
6
import headerNavItems from '../header-nav.yml'
7
-import useSiteMetadata from '../use-site-metadata'
7
+import useSiteMetadata from '../hooks/use-site-metadata'
8
import DarkButton from './dark-button'
9
import Drawer from './drawer'
10
import NavItems from './nav-items'
11
-import {useIsMobile} from '../use-breakpoint'
11
+import {useIsMobile} from '../hooks/use-breakpoint'
12
13
const useDrawerIsOpen = () => {
14
const isMobile = useIsMobile()
theme/src/components/nav-items.js
+1
-1
@@ -3,7 +3,7 @@ import {LinkExternalIcon} from '@primer/octicons-react'
3
import {Link as GatsbyLink} from 'gatsby'
4
import React from 'react'
5
import styled from 'styled-components'
6
-import NavHierarchy from '../nav-hierarchy'
6
+import NavHierarchy from '../util/nav-hierarchy'
7
8
const getActiveProps = className => props => {
9
const location = NavHierarchy.getLocation(props.location.pathname)
theme/src/components/page-footer.js
+1
-1
@@ -14,7 +14,7 @@ function PageFooter({editUrl, contributors}) {
14
</Link>
15
) : null}
16
17
- {contributors.length > 0 ? <Contributors contributors={contributors} /> : null}
17
+ {contributors.length ? <Contributors contributors={contributors} /> : null}
18
</Grid>
19
</BorderBox>
20
) : null
theme/src/components/search-results.js
+2
-2
@@ -1,7 +1,7 @@
1
import {Flex, Text} from '@primer/components'
2
import React from 'react'
3
-import useSiteMetadata from '../use-site-metadata'
4
-import NavHierarchy from '../nav-hierarchy'
3
+import useSiteMetadata from '../hooks/use-site-metadata'
4
+import NavHierarchy from '../util/nav-hierarchy'
5
6
function SearchResults({results, getItemProps, highlightedIndex}) {
7
const siteMetadata = useSiteMetadata()
theme/src/components/search.js
+1
-1
@@ -1,6 +1,6 @@
1
import {BorderBox, Position} from '@primer/components'
2
import React from 'react'
3
-import useSiteMetadata from '../use-site-metadata'
3
+import useSiteMetadata from '../hooks/use-site-metadata'
4
import DarkTextInput from './dark-text-input'
5
import SearchResults from './search-results'
6
theme/src/components/variant-select.js
+1
-1
@@ -6,7 +6,7 @@
6
7
import React from 'react'
8
import {ActionList, ActionMenu, ThemeProvider} from '@primer/react'
9
-import NavHierarchy from '../nav-hierarchy'
9
+import NavHierarchy from '../util/nav-hierarchy'
10
11
function VariantSelect(props) {
12
const [open, setOpen] = React.useState(false)
theme/src/header-nav.yml
+2
-2
@@ -1,2 +1,2 @@
1
-- title: npmjs.com
2
- url: https://www.npmjs.com/
1
+# For shadowing only
2
+[]
theme/src/hooks/use-breakpoint.js
renamed
theme/src/hooks/use-search.js
renamed
+1
-1
@@ -59,7 +59,7 @@ function useSearch() {
59
}, [])
60
61
React.useEffect(() => {
62
- const worker = new Worker(new URL('./search.worker.js', import.meta.url))
62
+ const worker = new Worker(new URL('../util/search.worker.js', import.meta.url))
63
workerRef.current = worker
64
65
worker.addEventListener('message', handleSearchResults)
theme/src/hooks/use-site-metadata.js
renamed
theme/src/hooks/use-slugger.js
renamed
theme/src/images/favicon.png
Binary files a/theme/src/images/favicon.png and /dev/null differ
theme/src/layout/hero.js
new
+30
@@ -0,0 +1,30 @@
1
+import {Box, Flex} from '@primer/components'
2
+import React from 'react'
3
+import Container from '../components/container'
4
+import Head from '../components/head'
5
+import Header from '../components/header'
6
+import Hero from '../components/hero'
7
+import Sidebar from '../components/sidebar'
8
+import * as Slugger from '../hooks/use-slugger'
9
+
10
+function HeroLayout({children, pageContext, location}) {
11
+ return (
12
+ <Slugger.Provider>
13
+ <Flex flexDirection="column" minHeight="100vh">
14
+ <Head />
15
+ <Header location={location} repositoryUrl={pageContext.repositoryUrl} />
16
+ <Flex flex="1 1 auto" flexDirection="row" role="main">
17
+ <Box display={['none', null, null, 'block']}>
18
+ <Sidebar repositoryUrl={pageContext.repositoryUrl} location={location} />
19
+ </Box>
20
+ <Box width="100%">
21
+ <Hero />
22
+ <Container>{children}</Container>
23
+ </Box>
24
+ </Flex>
25
+ </Flex>
26
+ </Slugger.Provider>
27
+ )
28
+}
29
+
30
+export default HeroLayout
theme/src/layout/index.js
renamed
+14
-21
@@ -1,20 +1,20 @@
1
import {BorderBox, Box, Flex, Grid, Heading, Position, StyledOcticon, Text} from '@primer/components'
2
import {ChevronDownIcon, ChevronRightIcon} from '@primer/octicons-react'
3
import React from 'react'
4
-import Head from './head'
5
-import Header, {HEADER_HEIGHT} from './header'
6
-import PageFooter from './page-footer'
7
-import Sidebar from './sidebar'
8
-import SourceLink from './source-link'
9
-import StatusLabel from './status-label'
10
-import TableOfContents from './table-of-contents'
11
-import VariantSelect from './variant-select'
12
-import NavHierarchy from '../nav-hierarchy'
13
-import Details from './details'
14
-import * as Slugger from '../use-slugger'
4
+import Head from '../components/head'
5
+import Header, {HEADER_HEIGHT} from '../components/header'
6
+import PageFooter from '../components/page-footer'
7
+import Sidebar from '../components/sidebar'
8
+import SourceLink from '../components/source-link'
9
+import StatusLabel from '../components/status-label'
10
+import TableOfContents from '../components/table-of-contents'
11
+import VariantSelect from '../components/variant-select'
12
+import NavHierarchy from '../util/nav-hierarchy'
13
+import Details from '../components/details'
14
+import * as Slugger from '../hooks/use-slugger'
15
16
function Layout({children, pageContext, location}) {
17
- const {title, description, status, source, additionalContributors = []} = pageContext.frontmatter
17
+ const {title, description, status, source} = pageContext.frontmatter
18
19
const variantRoot = NavHierarchy.getVariantRoot(location.pathname)
20
@@ -22,11 +22,7 @@ function Layout({children, pageContext, location}) {
22
<Slugger.Provider>
23
<Flex flexDirection="column" minHeight="100vh">
24
<Head title={title} description={description} />
25
- <Header
26
- repositoryUrl={pageContext.repositoryUrl}
27
- location={location}
28
- isSearchEnabled={pageContext.isSearchEnabled}
29
- />
25
+ <Header repositoryUrl={pageContext.repositoryUrl} location={location} />
26
<Flex flex="1 1 auto" flexDirection="row" css={{zIndex: 0}} role="main">
27
<Box display={['none', null, null, 'block']}>
28
<Sidebar repositoryUrl={pageContext.repositoryUrl} location={location} />
@@ -112,10 +108,7 @@ function Layout({children, pageContext, location}) {
108
</Box>
109
) : null}
110
{children}
115
- <PageFooter
116
- editUrl={pageContext.editUrl}
117
- contributors={pageContext.contributors.concat(additionalContributors.map(login => ({login})))}
118
- />
111
+ <PageFooter editUrl={pageContext.editUrl} contributors={pageContext.contributors} />
112
</Box>
113
</Grid>
114
</Flex>
theme/src/live-code-scope.js
deleted
-3
@@ -1,3 +0,0 @@
1
-// Users can shadow this file to define the scope of live code examples.
2
-// See https://primer.style/doctocat/usage/live-code for more details
3
-export default {}
theme/src/nav.yml
+1
-2
@@ -1,3 +1,2 @@
1
-# Users can shadow this file to define navigation items.
2
-# See https://primer.style/doctocat/usage/customization/#side-navigation for more details.
1
+# For shadowing only
2
[]
theme/src/util/aria-live.js
renamed
theme/src/util/nav-hierarchy.js
renamed
+1
-1
@@ -1,5 +1,5 @@
1
-import navItems from './nav.yml'
1
import {withPrefix} from 'gatsby'
2
+import navItems from '../nav.yml'
3
4
export default {
5
getLocation(path) {
theme/src/util/search.worker.js
renamed
theme/src/wrap/page-element.js
renamed
+1
-1
@@ -1,6 +1,6 @@
1
import {BaseStyles} from '@primer/components'
2
import React from 'react'
3
-import SkipLink from './skip-link'
3
+import SkipLink from '../components/skip-link'
4
import {createGlobalStyle} from 'styled-components'
5
6
const GlobalStyle = createGlobalStyle`
theme/src/wrap/root-element.js
renamed
+16
-15
@@ -3,21 +3,21 @@ import {Link, theme} from '@primer/components'
3
import {SSRProvider} from '@primer/react'
4
import React from 'react'
5
import {ThemeProvider} from 'styled-components'
6
-import Blockquote from './blockquote'
7
-import Code from './code'
8
-import DescriptionList from './description-list'
9
-import {H1, H2, H3, H4, H5, H6} from './heading'
10
-import HorizontalRule from './horizontal-rule'
11
-import Image from './image'
12
-import InlineCode from './inline-code'
13
-import List from './list'
14
-import Paragraph from './paragraph'
15
-import Table from './table'
16
-import Index from './index'
17
-import Note from './note'
18
-import Prompt from './prompt'
19
-import PromptReply from './prompt-reply'
20
-import Screenshot from './screenshot'
6
+import Blockquote from '../components/blockquote'
7
+import Code from '../components/code'
8
+import DescriptionList from '../components/description-list'
9
+import {H1, H2, H3, H4, H5, H6} from '../components/heading'
10
+import HorizontalRule from '../components/horizontal-rule'
11
+import Image from '../components/image'
12
+import InlineCode from '../components/inline-code'
13
+import List from '../components/list'
14
+import Paragraph from '../components/paragraph'
15
+import Table from '../components/table'
16
+import Index from '../components/index'
17
+import Note from '../components/note'
18
+import Prompt from '../components/prompt'
19
+import PromptReply from '../components/prompt-reply'
20
+import Screenshot from '../components/screenshot'
21
22
const components = {
23
a: Link,
@@ -43,6 +43,7 @@ const components = {
43
Prompt,
44
PromptReply,
45
Screenshot,
46
+ Link,
47
}
48
49
function wrapRootElement({element}) {