Skip to content

Commit e65e6c0

Browse files
Manikanta MavireddyManikanta Mavireddy
authored andcommitted
Merge remote-tracking branch 'upstream/main' into sidebar-component-family
2 parents a0b867d + a395b8b commit e65e6c0

26 files changed

+5626
-3157
lines changed

.github/workflows/build.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,7 @@ jobs:
6060
run: echo C:\Program Files\Git\usr\bin>>"%GITHUB_PATH%"
6161

6262
- name: Git Checkout
63-
uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 # v4.1.0
63+
uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 # v4.1.1
6464
with:
6565
# Since we checkout the HEAD of the current Branch, if the Pull Request comes from a Fork
6666
# we want to clone the fork's repository instead of the base repository
@@ -94,7 +94,7 @@ jobs:
9494
cache-build-
9595
9696
- name: Set up Node.js
97-
uses: actions/setup-node@5e21ff4d9bc1a8cf6de233a3057d20ec6b3fb69d
97+
uses: actions/setup-node@8f152de45cc393bb48ce5d89d36b731f54556e65
9898
with:
9999
# We want to ensure that the Node.js version running here respects our supported versions
100100
node-version-file: '.nvmrc'

.github/workflows/dependency-review.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,12 +21,12 @@ jobs:
2121
runs-on: ubuntu-latest
2222
steps:
2323
- name: Harden Runner
24-
uses: step-security/harden-runner@8ca2b8b2ece13480cda6dacd3511b49857a23c09 # v2.5.1
24+
uses: step-security/harden-runner@1b05615854632b887b69ae1be8cbefe72d3ae423 # v2.6.0
2525
with:
2626
egress-policy: audit
2727

2828
- name: Git Checkout
29-
uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 # v4.1.0
29+
uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 # v4.1.1
3030

3131
- name: Review Dependencies
3232
uses: actions/dependency-review-action@6c5ccdad469c9f8a2996bfecaec55a631a347034 # v3.1.0

.github/workflows/lighthouse.yml

Lines changed: 3 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ jobs:
3636

3737
steps:
3838
- name: Git Checkout
39-
uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 # v4.1.0
39+
uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 # v4.1.1
4040
with:
4141
# Since we checkout the HEAD of the current Branch, if the Pull Request comes from a Fork
4242
# we want to clone the fork's repository instead of the base repository
@@ -51,7 +51,7 @@ jobs:
5151

5252
- name: Add Comment to PR
5353
# Signal that a lighthouse run is about to start
54-
uses: thollander/actions-comment-pull-request@d61db783da9abefc3437960d0cce08552c7c004f # v2.4.2
54+
uses: thollander/actions-comment-pull-request@1d3973dc4b8e1399c0620d3f2b1aa5e795465308 # v2.4.3
5555
with:
5656
message: |
5757
Running Lighthouse audit...
@@ -65,14 +65,6 @@ jobs:
6565
token: ${{ secrets.GITHUB_TOKEN }}
6666
max_timeout: 90
6767

68-
- name: Git Checkout
69-
uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 # v4.1.0
70-
with:
71-
# By default Git Checkout on `pull-request-target` will checkout
72-
# the `default` branch of the Pull Request. We want to checkout
73-
# the actual branch of the Pull Request.
74-
ref: ${{ github.event.pull_request.head.ref }}
75-
7668
- name: Audit Preview URL with Lighthouse
7769
# Conduct the lighthouse audit
7870
id: lighthouse_audit
@@ -109,7 +101,7 @@ jobs:
109101
110102
- name: Add Comment to PR
111103
# Replace the previous message with our formatted lighthouse results
112-
uses: thollander/actions-comment-pull-request@d61db783da9abefc3437960d0cce08552c7c004f # v2.4.2
104+
uses: thollander/actions-comment-pull-request@1d3973dc4b8e1399c0620d3f2b1aa5e795465308 # v2.4.3
113105
with:
114106
# Reference the previously created comment
115107
comment_tag: 'lighthouse_audit'

.github/workflows/lint-and-tests.yml

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,7 @@ jobs:
6161

6262
steps:
6363
- name: Git Checkout
64-
uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 # v4.1.0
64+
uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 # v4.1.1
6565
with:
6666
# Since we checkout the HEAD of the current Branch, if the Pull Request comes from a Fork
6767
# we want to clone the fork's repository instead of the base repository
@@ -95,7 +95,7 @@ jobs:
9595
cache-lint-
9696
9797
- name: Set up Node.js
98-
uses: actions/setup-node@5e21ff4d9bc1a8cf6de233a3057d20ec6b3fb69d
98+
uses: actions/setup-node@8f152de45cc393bb48ce5d89d36b731f54556e65
9999
with:
100100
# We want to ensure that the Node.js version running here respects our supported versions
101101
node-version-file: '.nvmrc'
@@ -171,7 +171,7 @@ jobs:
171171

172172
steps:
173173
- name: Git Checkout
174-
uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 # v4.1.0
174+
uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 # v4.1.1
175175
with:
176176
# Since we checkout the HEAD of the current Branch, if the Pull Request comes from a Fork
177177
# we want to clone the fork's repository instead of the base repository
@@ -188,7 +188,7 @@ jobs:
188188
fetch-depth: 0
189189

