Skip to content

Commit e480e10

Browse files
authored
Merge pull request #80 from chrisweb/preview
Next.js 15 migration + next.js 15 static first mdx tutorial
2 parents 0238cd9 + 9aa8e79 commit e480e10

File tree

208 files changed

+21855
-6373
lines changed

Some content is hidden

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

208 files changed

+21855
-6373
lines changed

.editorconfig

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
root = true
2+
3+
[*]
4+
indent_style = space
5+
indent_size = 4
6+
end_of_line = lf
7+
charset = utf-8
8+
trim_trailing_whitespace = true
9+
10+
[*.{md,mdx}]
11+
indent_size = 2
12+
insert_final_newline = true
13+
14+
[*.{js,jsx,mjs,ts,tsx,mts,json}]
15+
indent_size = 4

.eslintrc.js

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

.no-dead-urls.remarkrc.mjs

Lines changed: 44 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -1,38 +1,52 @@
11
import remarkLintNoDeadUrls from 'remark-lint-no-dead-urls'
22

3+
/** @type {import('remark-lint-no-dead-urls').Options} */
4+
const remarkLintNoDeadUrlsOptions = {
5+
from: 'http://localhost:3000',
6+
skipUrlPatterns: [
7+
// can't find the anchor element for the hash
8+
// document is very big and loads slowly
9+
// might be due to a timeout
10+
'/*w3c.github.io*/',
11+
// pexels blocks all requests with a 403 (forbidden) response
12+
'/*pexels.com*/',
13+
// github urls with a hash for the line numbers
14+
// produce the error that the hash can not be found as anchor element
15+
// I do NOT want to disable all of github.com
16+
// disabling all the urls with a line number hash would be ideal but not sure how to do that
17+
// for now I search for /blob/ or /blame/ in the URL and exclude those
18+
'/*/blob/*/',
19+
'/*/blame/*/',
20+
// this page wants to redirect to a url with the language set
21+
// I prefer to use the URL with no language
22+
// so that it adapts to the user's language that will visit
23+
'/*azure.microsoft.com*/',
24+
// npmjs has low rate limit, often returns 429 (too many requests)
25+
'/*npmjs.com*/',
26+
// these domains often produce fetch errors
27+
'/*https://developer.apple.com/*/',
28+
'/*archive.org*/',
29+
// images have /public in their path
30+
// next.js however uses a cached version /_next/image?url=
31+
// for now I exclude them all, future we need something to convert URLs
32+
'/*/public/assets/images*/',
33+
// discord always returns 403 (forbidden)
34+
'/*discord.com*/',
35+
],
36+
deadOrAliveOptions: {
37+
// I will wait 60 seconds for the request to complete
38+
timeout: 60000,
39+
// I will retry 1 times
40+
retries: 1,
41+
// I will wait 60 seconds between retries
42+
retryDelay: 60000,
43+
},
44+
}
45+
346
const config = {
447
plugins: [
548
//[remarkLintNoDeadUrls, { from: 'https://example.com' }]
6-
[remarkLintNoDeadUrls, {
7-
from: 'http://localhost:3000',
8-
skipUrlPatterns: [
9-
// can't find the anchor element for the hash
10-
// document is very big and loads slowly
11-
// might be due to a timeout
12-
'/*w3c.github.io*/',
13-
// pexels blocks all requests with a 403 (forbidden) response
14-
'/*pexels.com*/',
15-
// github urls with a hash for the line numbers
16-
// produce the error that the hash can not be found as anchor element
17-
// I do NOT want to disable all of github.com
18-
// disabling all the urls with a line number hash would be ideal but not sure how to do that
19-
// for now I search for /blob/ in the URL and exclude those
20-
'/*/blob/*/',
21-
// this page wants to redirect to a url with the language set
22-
// I prefer to use the URL with no language
23-
// so that it adapts to the user's language that will visit
24-
'/*azure.microsoft.com*/',
25-
// npmjs has low rate limit, often returns 429 (too many requests)
26-
'/*npmjs.com*/',
27-
// these domains often produce fetch errors
28-
'/*https://developer.apple.com/*/',
29-
'/*archive.org*/',
30-
// images have /public in their path
31-
// next.js however uses a cached version /_next/image?url=
32-
// for now I eclude them all, future we need something to convert URLs
33-
'/*/public/assets/images*/',
34-
]
35-
}]
49+
[remarkLintNoDeadUrls, remarkLintNoDeadUrlsOptions]
3650
]
3751
}
3852

