From 2030ab60cbb278a3c820f4aa6d997e506ba731de Mon Sep 17 00:00:00 2001 From: Claudio Wunder Date: Mon, 12 Jun 2023 23:47:42 +0200 Subject: [PATCH 1/6] feat: introduce dynamic rendering of pages --- .github/ISSUE_TEMPLATE/01-bug-report.yml | 16 +- .github/ISSUE_TEMPLATE/02-feature-request.yml | 2 +- .github/ISSUE_TEMPLATE/config.yml | 4 +- .github/workflows/pull-request.yml | 4 +- COLLABORATOR_GUIDE.md | 2 +- components/Blog/BlogCard/index.stories.tsx | 2 +- layouts/BlogIndexLayout.tsx | 2 +- layouts/CategoryIndexLayout.tsx | 2 +- middleware.ts | 1 - .../generateNodeReleasesJson.mjs | 12 +- .../generateWebsiteFeeds.mjs | 37 +- .../next-data => next-data}/getBlogData.mjs | 76 ++-- next-data/getBlogIndexPages.mjs | 17 + next-data/helpers.mjs | 65 ++++ next-data/index.mjs | 15 + next.config.mjs | 5 +- next.data.mjs | 13 +- next.dynamic.mjs | 155 ++++++++ next.locales.mjs | 8 +- package-lock.json | 357 ++++++++++++------ package.json | 6 +- pages/[locale]/[...pathname].tsx | 58 +++ pages/[locale]/blog/[year].tsx | 66 ++++ providers/layoutProvider.tsx | 1 - scripts/next-data/_helpers.mjs | 16 - scripts/next-data/index.mjs | 3 - theme.dynamic.tsx | 56 +++ theme.tsx | 19 +- turbo.json | 29 +- types/blog.ts | 2 +- types/frontmatter.ts | 2 +- types/index.ts | 1 - types/middlewares.ts | 2 +- 33 files changed, 801 insertions(+), 255 deletions(-) rename {scripts/next-data => next-data}/generateNodeReleasesJson.mjs (80%) rename scripts/next-data/generatePreBuildFiles.mjs => next-data/generateWebsiteFeeds.mjs (53%) rename {scripts/next-data => next-data}/getBlogData.mjs (74%) create mode 100644 next-data/getBlogIndexPages.mjs create mode 100644 next-data/helpers.mjs create mode 100644 next-data/index.mjs create mode 100644 next.dynamic.mjs create mode 100644 pages/[locale]/[...pathname].tsx create mode 100644 pages/[locale]/blog/[year].tsx delete mode 100644 scripts/next-data/_helpers.mjs delete mode 100644 scripts/next-data/index.mjs create mode 100644 theme.dynamic.tsx diff --git a/.github/ISSUE_TEMPLATE/01-bug-report.yml b/.github/ISSUE_TEMPLATE/01-bug-report.yml index ac6f79f1f1870..281e5e0159968 100644 --- a/.github/ISSUE_TEMPLATE/01-bug-report.yml +++ b/.github/ISSUE_TEMPLATE/01-bug-report.yml @@ -1,5 +1,5 @@ name: Report a Technical/Visual Issue on the Node.js Website -description: "Is something not working as expected? Did you encounter a glitch or a bug with the Website?" +description: 'Is something not working as expected? Did you encounter a glitch or a bug with the Website?' labels: [bug] body: - type: markdown @@ -11,36 +11,36 @@ body: for us to fix it when you attach a screenshot as well. - type: input attributes: - label: "URL:" + label: 'URL:' description: The URL of the page you are reporting an issue on. placeholder: https://nodejs.org/en/ validations: required: true - type: input attributes: - label: "Browser Name:" + label: 'Browser Name:' description: What kind of browser are you using? placeholder: Chrome validations: required: true - type: input attributes: - label: "Browser Version:" + label: 'Browser Version:' description: What version of browser are you using? - placeholder: "103.0.5060.134" + placeholder: '103.0.5060.134' validations: required: true - type: input attributes: - label: "Operating System:" + label: 'Operating System:' description: What kind of operation system are you using (Write it in full, with version number)? - placeholder: "Windows 10, 21H2, 19044.1826" + placeholder: 'Windows 10, 21H2, 19044.1826' validations: required: true - type: textarea attributes: - label: "How to reproduce the issue:" + label: 'How to reproduce the issue:' placeholder: | 1. What I did. 2. What I expected to happen. diff --git a/.github/ISSUE_TEMPLATE/02-feature-request.yml b/.github/ISSUE_TEMPLATE/02-feature-request.yml index 4d6261251c17e..da59bf9dbc09b 100644 --- a/.github/ISSUE_TEMPLATE/02-feature-request.yml +++ b/.github/ISSUE_TEMPLATE/02-feature-request.yml @@ -1,5 +1,5 @@ name: Suggest a new feature or improvement for the Node.js Website -description: "Do you have an idea or a suggestion and you want to share?" +description: 'Do you have an idea or a suggestion and you want to share?' labels: [feature request] body: - type: markdown diff --git a/.github/ISSUE_TEMPLATE/config.yml b/.github/ISSUE_TEMPLATE/config.yml index 43d3c987a1ecf..5470b5cc09c8f 100644 --- a/.github/ISSUE_TEMPLATE/config.yml +++ b/.github/ISSUE_TEMPLATE/config.yml @@ -2,10 +2,10 @@ blank_issues_enabled: true contact_links: - name: Report an API Docs Issue on the Node.js Website url: https://github.com/nodejs/node/issues/new?assignees=&labels=doc&template=3-api-ref-docs-problem.yml - about: "Is something wrong with the API Docs? Did you face a bug with the API Docs?" + about: 'Is something wrong with the API Docs? Did you face a bug with the API Docs?' - name: Report a Translation Issue on the Node.js Website url: https://crowdin.com/project/nodejs-website - about: "Is something wrong in a specific translation? Do you believe a language can get improved? Do you have suggestions?" + about: 'Is something wrong in a specific translation? Do you believe a language can get improved? Do you have suggestions?' - name: Need help with Node.js? url: https://github.com/nodejs/help/issues/ about: "Struggling with Node.js? You're not sure how to code?" diff --git a/.github/workflows/pull-request.yml b/.github/workflows/pull-request.yml index 6653ce82ea3da..fb71a7cacf97a 100644 --- a/.github/workflows/pull-request.yml +++ b/.github/workflows/pull-request.yml @@ -60,7 +60,7 @@ jobs: os: [ubuntu-latest, windows-latest] steps: - - name: "Use GNU tar instead BSD tar" + - name: 'Use GNU tar instead BSD tar' if: matrix.os == 'windows-latest' shell: cmd run: echo C:\Program Files\Git\usr\bin>>"%GITHUB_PATH%" @@ -122,7 +122,7 @@ jobs: os: [ubuntu-latest, windows-latest] steps: - - name: "Use GNU tar instead BSD tar" + - name: 'Use GNU tar instead BSD tar' if: matrix.os == 'windows-latest' shell: cmd run: echo C:\Program Files\Git\usr\bin>>"%GITHUB_PATH%" diff --git a/COLLABORATOR_GUIDE.md b/COLLABORATOR_GUIDE.md index 1ac82b980077a..dbf94ad62a154 100644 --- a/COLLABORATOR_GUIDE.md +++ b/COLLABORATOR_GUIDE.md @@ -235,4 +235,4 @@ export default { component: NameOfComponent } as Meta; [`react-intl`]: https://formatjs.io/docs/react-intl/ [Next.js]: https://nextjs.org/ [MDX]: https://mdxjs.com/ -[SCSS]: https://sass-lang.com/ \ No newline at end of file +[SCSS]: https://sass-lang.com/ diff --git a/components/Blog/BlogCard/index.stories.tsx b/components/Blog/BlogCard/index.stories.tsx index 5a7f848ab6eee..c8206347c964c 100644 --- a/components/Blog/BlogCard/index.stories.tsx +++ b/components/Blog/BlogCard/index.stories.tsx @@ -8,7 +8,7 @@ export const Default: Story = { args: { author: 'Bat Man', category: 'category-mock', - date: '2023-04-21 23:40:56.77', + date: new Date('2023-04-21 23:40:56.77'), slug: '/blog/category-mock/sample-blog', title: 'Sample Test Blog', readingTime: '1 min read', diff --git a/layouts/BlogIndexLayout.tsx b/layouts/BlogIndexLayout.tsx index 2d09576d4c7bc..cb2acb65c463d 100644 --- a/layouts/BlogIndexLayout.tsx +++ b/layouts/BlogIndexLayout.tsx @@ -23,7 +23,7 @@ const BlogIndexLayout: FC = ({ children }) => {