feat: add heading anchor links
This commit is contained in:
1 parent
e403677a71
commit
bf8e78d0ba
4 files changed
+87
No files matched your search
@@ -129,4 +129,30 @@ figure[data-rehype-pretty-code-figure] pre {
|
||||
overflow-x: auto;
|
||||
font-size: 0.875rem;
|
||||
line-height: 1.7;
|
||||
}
|
||||
|
||||
h1, h2, h3, h4, h5, h6 {
|
||||
scroll-margin-top: 5rem; /* <-- Höhe deines Headers + etwas Abstand */
|
||||
}
|
||||
|
||||
html {
|
||||
scroll-behavior: smooth;
|
||||
}
|
||||
|
||||
/* Anchor-Link Styling */
|
||||
.heading-anchor {
|
||||
opacity: 0;
|
||||
margin-right: 1em; /* Abstand zum nachfolgenden Text */
|
||||
color: #3b82f6; /* Tailwind blue-500 */
|
||||
text-decoration: none;
|
||||
font-weight: 800;
|
||||
transition: opacity 0.15s ease-in-out;
|
||||
}
|
||||
|
||||
h1:hover .heading-anchor,
|
||||
h2:hover .heading-anchor,
|
||||
h3:hover .heading-anchor,
|
||||
h4:hover .heading-anchor,
|
||||
.heading-anchor:focus {
|
||||
opacity: 1;
|
||||
}
|
||||
@@ -2,11 +2,29 @@ import { getWikiPageBySlug } from '@/lib/wiki';
|
||||
import { notFound } from 'next/navigation';
|
||||
import { MDXRemote } from 'next-mdx-remote/rsc';
|
||||
import rehypePrettyCode from 'rehype-pretty-code';
|
||||
import rehypeSlug from 'rehype-slug';
|
||||
import rehypeAutolinkHeadings from 'rehype-autolink-headings';
|
||||
import { Callout, Grid, Card, Steps, Step, InlineCode, CodeBlockContainer } from '@/components/mdx-components';
|
||||
|
||||
const mdxOptions = {
|
||||
mdxOptions: {
|
||||
rehypePlugins: [
|
||||
rehypeSlug, // creates heading-ids automaticly
|
||||
[
|
||||
rehypeAutolinkHeadings,
|
||||
{
|
||||
behavior: 'prepend', // symbol is PRE header
|
||||
properties: {
|
||||
className: ['heading-anchor'],
|
||||
ariaHidden: 'true',
|
||||
tabIndex: -1,
|
||||
},
|
||||
content: {
|
||||
type: 'text',
|
||||
value: ' #', // symbol
|
||||
},
|
||||
},
|
||||
],
|
||||
[
|
||||
rehypePrettyCode,
|
||||
{
|
||||
|
||||
Reference in new issue
Block a user