.remarkrc.mjs

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
// presets imports
2-
import remarkPresetLintRecommended from 'remark-preset-lint-consistent'
3-
import remarkPresetLintConsistent from 'remark-preset-lint-recommended'
2+
import remarkPresetLintRecommended from 'remark-preset-lint-recommended'
3+
import remarkPresetLintConsistent from 'remark-preset-lint-consistent'
44
import remarkPresetLintMarkdownStyleGuide from 'remark-preset-lint-markdown-style-guide'
55

66
// rules imports
@@ -10,15 +10,21 @@ import remarkLintNoUndefinedReferences from 'remark-lint-no-undefined-references
1010
import remarkLintLinkTitleStyle from 'remark-lint-link-title-style'
1111
import remarkLintMaximumLineLength from 'remark-lint-maximum-line-length'
1212
import remarkLintListItemSpacing from 'remark-lint-list-item-spacing'
13+
14+
// remark plugins
15+
import remarkGfm from 'remark-gfm'
1316
import remarkFrontmatter from 'remark-frontmatter'
1417

1518
const config = {
1619
plugins: [
17-
// presets
20+
// first the plugins
21+
remarkGfm,
22+
remarkFrontmatter,
23+
// then the presets
1824
remarkPresetLintRecommended,
1925
remarkPresetLintConsistent,
2026
remarkPresetLintMarkdownStyleGuide,
21-
// rules
27+
// and finally the rules customizations
2228
// https://www.npmjs.com/package/remark-lint-maximum-heading-length
2329
[remarkLintMaximumHeadingLength, [1, 100]],
2430
// https://www.npmjs.com/package/remark-lint-unordered-list-marker-style

.vscode/settings.json

Lines changed: 1 addition & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -6,14 +6,7 @@
66
},
77
"eslint.debug": true,
88
"eslint.options": {
9-
"extensions": [
10-
".js",
11-
".jsx",
12-
".md",
13-
".mdx",
14-
".ts",
15-
".tsx"
16-
]
9+
"flags": ["unstable_ts_config"]
1710
},
1811
"eslint.validate": [
1912
"markdown",

README.md

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -18,17 +18,15 @@ On [chris.lu](https://chris.lu), you will find my tutorials and can learn more a
1818

1919
## Technologies used
2020

21-
During the development of the blog, I wrote a ["Next.js static MDX blog" tutorial](https://chris.lu/web_development/tutorials/next-js-static-mdx-blog) that showcases most of the technologies that I used
21+
During the development of the blog, I wrote a ["Next.js static MDX blog" tutorial](https://chris.lu/web-development/tutorials/next-js-static-mdx-blog) that showcases most of the technologies that I used
2222

23-
The framework I used is [Next.js 14](https://github.com/vercel/next.js) with [React 18](https://github.com/facebook/react) (I plan on upgrading to Next.js 15 and React 19 as soon as the first stable versions get released and will update my tutorial accordingly)
23+
The framework I used is [Next.js 15.x](https://github.com/vercel/next.js) with [React 19.x](https://github.com/facebook/react)
2424

25-
I added [MDX](https://mdxjs.com/) support to be able to create content using next/mdx. I then also used several remark and rehype plugins and even built two myself, [rehype-github-alerts
26-
](https://github.com/chrisweb/rehype-github-alerts) and [remark-table-of-contents
27-
](https://github.com/chrisweb/remark-table-of-contents)
25+
I added [MDX](https://mdxjs.com/) support to be able to create content using **@next/mdx**. I then also used several MDX (remark and rehype) plugins and even built two myself, [rehype-github-alerts](https://github.com/chrisweb/rehype-github-alerts) and [remark-table-of-contents](https://github.com/chrisweb/remark-table-of-contents)
2826

2927
I had a lot of fun doing my [WebGL](https://developer.mozilla.org/en-US/docs/Web/API/WebGL_API) header animation using [react-three-fiber](https://github.com/pmndrs/react-three-fiber) (a React renderer for [three.js](https://github.com/mrdoob/three.js))
3028

31-
I also added a jukebox on top using my [web-audio-api-player](https://github.com/chrisweb/web-audio-api-player) and added a dynamic waveform using my [waveform-visualizer](https://github.com/chrisweb/waveform-visualizer) and [waveform-data-generator](https://github.com/chrisweb/waveform-data-generator) packages
29+
I also added a jukebox like music player (on the top right) using my [web-audio-api-player](https://github.com/chrisweb/web-audio-api-player) and added a dynamic waveform using my [waveform-visualizer](https://github.com/chrisweb/waveform-visualizer) and [waveform-data-generator](https://github.com/chrisweb/waveform-data-generator) packages
3230

3331
## Feedback & bug reports
3432

@@ -47,7 +45,11 @@ If you have feedback or want to discuss something, please use the [chris.lu gith
4745
`npm run lint-debug`: linting command but more verbose output
4846
`npm run lint-fix`: linting command that also attempts to automatically fix problems
4947
`npm run info`: the default next.js script to get some info about the project
50-
`npm run check-urls`: check if URLs in documents are alive or not, this linting is seperate from the main linting script so that it can be used sporadically, as it makes lots of calls to 3rd party URLs to check if they are alive, it does not run during the build process so that a unreachable URL of a third party won't break the build
48+
`npm run check-urls`: check if URLs in documents are alive or not, this linting is separate from the main linting script so that it can be used sporadically, as it makes lots of calls to 3rd party URLs to check if they are alive, it does not run during the build process so that a unreachable URL of a third party won't break the build, it is separate from eslint process and uses remark-cli
49+
50+
## Node.js version
51+
52+
Next.js [requires >=18.18.0](https://github.com/vercel/next.js/commit/ecd2be6d3b74d7af2513a8b355408a8f88ec6b25) (same as ESLint v9), Typescript ESLint [requires Node.js >=20.11.0](https://typescript-eslint.io/getting-started/typed-linting) (for import.meta.dirname in ESM files), this projects [package.json](./package.json) has the engines node set to 20.11.0, the latest Node.js LTS is 22.11.0 (Nov. 2024)
5153

5254
## License
5355

app/about_me/opengraph-image.tsx

Lines changed: 13 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -15,26 +15,16 @@ const title = 'About me'
1515

1616
export const alt = `Chris.lu ${title} banner`
1717

18-
/*interface IImageProps {
19-
params: {
20-
slug: string
21-
}
22-
id: number
23-
}*/
24-
2518
// Image generation
26-
export default async function OGImage(/*props: IImageProps*/) {
27-
28-
//console.log(props)
19+
export default async function Image() {
2920

30-
// Font
3121
const permanentMarkerRegular = fetch(
3222
new URL('/public/assets/fonts/PermanentMarker-Regular.ttf', import.meta.url)
33-
).then((res) => res.arrayBuffer())
23+
).then(res => res.arrayBuffer())
3424

3525
const imageData = await fetch(
3626
new URL('/public/assets/images/og_image_background_1200x630.jpg', import.meta.url)
37-
).then((res) => res.arrayBuffer())
27+
).then(res => res.arrayBuffer())
3828

3929
return new ImageResponse(
4030
// ImageResponse JSX element
@@ -48,17 +38,15 @@ export default async function OGImage(/*props: IImageProps*/) {
4838
justifyContent: 'center',
4939
}}
5040
>
51-
{
52-
// eslint-disable-next-line jsx-a11y/alt-text, @next/next/no-img-element
53-
<img
54-
// @ts-ignore: this is fine 🔥
55-
src={imageData}
56-
style={{
57-
objectFit: 'cover',
58-
objectPosition: 'center',
59-
}}
60-
/>
61-
}
41+
{/* eslint-disable-next-line jsx-a11y/alt-text, @next/next/no-img-element */}
42+
<img
43+
// @ts-ignore: this is fine 🔥
44+
src={imageData}
45+
style={{
46+
objectFit: 'cover',
47+
objectPosition: 'center',
48+
}}
49+
/>
6250
<span
6351
style={{
6452
position: 'absolute',
@@ -97,7 +85,7 @@ export default async function OGImage(/*props: IImageProps*/) {
9785
>
9886
{title}
9987
</span>
100-
</div >
88+
</div>
10189
),
10290
// ImageResponse options
10391
{

0 commit comments

Comments
 (0)