Skip to content

Commit 558b643

Browse files
committed
Fix TOC links with invalid querySelector
1 parent 3e78a87 commit 558b643

File tree

6 files changed

+7
-23
lines changed

6 files changed

+7
-23
lines changed

astro.config.mjs

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,6 @@ import { defineConfig } from 'astro/config'
33
import tailwindcss from '@tailwindcss/vite'
44
import sitemap from '@astrojs/sitemap'
55
import mdx from '@astrojs/mdx'
6-
import rehypeSlug from 'rehype-slug'
76
import rehypeAutolinkHeadings from 'rehype-autolink-headings'
87
import expressiveCode from 'astro-expressive-code'
98
import siteConfig from './src/site.config'
@@ -39,7 +38,6 @@ export default defineConfig({
3938
remarkGemoji,
4039
],
4140
rehypePlugins: [
42-
rehypeSlug,
4341
[
4442
rehypeAutolinkHeadings,
4543
{

package-lock.json

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

package.json

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,6 @@
4242
"rehype-autolink-headings": "^7.1.0",
4343
"rehype-external-links": "^3.0.0",
4444
"rehype-katex": "^7.0.1",
45-
"rehype-slug": "^6.0.0",
4645
"rehype-unwrap-images": "^1.0.0",
4746
"remark-directive": "^4.0.0",
4847
"remark-math": "^6.0.0",

src/components/TableOfContents.astro

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,8 @@ const toc = generateToc(headings)
5959
e.preventDefault()
6060
const href = anchor.getAttribute('href')
6161
if (!href) return
62-
document.querySelector(href)?.scrollIntoView({
62+
const id = href.startsWith('#') ? href.slice(1) : href
63+
document.getElementById(id)?.scrollIntoView({
6364
behavior: 'smooth',
6465
})
6566
})

src/content/posts/advanced-typescript-conditional-types.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,10 @@ tags: ['typescript']
1010
echo "Exploring advanced TypeScript features like conditional types"
1111
```
1212

13+
## 3 Test
14+
15+
## #test
16+
1317
Conditional types in TypeScript allow you to create types based on conditions. Here's an example:
1418

1519
```typescript

src/pages/posts/[slug].astro

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,7 @@ if (addendum.length > 0) {
5555
/>
5656
)
5757
}
58-
<h1 class="mb-3 text-3xl text-[var(--theme-h1)] font-semibold">
58+
<h1 class="mb-3 text-2xl text-[var(--theme-h1)] font-semibold">
5959
# {postData.title}
6060
</h1>
6161
<div class="text-foreground/80 mb-2.5">

0 commit comments

Comments
 (0)