Skip to content

Commit 17cb335

Browse files
committed
error resolve
1 parent 973d3cc commit 17cb335

File tree

4 files changed

+102
-91
lines changed

4 files changed

+102
-91
lines changed

package-lock.json

Lines changed: 53 additions & 54 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/components/TableOfContents.tsx

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,8 +11,10 @@ interface Heading {
1111
export default function TableOfContents() {
1212
const [headings, setHeadings] = useState<Heading[]>([]);
1313
const [activeId, setActiveId] = useState<string>('');
14+
const [mounted, setMounted] = useState(false);
1415

1516
useEffect(() => {
17+
setMounted(true);
1618
const elements = Array.from(document.querySelectorAll('h2, h3, h4'));
1719
const items = elements.map((element) => ({
1820
id: element.id,
@@ -36,7 +38,7 @@ export default function TableOfContents() {
3638
return () => observer.disconnect();
3739
}, []);
3840

39-
if (headings.length === 0) return null;
41+
if (!mounted || headings.length === 0) return null;
4042

4143
return (
4244
<nav className="sticky top-24 max-h-[calc(100vh-6rem)] overflow-auto p-4 rounded-lg bg-base-200">
Lines changed: 14 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,18 @@
1+
import { makeSource } from 'contentlayer/source-files';
2+
import rehypeAutolinkHeadings from 'rehype-autolink-headings';
3+
import rehypeSlug from 'rehype-slug';
4+
15
// <-- Direct path specification
26

37
const regXHN = /\n(?<flag>#{1,6})\s+(?<content>.+)/g; //! For headings 1-6
48

5-
rehypeSlug, // Add id to heading
6-
7-
rehypeAutolinkHeadings, // Create anchor through id
9+
export default makeSource({
10+
contentDirPath: 'posts',
11+
documentTypes: [],
12+
mdx: {
13+
rehypePlugins: [
14+
rehypeSlug, // Add id to heading
15+
[rehypeAutolinkHeadings, { behavior: 'wrap' }], // Create anchor through id
16+
],
17+
},
18+
});

yarn.lock

Lines changed: 32 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -546,22 +546,22 @@
546546
unist-util-visit "^4.0.0"
547547
vfile "^5.0.0"
548548

549-
"@next/env@14.0.4":
550-
version "14.0.4"
551-
resolved "https://registry.npmjs.org/@next/env/-/env-14.0.4.tgz"
552-
integrity sha512-irQnbMLbUNQpP1wcE5NstJtbuA/69kRfzBrpAD7Gsn8zm/CY6YQYc3HQBz8QPxwISG26tIm5afvvVbu508oBeQ==
549+
"@next/env@13.5.11":
550+
version "13.5.11"
551+
resolved "https://registry.npmjs.org/@next/env/-/env-13.5.11.tgz"
552+
integrity sha512-fbb2C7HChgM7CemdCY+y3N1n8pcTKdqtQLbC7/EQtPdLvlMUT9JX/dBYl8MMZAtYG4uVMyPFHXckb68q/NRwqg==
553553

554-
"@next/eslint-plugin-next@14.0.4":
555-
version "14.0.4"
556-
resolved "https://registry.npmjs.org/@next/eslint-plugin-next/-/eslint-plugin-next-14.0.4.tgz"
557-
integrity sha512-U3qMNHmEZoVmHA0j/57nRfi3AscXNvkOnxDmle/69Jz/G0o/gWjXTDdlgILZdrxQ0Lw/jv2mPW8PGy0EGIHXhQ==
554+
"@next/eslint-plugin-next@13.5.11":
555+
version "13.5.11"
556+
resolved "https://registry.npmjs.org/@next/eslint-plugin-next/-/eslint-plugin-next-13.5.11.tgz"
557+
integrity sha512-0qjDhes9UTSxirt/dYzrv20hs8SUhcIOvlEioj5+XucVrBHihnAk6Om7Vzk+VZ2nRE7tcShm/6lH1xSkJ3XMpg==
558558
dependencies:
559559
glob "7.1.7"
560560

561-
"@next/swc-win32-x64-msvc@14.0.4":
562-
version "14.0.4"
563-
resolved "https://registry.npmjs.org/@next/swc-win32-x64-msvc/-/swc-win32-x64-msvc-14.0.4.tgz"
564-
integrity sha512-yEh2+R8qDlDCjxVpzOTEpBLQTEFAcP2A8fUFLaWNap9GitYKkKv1//y2S6XY6zsR4rCOPRpU7plYDR+az2n30A==
561+
"@next/swc-win32-x64-msvc@13.5.9":
562+
version "13.5.9"
563+
resolved "https://registry.npmjs.org/@next/swc-win32-x64-msvc/-/swc-win32-x64-msvc-13.5.9.tgz"
564+
integrity sha512-/72/dZfjXXNY/u+n8gqZDjI6rxKMpYsgBBYNZKWOQw0BpBF7WCnPflRy3ZtvQ2+IYI3ZH2bPyj7K+6a6wNk90Q==
565565

566566
"@nodelib/fs.scandir@2.1.5":
567567
version "2.1.5"
@@ -1773,12 +1773,12 @@ escape-string-regexp@^5.0.0:
17731773
resolved "https://registry.npmjs.org/escape-string-regexp/-/escape-string-regexp-5.0.0.tgz"
17741774
integrity sha512-/veY75JbMK4j1yjvuUxuVsiS/hr/4iHs9FTT6cgTexxdE0Ly/glccBAkloH/DofkjRbZU3bnoj38mOmhkZ0lHw==
17751775

1776-
eslint-config-next@14.0.4:
1777-
version "14.0.4"
1778-
resolved "https://registry.npmjs.org/eslint-config-next/-/eslint-config-next-14.0.4.tgz"
1779-
integrity sha512-9/xbOHEQOmQtqvQ1UsTQZpnA7SlDMBtuKJ//S4JnoyK3oGLhILKXdBgu/UO7lQo/2xOykQULS1qQ6p2+EpHgAQ==
1776+
eslint-config-next@13.5.11:
1777+
version "13.5.11"
1778+
resolved "https://registry.npmjs.org/eslint-config-next/-/eslint-config-next-13.5.11.tgz"
1779+
integrity sha512-jImZvfc4htMMsiW3nCY/UOxXrI4DbEI4JrdWOEfSNkMipi4j3ZukUhvv4TGQnP6d6lvPTh6uHisQbMl3Ozga1w==
17801780
dependencies:
1781-
"@next/eslint-plugin-next" "14.0.4"
1781+
"@next/eslint-plugin-next" "13.5.11"
17821782
"@rushstack/eslint-patch" "^1.3.3"
17831783
"@typescript-eslint/parser" "^5.4.2 || ^6.0.0"
17841784
eslint-import-resolver-node "^0.3.6"
@@ -2302,7 +2302,7 @@ gopd@^1.0.1:
23022302
dependencies:
23032303
get-intrinsic "^1.1.3"
23042304

2305-
graceful-fs@^4.1.2, graceful-fs@^4.2.11, graceful-fs@^4.2.4:
2305+
graceful-fs@^4.1.2, graceful-fs@^4.2.4:
23062306
version "4.2.11"
23072307
resolved "https://registry.npmjs.org/graceful-fs/-/graceful-fs-4.2.11.tgz"
23082308
integrity sha512-RbJ5/jmFcNNCcDV5o9eTnBLJ/HszWV0P73bc+Ff4nS/rJj+YaS6IGyiOL0VoBYX+l1Wrl3k63h/KrH+nhJ0XvQ==
@@ -3798,29 +3798,28 @@ next-themes@^0.2.1:
37983798
resolved "https://registry.npmjs.org/next-themes/-/next-themes-0.2.1.tgz"
37993799
integrity sha512-B+AKNfYNIzh0vqQQKqQItTS8evEouKD7H5Hj3kmuPERwddR2TxvDSFZuTj6T7Jfn1oyeUyJMydPl1Bkxkh0W7A==
38003800

3801-
next@*, "next@^12 || ^13", next@14.0.4:
3802-
version "14.0.4"
3803-
resolved "https://registry.npmjs.org/next/-/next-14.0.4.tgz"
3804-
integrity sha512-qbwypnM7327SadwFtxXnQdGiKpkuhaRLE2uq62/nRul9cj9KhQ5LhHmlziTNqUidZotw/Q1I9OjirBROdUJNgA==
3801+
next@*, "next@^12 || ^13", next@13.5.11:
3802+
version "13.5.11"
3803+
resolved "https://registry.npmjs.org/next/-/next-13.5.11.tgz"
3804+
integrity sha512-WUPJ6WbAX9tdC86kGTu92qkrRdgRqVrY++nwM+shmWQwmyxt4zhZfR59moXSI4N8GDYCBY3lIAqhzjDd4rTC8Q==
38053805
dependencies:
3806-
"@next/env" "14.0.4"
3806+
"@next/env" "13.5.11"
38073807
"@swc/helpers" "0.5.2"
38083808
busboy "1.6.0"
38093809
caniuse-lite "^1.0.30001406"
3810-
graceful-fs "^4.2.11"
38113810
postcss "8.4.31"
38123811
styled-jsx "5.1.1"
38133812
watchpack "2.4.0"
38143813
optionalDependencies:
3815-
"@next/swc-darwin-arm64" "14.0.4"
3816-
"@next/swc-darwin-x64" "14.0.4"
3817-
"@next/swc-linux-arm64-gnu" "14.0.4"
3818-
"@next/swc-linux-arm64-musl" "14.0.4"
3819-
"@next/swc-linux-x64-gnu" "14.0.4"
3820-
"@next/swc-linux-x64-musl" "14.0.4"
3821-
"@next/swc-win32-arm64-msvc" "14.0.4"
3822-
"@next/swc-win32-ia32-msvc" "14.0.4"
3823-
"@next/swc-win32-x64-msvc" "14.0.4"
3814+
"@next/swc-darwin-arm64" "13.5.9"
3815+
"@next/swc-darwin-x64" "13.5.9"
3816+
"@next/swc-linux-arm64-gnu" "13.5.9"
3817+
"@next/swc-linux-arm64-musl" "13.5.9"
3818+
"@next/swc-linux-x64-gnu" "13.5.9"
3819+
"@next/swc-linux-x64-musl" "13.5.9"
3820+
"@next/swc-win32-arm64-msvc" "13.5.9"
3821+
"@next/swc-win32-ia32-msvc" "13.5.9"
3822+
"@next/swc-win32-x64-msvc" "13.5.9"
38243823

38253824
no-case@^3.0.4:
38263825
version "3.0.4"

0 commit comments

Comments
 (0)