190190
- name: Set up Node.js
191-
uses: actions/setup-node@5e21ff4d9bc1a8cf6de233a3057d20ec6b3fb69d
191+
uses: actions/setup-node@8f152de45cc393bb48ce5d89d36b731f54556e65
192192
with:
193193
# We want to ensure that the Node.js version running here respects our supported versions
194194
node-version-file: '.nvmrc'

.github/workflows/scorecard.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -32,12 +32,12 @@ jobs:
3232

3333
steps:
3434
- name: Harden Runner
35-
uses: step-security/harden-runner@8ca2b8b2ece13480cda6dacd3511b49857a23c09 # v2.5.1
35+
uses: step-security/harden-runner@1b05615854632b887b69ae1be8cbefe72d3ae423 # v2.6.0
3636
with:
3737
egress-policy: audit
3838

3939
- name: Git Checkout
40-
uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 # v4.1.0
40+
uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 # v4.1.1
4141
with:
4242
persist-credentials: false
4343

.github/workflows/translations-pr.yml

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ jobs:
3333
runs-on: ubuntu-latest
3434

3535
steps:
36-
- uses: thollander/actions-comment-pull-request@d61db783da9abefc3437960d0cce08552c7c004f
36+
- uses: thollander/actions-comment-pull-request@1d3973dc4b8e1399c0620d3f2b1aa5e795465308
3737
with:
3838
message: |
3939
> [!NOTE]\
@@ -56,7 +56,7 @@ jobs:
5656

5757
steps:
5858
- name: Git Checkout
59-
uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 # v4.1.0
59+
uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 # v4.1.1
6060
with:
6161
# By default Git Checkout on `pull-request-target` will checkout
6262
# the `default` branch of the Pull Request. We want to checkout
@@ -80,7 +80,7 @@ jobs:
8080
cache-lint-
8181
8282
- name: Set up Node.js
83-
uses: actions/setup-node@5e21ff4d9bc1a8cf6de233a3057d20ec6b3fb69d
83+
uses: actions/setup-node@8f152de45cc393bb48ce5d89d36b731f54556e65
8484
with:
8585
# We want to ensure that the Node.js version running here respects our supported versions
8686
node-version-file: '.nvmrc'
@@ -102,7 +102,7 @@ jobs:
102102
run: npx prettier "{pages,i18n}/**/*.{json,md,mdx}" --check --write --cache --cache-strategy=metadata --cache-location=.prettiercache
103103

104104
- name: Push Changes back to Pull Request
105-
uses: stefanzweifel/git-auto-commit-action@3ea6ae190baf489ba007f7c92608f33ce20ef04a
105+
uses: stefanzweifel/git-auto-commit-action@8756aa072ef5b4a080af5dc8fef36c5d586e521d
106106
with:
107107
commit_options: '--no-verify --signoff'
108108
commit_message: 'chore: automated format of translated files'

global.d.ts

Lines changed: 0 additions & 12 deletions
This file was deleted.

