Skip to content

Commit ec1ebcc

Browse files
ovflowdshudingshanpriyanbmuenzenmeyermikeesto
authored
feat(infra): migrate to next.js infrastructure (nodejs#4991)Co-authored-by: Brian Muenzenmeyer <[email protected]> Co-authored-by: Shanmughapriyan S <[email protected]> Co-authored-by: Michael Esteban <[email protected]> Co-authored-by: Shu Ding <[email protected]>
* chore(next.js): added initial package.json update and configuration files * chore(static): moved static files to public/static * chore(pages): moved locale directory to pages/ * chore(survey): added readme and updated deploy script for survey * chore(legacy): removed build.js and server.js * chore(typescript): updated theme.tsx and added typescript support * chore(folder-structure): continued moving files and clean up of things * chore(codeowners): updated codeowners * chore(eslint): updated markdown matching * chore(move): moved styles and layout and data folders * chore(i18n): added initial locale config * chore(lts): stick with v18 lts * chore(i18n): updated crowdin configuration * chore(lts): fixed lts naming on ci and nvm * chore(package.json): fixed lint commands * chore(package-lock): reindexed and updated package lock * chore(i18n): added react-intl package * chore(configs): updated next, eslint and tsconfig * chore(packages): add prettier config for the plugin * chore(configs): updated prettier, eslint adn package.json * chore(package): removed airbnb config * chore(lint): applied linting in core files * chore(lint): applied linting on markdown and style files * chore(ci): disable build job for now * chore(cache): added eslint cache files to ignore * chore(public): moved robots and security to root public folder * chore(eslint): added default next config * chore(remark): added remark configuration * chore(i18n): added ICU locale files boilerplates * chore(config): added website config file * chore(favicon): removed all favicon alternates to a simple png file * chore(dependencies): added a rss/atom/json feed package * chore(packages): updated packages and adopted npm-run-all * chore(layouts): removed blm specific layouts * feast(config): introduced site config provider and context * feat(header): started to create the header component * chore(provider): refactored provider * chore(fonts): added source sans pro font * feat(templates): added core component * chore(pages): removed legacy blm page * feat(types): introduced frontmatter types * chore(theme): started to update theme with layout * feat(config): updated site config types * feat(header): added all header meta tags * chore(document): added assets for theme switch * chore(eslint): fixed eslint failed rule * update nextra * chore(document): added remaining scripts * feat(footer): added footer * feat(header): updated header with favicon * feat(manifest): added manifest for PWA * feat(i18n): introduced i18n hook * chore(header): added i18n config * feat(layouts): added default layout * feat(layouts): initial version of the layout provider * refactor(provider): cleaned-up the site provider * feat(theme): adopted layout provider on theme * chore(layouts): removed unused layouts * feat(footer): added scroll-to-top * chore(i18n): added navigation and translations * chore(dependencies): added highlightjs and classnames * chore(utils): added link locale util * feat(i18n): introduced locale provider * feat(header): renamed header into htmlhead * feat(header): introduced page header * feat(components): introduced localised linkicomponent * feat(components): introduced language picker component * chore(footer): updated translation id * feat(app): updated app, document and theme with new locale and scripts * chore(layouts): added header to default layout * chore(layouts): removed old header layout * chore(docs): made the docs index mdx compatible * chore(types): added labels to frontmatter * chore(config): updated next config and remark plugins * chore(types): added types for node-version-data * feat(i18n): hook to support metadata about current route * feat(navigation): updated navigation metadata * feat(navigation): introduced a navigation hook * feat(node-versions): introduced provider and types for node-versions * feat(navigation): introduced side navigation component * feat(header): use the new navigation component * chore(app): introduced node data provider usage * feat(docs): introduced doc layout * chore(layouts): added docs to layout provider * chore(layouts/scripts): removed now unused layouts and scripts * chore(scripts): removed build scripts for node data * chore(utils): introduced new util * chore(data): removed non-needed data anymore * chore(navigation): include root entry on side nav * fix(footer): fixed spacing of items * fix(body): next element to also follow body rules * feat(layouts): introduced new layouts * chore(note): added todo notes on temporary components * feat(mdx): added proper node api versions component * chore(dependencies): removed non-needed dependencies * chore(docs): reverted mdx rename and use regular mdx provider for the component import * chore(remark): a lot of the lists are unordered and shouldn't need to be with * * chore(layouts): removed unused knowledge layouts * feat(banner): introduced banner component * feat(nextra): allow plain md syntax; include i18n file in ssg * feat(next): introduced lambdas for getting data * chore(eslint): added mjs to es6 context * feat(next): adopted new data fetching mechanism * feat(providers): updated providers with new data fetching * chore(types): simplified provider types * chore(i18n): added lts span * chore(next): improve next configuration * feat(header): allow subpath match for sidenav * chore(dependencies): added critters and sharp for css/image optimization * feat(caching): introduced caching of static async props * fix(header): home location sublink * chore(hooks): removed .tsx extension * chore(scripts): removed unused scripts * feat(utils): added util for changelog link * feat(providers): provide nextra context * chore(types): added numeric version * feat(hooks): nextra context hook * feat(components): download button component * feat(layouts): introduced index layout * feat(date): added format time util * chore(scripts): removed more unused scripts * disable flexsearch for now * chore(next): increase memory pool for build * feat(data): updated hooks and how data is provided * chore(components): moved a few components around * chore(404): added dev 404 page * chore(i18n): added navigation and i18n for downloads * feat(download): introduced download components * feat(pages): introduced download pages * feat(navigation): offer replacement of vars in link * chore(scripts): updated a few scripts * chore(scripts): removed other deprecated script * chore(handlebars): added handlebars * feat(release-post): contained release posts within the scripts folder * chore(external): no need to have a package.json there anymore * chore(release-post): minor typo fix * chore(dependencies): added sw dependency * chore(sw): enable sw feature * chore(types): updated node data types * feat(components): introduced download table component * chore(layouts): introduced previous releases layout * chore(scripts): added jquery as script * refactor(components): use Link component * chore(downloads): use dompurify for the frontmatter modules * fix(links): fix api docs links * fix(locale): fixed determination of route match * chore(deps): updated dependencies * chore(helpers): introduced helper for getting a header link * feat(heading): introduced anchored heading component * chore(theme): adopted anchored component * chore(anchor): id is always provided * chore(dependencies): updated package json * chore(mdx): transformed into mdx pages that need to be in mdx * chore(dependencies): updated dependencies * chore(mdx): default config * fix: upgrade nextra and refactor getNextData * feat(layouts): introduced blog post layout * fix(release-post): end paragraph markings * chore(layouts): sanitize to be memoized * fix: only pass necessary node versions in page props * chore(guides): removed non-translated guides * fix(markdown): fix buffer guide markdown * feat(mdx): blockquote as highlightbox * fix(linting): fixed prettier rules for mdx * fix: /404 route and optimize page size * fix: optimize next build * chore(canonical): add canonical * refactor(data): simplified data gathering * chore(dependencies): introducesd sitemap and swr * chore(ts): allow downlevel iteration * fix(build): unoptimized images * feat(downloads): only latest major of each version * chore(js): removed unused code * chore(404): prettified 404 file * chore(footer): fixed # not valid * chore(i18n): add 404 page messages * chore(404): use tsx instead of mdx * chore(react-intl): no errors * chore(i18n): fallback data * chore(ci): added build on ci again * chore(sitemap): added sitemap data * chore(eslint): prefer nodejs config * chore(fix): linting * chore(scripts): remove server 404 and fix main.js for 404 * chore(build): is memory efficient now * fix(i18n): always using english locale * chore(next): updated config options * feat(data): improved data rendering/reusability * chore(next): remove non-necessary packages * chore(scripts): refactored release-post to mjs * chore(scripts): simplify and document code * chore(next): refactored data scripts * refactor(header): i18n, svg and fix styles * chore(next): minor refactor of helper * feat(node-data): only on selected routes * fix(ts): fixed typescript types * refactor(providers): simplified the _app * chore(dependencies): added gray-matter * feat(helpers): introduced script helpers * chore(types): updated types * refactor(next): refactored data components * chore(sitemap): removed non-existent env * chore(optimize): removed css optimization * feat(dat): introduced blog data helper * fix(blogdata): fixed slug * feat(types): shared props and context * feat(utils): added time component * chore(gitignore): year pages * chore(types): refactored types * chore(data): improved blog data and create year pages * feat(blog): introduced blog index page * feat(layouts): implemented blog category layout * feat(i18n): migrate translations 🎉 (#1) * feat: migrate `ar` * feat: migrate `ca` * feat: migrate `de` * feat: migrate `es` * feat: migrate `fa` * feat: migrate `fr` * feat: migrate `gl` * feat: migrate `it` * feat: migrate `ja` * feat: migrate `ka` * feat: migrate `ko` * feat: migrate `nl` * feat: migrate `pt-br` * feat: migrate `ro` * feat: migrate `ru` * feat: migrate `tr` * feat: migrate `uk` * feat: migrate `zh-cn` * feat: migrate `zh-tw` * chore: update next and previous strings * chore: remove `en` site.json * fix(document): numerours document style fixes and javascript fixes * chore(eslint): global window * chore(external): moved external folders * feat(rss): introduced rss generation * chore(tests): removed unused tests * chore(readme): updated readme * chore(lint): ignore and fix linting * refactor(scripts): refactored the legacy scripts * chore(ci): set memory to 4gb on ci * chore(workers): no need tofr morkers * chore(ci): updated a doc and ci file * chore(refactor): minor refactors, text changes and bug fixes * Update COLLABORATOR_GUIDE.md Co-authored-by: Brian Muenzenmeyer <[email protected]> Signed-off-by: Claudio Wunder <[email protected]> * Apply suggestions from code review Co-authored-by: Shanmughapriyan S <[email protected]> Signed-off-by: Claudio Wunder <[email protected]> * fix: upgrade nextra to remove the __esModule hack * chore: disable outputFileTracing * chore(ci): use build cache * chore(js): fix theme switcher issues * fix(build): improved data transmission from static props * chore(fixes): minor style and config changes * fix(scrollto): minor scroll to fix * Update next.config.mjs Co-authored-by: Michael Esteban <[email protected]> Signed-off-by: Claudio Wunder <[email protected]> * chore(ci): attempt to optimize caching * chore(ci): fine-tune to be based on eslint hashing * chore(cache): only cache .next/cache * chore(mastodon): added mastodon verification * chore(next): updated packages and optimised build performance * chore(dependencies): updated dependencies * fix(lint): fixed linting * chore(dependencies): removed temp dep * chore(package): reduce memory --------- Signed-off-by: Claudio Wunder <[email protected]> Co-authored-by: Shu Ding <[email protected]> Co-authored-by: Shanmughapriyan S <[email protected]> Co-authored-by: Brian Muenzenmeyer <[email protected]> Co-authored-by: Michael Esteban <[email protected]>
1 parent 5f9862c commit ec1ebcc

File tree

1,641 files changed

+11742
-35865
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

1,641 files changed

+11742
-35865
lines changed

.editorconfig

+2-6
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,9 @@
1-
# https://editorconfig.org/
2-
31
root = true
42

53
[*]
64
indent_style = space
75
indent_size = 2
86
end_of_line = lf
9-
insert_final_newline = true
7+
charset = utf-8
108
trim_trailing_whitespace = true
11-
12-
[*.svg]
13-
insert_final_newline = false
9+
insert_final_newline = true

.eslintignore

+17-4
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,17 @@
1-
**/*.min.js
2-
static/legacy/
3-
external/
4-
build/
1+
build
2+
.next
3+
external
4+
styles
5+
node_modules
6+
public/en/user-survey-report
7+
public/static/documents
8+
public/static/legacy
9+
10+
# These should be fixed in the future as the
11+
# tests and scripts will be updated in this PR
12+
tests
13+
14+
# MDX Plugin enforces Prettier formatting which should
15+
# be done in the future as we don't want to update the Markdown file
16+
# contents right now
17+
pages/**/*.md

.eslintrc

+58-37
Original file line numberDiff line numberDiff line change
@@ -1,51 +1,72 @@
11
{
2-
"extends": [
3-
"eslint:recommended",
4-
"standard",
5-
"prettier"
6-
],
7-
"plugins": [
8-
"prettier"
9-
],
10-
"rules": {
11-
"prettier/prettier": "error"
12-
},
2+
"extends": ["eslint:recommended", "next"],
133
"overrides": [
144
{
15-
"files": [
16-
"**/*.md"
17-
],
18-
"plugins": [
19-
"markdown"
20-
],
21-
"processor": "markdown/markdown"
5+
"files": ["**/*.{mjs,js,jsx,ts,tsx}"],
6+
"extends": ["plugin:prettier/recommended"],
7+
"env": { "node": true, "es6": true }
8+
},
9+
{
10+
"files": ["**/*.{ts,tsx}"],
11+
"globals": { "globalThis": false }
12+
},
13+
{
14+
"files": ["**/*.tsx"],
15+
"rules": {
16+
"react/no-unused-prop-types": "off",
17+
"react/require-default-props": "off",
18+
"react/jsx-props-no-spreading": "off",
19+
"react-hooks/rules-of-hooks": "error",
20+
"react-hooks/exhaustive-deps": "warn",
21+
"consistent-return": "off",
22+
"react/function-component-definition": [
23+
"error",
24+
{
25+
"namedComponents": "arrow-function",
26+
"unnamedComponents": "arrow-function"
27+
}
28+
],
29+
"react/jsx-filename-extension": [
30+
2,
31+
{ "extensions": [".js", ".jsx", ".ts", ".tsx"] }
32+
]
33+
}
34+
},
35+
{
36+
"files": ["**/*.{md,mdx}"],
37+
"extends": ["plugin:mdx/recommended"],
38+
"settings": { "mdx/code-blocks": false },
39+
"rules": { "react/jsx-no-undef": "off", "no-useless-escape": "off" }
2240
},
2341
{
2442
"files": [
25-
"**/*.md/*.js"
43+
"pages/*/about/*.{md,mdx}",
44+
"pages/*/download/*.{md,mdx}",
45+
"pages/*/get-involved/*.{md,mdx}",
46+
"pages/*/docs/*.{md,mdx}",
47+
"pages/*/*.{md,mdx}"
2648
],
27-
"parserOptions": {
28-
"ecmaVersion": "latest"
29-
},
49+
"settings": { "mdx/code-blocks": true }
50+
},
51+
{
52+
"files": ["pages/**/*.{md,mdx}/*.{js,jsx,cjs,mjs,ts,tsx}"],
3053
"rules": {
31-
"eqeqeq": "off",
32-
"n/no-deprecated-api": "off",
33-
"n/handle-callback-err": "off",
34-
"no-const-assign": "off",
54+
"camelcase": "off",
55+
"@typescript-eslint/no-unused-vars": "off",
56+
"consistent-return": "off",
57+
"func-names": "off",
58+
"import/extensions": "off",
59+
"import/no-extraneous-dependencies": "off",
60+
"import/no-unresolved": "off",
61+
"no-console": "off",
62+
"no-empty": "off",
63+
"no-restricted-globals": "off",
64+
"no-restricted-syntax": "off",
3565
"no-undef": "off",
66+
"no-underscore-dangle": "off",
3667
"no-unused-expressions": "off",
3768
"no-unused-vars": "off",
38-
"node/handle-callback-err": "off",
39-
"node/no-deprecated-api": "off",
40-
"prefer-const": "off",
41-
"prettier/prettier": [
42-
"error",
43-
{
44-
"singleQuote": true,
45-
"trailingComma": "none"
46-
}
47-
],
48-
"semi": ["error", "always"]
69+
"prefer-promise-reject-errors": "off"
4970
}
5071
}
5172
]

.github/ISSUE_TEMPLATE/01-bug-report.yml

+9-10
Original file line numberDiff line numberDiff line change
@@ -11,37 +11,36 @@ body:
1111
for us to fix it when you attach a screenshot as well.
1212
- type: input
1313
attributes:
14-
label: "URL:"
14+
label: 'URL:'
1515
description: The URL of the page you are reporting an issue on.
1616
placeholder: https://nodejs.org/en/
1717
validations:
1818
required: true
1919
- type: input
2020
attributes:
21-
label: "Browser Name:"
22-
description: What kind of browser are you using?
21+
label: 'Browser Name:'
22+
description: What kind of browser are you using?
2323
placeholder: Chrome
2424
validations:
2525
required: true
2626
- type: input
2727
attributes:
28-
label: "Browser Version:"
28+
label: 'Browser Version:'
2929
description: What version of browser are you using?
30-
placeholder: "103.0.5060.134"
30+
placeholder: '103.0.5060.134'
3131
validations:
3232
required: true
3333
- type: input
3434
attributes:
35-
label: "Operation System:"
36-
description:
37-
What kind of operation system are you using
35+
label: 'Operation System:'
36+
description: What kind of operation system are you using
3837
(Write it in full, with version number)?
39-
placeholder: "Windows 10, 21H2, 19044.1826"
38+
placeholder: 'Windows 10, 21H2, 19044.1826'
4039
validations:
4140
required: true
4241
- type: textarea
4342
attributes:
44-
label: "How to reproduce the issue:"
43+
label: 'How to reproduce the issue:'
4544
placeholder: |
4645
1. What I did.
4746
2. What I expected to happen.

.github/ISSUE_TEMPLATE/02-feature-request.yml

+1-1
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ body:
1212
so it might be a good idea to check out our plans there as well: https://github.com/nodejs/nodejs.dev/issues/.
1313
- type: textarea
1414
attributes:
15-
label: "Enter your suggestions in details:"
15+
label: 'Enter your suggestions in details:'
1616
placeholder: |
1717
1. What I expected to happen.
1818
2. Your reason (if possible, images or videos are welcome).

.github/ISSUE_TEMPLATE/03-i18n.yml

+1-1
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ body:
1010
to create a new localization team.
1111
- type: textarea
1212
attributes:
13-
label: "Enter your issue on localizations here:"
13+
label: 'Enter your issue on localizations here:'
1414
placeholder: |
1515
1. The name of the team (e.g: nodejs/node-cn).
1616
2. Any problems to report or you want to create it?

.github/dependabot.yml

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,12 @@
11
version: 2
22
updates:
33
- package-ecosystem: github-actions
4-
directory: "/"
4+
directory: '/'
55
schedule:
66
interval: weekly
77
open-pull-requests-limit: 10
88
- package-ecosystem: npm
9-
directory: "/"
9+
directory: '/'
1010
schedule:
1111
interval: weekly
1212
open-pull-requests-limit: 10

.github/workflows/ci.yml

+40-21
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ jobs:
2222
- name: Set up Node.js
2323
uses: actions/setup-node@v3
2424
with:
25-
node-version: "lts/*"
25+
node-version-file: '.nvmrc'
2626
cache: npm
2727

2828
- name: Install npm dependencies
@@ -31,9 +31,9 @@ jobs:
3131
- name: Lint
3232
run: |
3333
echo "::add-matcher::.github/workflows/remark-lint-problem-matcher.json"
34-
npm run test:lint
34+
npm run lint
3535
36-
test:
36+
build:
3737
name: Node on ${{ matrix.os }}
3838
runs-on: ${{ matrix.os }}
3939

@@ -49,28 +49,47 @@ jobs:
4949
- name: Set up Node.js
5050
uses: actions/setup-node@v3
5151
with:
52-
node-version: "lts/*"
52+
node-version-file: '.nvmrc'
5353
cache: npm
5454

55-
- run: java -version
56-
57-
- name: Install npm dependencies
55+
- name: Install NPM dependencies
5856
run: npm ci
5957

60-
- name: Build
61-
run: npm run build
62-
63-
- name: Run unit tests
64-
run: npm run test:unit
58+
- name: Restore Next.js cache
59+
uses: actions/cache/restore@v3
60+
with:
61+
path: |
62+
${{ github.workspace }}/.next/cache
63+
key: ${{ runner.os }}-nextjs-${{ hashFiles('**/package-lock.json') }}-
6564

66-
- name: Run HTML validator
67-
run: npm run test:html
65+
- name: Build Next.js
66+
run: npm run build
67+
env:
68+
NODE_OPTIONS: '--max_old_space_size=4096'
6869

69-
- name: Run linkinator
70-
uses: JustinBeckwith/linkinator-action@v1
70+
- name: Save Next.js cache
71+
uses: actions/cache/save@v3
7172
with:
72-
linksToSkip: "^(?!http://localhost)"
73-
paths: en
74-
recurse: true
75-
serverRoot: build
76-
verbosity: error
73+
path: |
74+
${{ github.workspace }}/.next/cache
75+
key: ${{ runner.os }}-nextjs-${{ hashFiles('**/package-lock.json') }}-${{ hashFiles('.next/cache/eslint') }}
76+
77+
- name: Export Next.js
78+
run: npm run export
79+
80+
# We don't generate non-translated pages. So if a certain page on /en/ exists
81+
# but not on /de/ or any other language, it will 404. This is handled on nginx level
82+
# Prior to this migration Metalsmith would copy the English version of a page to all
83+
# the non-translated pages. "Fooling" the 404 by basically adding i18n context with
84+
# an untranslated page. This would be very exhaustive with Next.js on SCG mode
85+
# but it's something we want to do once we decide upon using Next.js on SSR mode or
86+
# if we decide upon using Vercel's infrastructure as generating a copy of every English page
87+
# on the file system is very resource exhaustive.
88+
# - name: Run linkinator
89+
# uses: JustinBeckwith/linkinator-action@v1
90+
# with:
91+
# linksToSkip: '^(?!http://localhost)'
92+
# paths: en
93+
# recurse: true
94+
# serverRoot: build
95+
# verbosity: error

.github/workflows/codeql.yml

+3-3
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
name: "CodeQL"
1+
name: 'CodeQL'
22

33
on:
44
push:
@@ -8,7 +8,7 @@ on:
88
branches:
99
- main
1010
schedule:
11-
- cron: "0 0 * * 0"
11+
- cron: '0 0 * * 0'
1212
workflow_dispatch:
1313

1414
jobs:
@@ -27,7 +27,7 @@ jobs:
2727
- name: Initialize CodeQL
2828
uses: github/codeql-action/init@v2
2929
with:
30-
languages: "javascript"
30+
languages: 'javascript'
3131

3232
- name: Perform CodeQL Analysis
3333
uses: github/codeql-action/analyze@v2

.gitignore

+9-5
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,3 @@
1-
# Generated HTML and other static files
2-
build/
31
# Commonly ignored Node.js files
42
node_modules/
53
npm-debug.log
@@ -10,7 +8,13 @@ npm-debug.log
108
.AppleDouble
119
.LSOverride
1210

13-
# Netlify
14-
.netlify
11+
# Next.js files
12+
.next
13+
build
14+
public/sitemap.xml
15+
public/en/feed/*.xml
16+
pages/en/blog/year-[0-9][0-9][0-9][0-9].md
1517

16-
.cache/
18+
# ESLint Cache Files
19+
.eslintjscache
20+
.eslintmdcache

.mailmap

-1
This file was deleted.

.nvmrc

+1
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
lts/hydrogen

.prettierignore

+17
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
build
2+
.next
3+
external
4+
styles
5+
node_modules
6+
public/en/user-survey-report
7+
public/static/documents
8+
public/static/legacy
9+
10+
# These should be fixed in the future as the
11+
# tests and scripts will be updated in this PR
12+
tests
13+
14+
# MDX Plugin enforces Prettier formatting which should
15+
# be done in the future as we don't want to update the Markdown file
16+
# contents right now
17+
pages/**/*.md

.prettierrc

+12
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
{
2+
"printWidth": 80,
3+
"tabWidth": 2,
4+
"useTabs": false,
5+
"semi": true,
6+
"singleQuote": true,
7+
"jsxSingleQuote": false,
8+
"trailingComma": "es5",
9+
"bracketSpacing": true,
10+
"bracketSameLine": false,
11+
"arrowParens": "avoid"
12+
}

0 commit comments

Comments
 (0)