Skip to content

Commit eba0eb0

Browse files
author
Luca Forstner
authored
Revert "deps: Bump next and related dependencies" (#10509)
1 parent 088fec6 commit eba0eb0

File tree

4 files changed

+149
-126
lines changed

4 files changed

+149
-126
lines changed

package.json

Lines changed: 7 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -24,8 +24,7 @@
2424
"lint:prettier:fix": "prettier --write \"./{src,app,scripts}/**/*.{md,mdx,ts,tsx,js,jsx,mjs}\"",
2525
"lint:fix": "yarn run lint:prettier:fix && yarn run lint:eslint:fix",
2626
"sidecar": "yarn spotlight-sidecar",
27-
"test": "jest",
28-
"build-trace": "npx next@canary internal turbo-trace-server .next/trace"
27+
"test": "jest"
2928
},
3029
"prisma": {
3130
"seed": "node prisma/seed/seed.mjs"
@@ -37,9 +36,9 @@
3736
"@emotion/react": "^11.11.0",
3837
"@emotion/styled": "^11.0.0",
3938
"@google-cloud/storage": "^7.7.0",
40-
"@mdx-js/loader": "^3.0.1",
41-
"@mdx-js/react": "^3.0.1",
42-
"@next/mdx": "^14.2.4",
39+
"@mdx-js/loader": "^3.0.0",
40+
"@mdx-js/react": "^3.0.0",
41+
"@next/mdx": "^14.0.1",
4342
"@popperjs/core": "^2.11.8",
4443
"@prettier/plugin-xml": "^3.3.1",
4544
"@prisma/client": "^5.8.1",
@@ -52,7 +51,7 @@
5251
"@radix-ui/themes": "^2.0.3",
5352
"@sentry-internal/global-search": "^1.0.0",
5453
"@sentry/nextjs": "^8.8.0",
55-
"@types/mdx": "^2.0.13",
54+
"@types/mdx": "^2.0.9",
5655
"algoliasearch": "^4.23.3",
5756
"esbuild": "^0.19.8",
5857
"framer-motion": "^10.12.16",
@@ -62,9 +61,9 @@
6261
"js-cookie": "^3.0.5",
6362
"js-yaml": "^4.1.0",
6463
"match-sorter": "^6.3.4",
65-
"mdx-bundler": "^10.0.2",
64+
"mdx-bundler": "^10.0.1",
6665
"micromark": "^4.0.0",
67-
"next": "14.2.4",
66+
"next": "14.0.2",
6867
"next-auth": "^4.24.5",
6968
"next-mdx-remote": "^4.4.1",
7069
"nextjs-toploader": "^1.6.6",

src/mdx.ts

Lines changed: 22 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
import fs from 'fs';
22
import path from 'path';
3-
import {fileURLToPath} from 'url';
43

54
import matter from 'gray-matter';
65
import {s} from 'hastscript';
@@ -29,8 +28,7 @@ import remarkTocHeadings, {TocNode} from './remark-toc-headings';
2928
import remarkVariables from './remark-variables';
3029
import {FrontMatter, Platform, PlatformConfig} from './types';
3130

32-
// @ts-ignore
33-
const directoryName = path.dirname(fileURLToPath(import.meta.url));
31+
const root = process.cwd();
3432

3533
function formatSlug(slug: string) {
3634
return slug.replace(/\.(mdx|md)/, '');
@@ -98,8 +96,8 @@ async function getDocsFrontMatterUncached(): Promise<FrontMatter[]> {
9896
return frontMatter;
9997
}
10098

101-
function getAllFilesFrontMatter() {
102-
const docsPath = path.join(directoryName, '..', 'docs');
99+
export function getAllFilesFrontMatter(folder: string = 'docs') {
100+
const docsPath = path.join(root, folder);
103101
const files = getAllFilesRecursively(docsPath);
104102
const allFrontMatter: FrontMatter[] = [];
105103
files.forEach(file => {
@@ -117,10 +115,15 @@ function getAllFilesFrontMatter() {
117115
allFrontMatter.push({
118116
...(frontmatter as FrontMatter),
119117
slug: formatSlug(fileName),
120-
sourcePath: path.join('docs', fileName),
118+
sourcePath: path.join(folder, fileName),
121119
});
122120
});
123121

122+
if (folder !== 'docs') {
123+
// We exit early if we're not in the docs folder. We use this for the changelog.
124+
return allFrontMatter;
125+
}
126+
124127
// Add all `common` files in the right place.
125128
const platformsPath = path.join(docsPath, 'platforms');
126129
const platformNames = fs
@@ -215,17 +218,17 @@ function getAllFilesFrontMatter() {
215218
}
216219

217220
export async function getFileBySlug(slug: string) {
218-
const configPath = path.join(directoryName, '..', slug, 'config.yml');
221+
const configPath = path.join(root, slug, 'config.yml');
219222

220223
let configFrontmatter: PlatformConfig | undefined;
221224
if (fs.existsSync(configPath)) {
222225
configFrontmatter = yaml.load(fs.readFileSync(configPath, 'utf8')) as PlatformConfig;
223226
}
224227

225-
let mdxPath = path.join(directoryName, '..', `${slug}.mdx`);
226-
let mdxIndexPath = path.join(directoryName, '..', slug, 'index.mdx');
227-
let mdPath = path.join(directoryName, '..', `${slug}.md`);
228-
let mdIndexPath = path.join(directoryName, '..', slug, 'index.md');
228+
let mdxPath = path.join(root, `${slug}.mdx`);
229+
let mdxIndexPath = path.join(root, slug, 'index.mdx');
230+
let mdPath = path.join(root, `${slug}.md`);
231+
let mdIndexPath = path.join(root, slug, 'index.md');
229232

230233
if (
231234
slug.indexOf('docs/platforms/') === 0 &&
@@ -246,20 +249,18 @@ export async function getFileBySlug(slug: string) {
246249
commonFilePath = path.join(commonPath, slugParts.slice(3).join('/'));
247250
}
248251
if (commonFilePath && fs.existsSync(commonPath)) {
249-
mdxPath = path.join(directoryName, '..', `${commonFilePath}.mdx`);
250-
mdxIndexPath = path.join(directoryName, '..', commonFilePath, 'index.mdx');
251-
mdPath = path.join(directoryName, '..', `${commonFilePath}.md`);
252-
mdIndexPath = path.join(directoryName, '..', commonFilePath, 'index.md');
252+
mdxPath = path.join(root, `${commonFilePath}.mdx`);
253+
mdxIndexPath = path.join(root, commonFilePath, 'index.mdx');
254+
mdPath = path.join(root, `${commonFilePath}.md`);
255+
mdIndexPath = path.join(root, commonFilePath, 'index.md');
253256
}
254257
}
255258

256-
const sourcePath =
257-
[mdxPath, mdxIndexPath, mdPath].find(p => fs.existsSync(p)) ?? mdIndexPath;
259+
const sourcePath = [mdxPath, mdxIndexPath, mdPath].find(fs.existsSync) ?? mdIndexPath;
258260
const source = fs.readFileSync(sourcePath, 'utf8');
259261

260262
process.env.ESBUILD_BINARY_PATH = path.join(
261-
directoryName,
262-
'..',
263+
root,
263264
'node_modules',
264265
'esbuild',
265266
'bin',
@@ -284,10 +285,7 @@ export async function getFileBySlug(slug: string) {
284285
[remarkTocHeadings, {exportRef: toc}],
285286
remarkGfm,
286287
remarkFormatCodeBlocks,
287-
[
288-
remarkImageSize,
289-
{sourceFolder: cwd, publicFolder: path.join(directoryName, '..', 'public')},
290-
],
288+
[remarkImageSize, {sourceFolder: cwd, publicFolder: path.join(root, 'public')}],
291289
remarkMdxImages,
292290
remarkCodeTitles,
293291
remarkCodeTabs,
@@ -355,7 +353,7 @@ export async function getFileBySlug(slug: string) {
355353
};
356354
// Set the `outdir` to a public location for this bundle.
357355
// this where this images will be copied
358-
options.outdir = path.join(directoryName, '..', 'public', 'mdx-images');
356+
options.outdir = path.join(root, 'public', 'mdx-images');
359357

360358
// Set write to true so that esbuild will output the files.
361359
options.write = true;

vercel.json

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
{
2-
"$schema": "https://openapi.vercel.sh/vercel.json",
32
"headers": [
43
{
54
"source": "/(.*)",

0 commit comments

Comments
 (0)