next.config.mjs

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ const nextConfig = {
3636
eslint: { dirs: ['.'], ignoreDuringBuilds: true },
3737
// Next.js WebPack Bundler does not know how to handle `.mjs` files on `node_modules`
3838
// This is not an issue when using TurboPack as it uses SWC and it is ESM-only
39-
// Once we migrate to Next.js 14 we might be able to remove this
39+
// Once Next.js uses Turbopack for their build process we can remove this
4040
webpack: function (config) {
4141
config.module.rules.push({
4242
test: /\.m?js$/,
@@ -58,6 +58,8 @@ const nextConfig = {
5858
'@radix-ui/react-toast',
5959
'tailwindcss',
6060
],
61+
// Removes the warning regarding the WebPack Build Worker
62+
webpackBuildWorker: false,
6163
},
6264
};
6365

next.constants.mjs

Lines changed: 0 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -82,15 +82,6 @@ export const MD_EXTENSION_REGEX = /((\/)?(index))?\.mdx?$/i;
8282
*/
8383
export const DEFAULT_LOCALE_CODE = defaultLocale.code;
8484

85-
/**
86-
* This indicates the path to the Legacy JavaScript File that is used
87-
* on the legacy Website.
88-
*
89-
* @deprecated The Legacy Website is due to be removed soon and this file
90-
* and its usages should be removed
91-
*/
92-
export const LEGACY_JAVASCRIPT_FILE = `${BASE_PATH}/static/js/legacyMain.js`;
93-
9485
/**
9586
* This is a list of all static routes or pages from the Website that we do not
9687
* want to allow to be statically built on our Static Export Build.

next.dynamic.mjs

Lines changed: 10 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -3,13 +3,12 @@
33
import { readFileSync } from 'node:fs';
44
import { join, normalize, sep } from 'node:path';
55

6-
import { serialize } from 'next-mdx-remote/serialize';
76
import { VFile } from 'vfile';
87

98
import { DEFAULT_LOCALE_CODE, MD_EXTENSION_REGEX } from './next.constants.mjs';
109
import { getMarkdownFiles } from './next.helpers.mjs';
1110
import { availableLocales } from './next.locales.mjs';
12-
import { nextRehypePlugins, nextRemarkPlugins } from './next.mdx.mjs';
11+
import { compileMDX } from './next.mdx.compiler.mjs';
1312

1413
// allows us to run a glob to get markdown files based on a language folder
1514
const getPathsByLanguage = async (locale = DEFAULT_LOCALE_CODE, ignored = []) =>
@@ -148,31 +147,15 @@ export const generateStaticProps = async (source = '', filename = '') => {
148147
// Gets the file extension of the file, to determine which parser and plugins to use
149148
const fileExtension = filename.endsWith('.mdx') ? 'mdx' : 'md';
150149

151-
// This act as a MDX "compiler" but, lightweight. It parses the Markdown
152-
// string source into a React Component tree, and then it serializes it
153-
// it also supports Remark plugins, and MDX components
154-
// Note.: We use the filename extension to define the mode of execution
155-
const { compiledSource } = await serialize(sourceAsVirtualFile, {
156-
parseFrontmatter: true,
157-
mdxOptions: {
158-
rehypePlugins: nextRehypePlugins(fileExtension),
159-
remarkPlugins: nextRemarkPlugins(fileExtension),
160-
format: fileExtension,
161-
},
162-
});
163-
164-
// After the MDX gets processed with the remarkPlugins, some extra `data` that might come along
165-
// the `frontmatter` comes from `serialize` built-in support to `remark-frontmatter`
166-
const { headings, matter: rawFrontmatter } = sourceAsVirtualFile.data;
167-
168-
// This serialises the Frontmatter into a JSON object that is compatible with the
169-
// `getStaticProps` supported data type for props. (No prop value can be an object or not a primitive)
170-
const frontmatter = JSON.parse(JSON.stringify(rawFrontmatter));
171-
172-
// this defines the basic props that should be passed back to the `DynamicPage` component
173-
// We only want the `compiledSource` as we use `MDXProvider` for custom components along the journey
174-
// And then we want the frontmatter and heading information from the VFile `data`
175-
staticProps.props = { content: compiledSource, headings, frontmatter };
150+
// This compiles our MDX source (VFile) into a final MDX-parsed VFile
151+
// that then is passed as a string to the MDXProvider which will run the MDX Code
152+
const { content, headings, frontmatter } = await compileMDX(
153+
sourceAsVirtualFile,
154+
fileExtension
155+
);
156+
157+
// Passes the compiled MDX Source to the MDX Provider and some extra data
158+
staticProps.props = { content: String(content), headings, frontmatter };
176159
staticProps.notFound = false;
177160
}
178161

next.mdx.compiler.mjs

Lines changed: 52 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,52 @@
1+
'use strict';
2+
3+
import { compile, runSync } from '@mdx-js/mdx';
4+
import * as jsxRuntime from 'react/jsx-runtime';
5+
import { matter } from 'vfile-matter';
6+
7+
import { NEXT_REHYPE_PLUGINS, NEXT_REMARK_PLUGINS } from './next.mdx.mjs';
8+
9+
/**
10+
* This is our custom simple MDX Compiler that is used to compile Markdown and MDX
11+
* this returns a serializable VFile as a string that then gets passed to our MDX Provider
12+
*
13+
* @param {import('vfile').VFile} source
14+
* @param {'md' | 'mdx'} fileExtension
15+
* @returns {Promise<{ content: import('vfile').VFile; headings: import('@vcarl/remark-headings').Heading[]; frontmatter: Record<string, any>}>}
16+
*/
17+
export async function compileMDX(source, fileExtension) {
18+
// Parses the Frontmatter to the VFile and removes from the original source
19+
// cleaning the frontmatter to the source that is going to be parsed by the MDX Compiler
20+
matter(source, { strip: true });
21+
22+
// This is a minimal MDX Compiler that is lightweight and only parses the MDX
23+
const compiledSource = await compile(source, {
24+
rehypePlugins: NEXT_REHYPE_PLUGINS,
25+
remarkPlugins: NEXT_REMARK_PLUGINS,
26+
format: fileExtension,
27+
// This instructs the MDX compiler to generate a minimal JSX-body
28+
// to be consumed within MDX's `run` method, instead of a standalone React Application
29+
outputFormat: 'function-body',
30+
// Ensure compatibility with Server Components
31+
providerImportSource: undefined,
32+
});
33+
34+
// Retrieve some parsed data from the VFile metadata
35+
// such as frontmatter and Markdown headings
36+
const { headings, matter: frontmatter } = source.data;
37+
38+
return { content: compiledSource, headings, frontmatter };
39+
}
40+
41+
/**
42+
* This evaluates our MDX VFile into actual JSX eval'd code
43+
* which is actually used by the MDX Provider
44+
*
45+
* @param {string} source
46+
* @returns {import('mdx/types').MDXContent}
47+
*/
48+
export function runMDX(source) {
49+
const { default: content } = runSync(source, jsxRuntime);
50+
51+
return content;
52+
}

0 commit comments

Comments
 (0)