*/} - + {/**/} + {title && {title}} @@ -161,10 +153,8 @@ export default function MdxPage({ children }) { )} - - - - + + {editUrl && ( { + return ( + + + On this page + + { headings.map(({url, title, level}, i) => ( + + + + { title } + + + + ))} + + ) +} diff --git a/site/components/_getIntersectionObserver.js b/site/components/_getIntersectionObserver.js new file mode 100644 index 0000000..51585b7 --- /dev/null +++ b/site/components/_getIntersectionObserver.js @@ -0,0 +1,16 @@ +const getIntersectionObserver = (callback) => { + if (typeof window !== 'undefined') { + return new IntersectionObserver( + (entries) => { + entries.forEach((entry) => { + callback(entry); + }); + }, + { root: null, + rootMargin: `0% 0% -85% 0%` + } + ); + } +}; + +export default getIntersectionObserver; diff --git a/site/components/_getMDXComponents.js b/site/components/_getMDXComponents.js index 3df1846..8f263f0 100644 --- a/site/components/_getMDXComponents.js +++ b/site/components/_getMDXComponents.js @@ -4,16 +4,20 @@ import { Anchor } from './Anchor' import { Heading } from './Heading' -const getMDXComponents = ({ params: { h } }) => ({ +/** + * @param {object} [props] Props passed to each component + * @param {object} [props.h] Props passed to Heading component + */ +const getMDXComponents = (props) => ({ Head, p: Paragraph, a: Anchor, - h1: Heading({ level: 1, ...h }), - h2: Heading({ level: 2, ...h }), - h3: Heading({ level: 3, ...h }), - h4: Heading({ level: 4, ...h }), - h5: Heading({ level: 5, ...h }), - h6: Heading({ level: 6, ...h }), + h1: Heading({ level: 1, ...props?.h }), + h2: Heading({ level: 2, ...props?.h }), + h3: Heading({ level: 3, ...props?.h }), + h4: Heading({ level: 4, ...props?.h }), + h5: Heading({ level: 5, ...props?.h }), + h6: Heading({ level: 6, ...props?.h }), }); export default getMDXComponents; diff --git a/site/contentlayer.config.ts b/site/contentlayer.config.ts index d58d05e..2968885 100644 --- a/site/contentlayer.config.ts +++ b/site/contentlayer.config.ts @@ -64,7 +64,7 @@ export default makeSource({ rehypePlugins: [ rehypeSlug, rehypeAutolinkHeadings, - [ rehypeToc, { position: 'beforeend' } ] + [ rehypeToc, { position: 'afterend' } ] ] } }) diff --git a/site/styles/global.css b/site/styles/global.css index e965e61..e6e1c74 100644 --- a/site/styles/global.css +++ b/site/styles/global.css @@ -13,7 +13,7 @@ /* OTHERS */ html { - scroll-behavior: smooth; + /* scroll-behavior: smooth; */ } /* bg-neutral-800 @@ -39,23 +39,30 @@ body { background: linear-gradient(to right, rgba(255, 255, 255, 0), rgba(255, 255, 255, 1) 100%); } -/* rehype-toc plugin classes */ +/* rehype-toc classes */ .toc { - @apply hidden lg:block w-[16rem] p-8 pt-14 fixed top-16 bottom-0 right-[max(0px,50%-40rem)] overflow-y-auto border-2 border-blue-500; + @apply + hidden + lg:block + w-[22rem] + p-12 /* 1.5rem */ + pl-12 + py-24 + fixed + top-16 + /* bottom-0 */ + right-[max(2rem,calc(50%-40rem+2rem))] + overflow-y-auto } .toc::before { position: absolute; content: "On this page"; - top: 1.5rem; - line-height: 1.125rem; - color: white; - font-size: 1.125rem; - font-weight: bold; + @apply text-white text-xl font-semibold top-12 } .toc-item { - @apply leading-5; + @apply leading-3; } .toc-item-h1 { @@ -71,7 +78,11 @@ body { } .toc-item .toc-link { - @apply text-sm text-slate-400 hover:text-white no-underline break-normal + @apply text-sm text-slate-400 no-underline break-normal +} + +.toc-item .toc-link:not(.active) { + @apply hover:text-white } .toc-link.active {
+ {/**/} + {title && {title}} @@ -161,10 +153,8 @@ export default function MdxPage({ children }) { )} - - - - + + {editUrl && ( { + return ( + + + On this page + + { headings.map(({url, title, level}, i) => ( + + + + { title } + + + + ))} + + ) +} diff --git a/site/components/_getIntersectionObserver.js b/site/components/_getIntersectionObserver.js new file mode 100644 index 0000000..51585b7 --- /dev/null +++ b/site/components/_getIntersectionObserver.js @@ -0,0 +1,16 @@ +const getIntersectionObserver = (callback) => { + if (typeof window !== 'undefined') { + return new IntersectionObserver( + (entries) => { + entries.forEach((entry) => { + callback(entry); + }); + }, + { root: null, + rootMargin: `0% 0% -85% 0%` + } + ); + } +}; + +export default getIntersectionObserver; diff --git a/site/components/_getMDXComponents.js b/site/components/_getMDXComponents.js index 3df1846..8f263f0 100644 --- a/site/components/_getMDXComponents.js +++ b/site/components/_getMDXComponents.js @@ -4,16 +4,20 @@ import { Anchor } from './Anchor' import { Heading } from './Heading' -const getMDXComponents = ({ params: { h } }) => ({ +/** + * @param {object} [props] Props passed to each component + * @param {object} [props.h] Props passed to Heading component + */ +const getMDXComponents = (props) => ({ Head, p: Paragraph, a: Anchor, - h1: Heading({ level: 1, ...h }), - h2: Heading({ level: 2, ...h }), - h3: Heading({ level: 3, ...h }), - h4: Heading({ level: 4, ...h }), - h5: Heading({ level: 5, ...h }), - h6: Heading({ level: 6, ...h }), + h1: Heading({ level: 1, ...props?.h }), + h2: Heading({ level: 2, ...props?.h }), + h3: Heading({ level: 3, ...props?.h }), + h4: Heading({ level: 4, ...props?.h }), + h5: Heading({ level: 5, ...props?.h }), + h6: Heading({ level: 6, ...props?.h }), }); export default getMDXComponents; diff --git a/site/contentlayer.config.ts b/site/contentlayer.config.ts index d58d05e..2968885 100644 --- a/site/contentlayer.config.ts +++ b/site/contentlayer.config.ts @@ -64,7 +64,7 @@ export default makeSource({ rehypePlugins: [ rehypeSlug, rehypeAutolinkHeadings, - [ rehypeToc, { position: 'beforeend' } ] + [ rehypeToc, { position: 'afterend' } ] ] } }) diff --git a/site/styles/global.css b/site/styles/global.css index e965e61..e6e1c74 100644 --- a/site/styles/global.css +++ b/site/styles/global.css @@ -13,7 +13,7 @@ /* OTHERS */ html { - scroll-behavior: smooth; + /* scroll-behavior: smooth; */ } /* bg-neutral-800 @@ -39,23 +39,30 @@ body { background: linear-gradient(to right, rgba(255, 255, 255, 0), rgba(255, 255, 255, 1) 100%); } -/* rehype-toc plugin classes */ +/* rehype-toc classes */ .toc { - @apply hidden lg:block w-[16rem] p-8 pt-14 fixed top-16 bottom-0 right-[max(0px,50%-40rem)] overflow-y-auto border-2 border-blue-500; + @apply + hidden + lg:block + w-[22rem] + p-12 /* 1.5rem */ + pl-12 + py-24 + fixed + top-16 + /* bottom-0 */ + right-[max(2rem,calc(50%-40rem+2rem))] + overflow-y-auto } .toc::before { position: absolute; content: "On this page"; - top: 1.5rem; - line-height: 1.125rem; - color: white; - font-size: 1.125rem; - font-weight: bold; + @apply text-white text-xl font-semibold top-12 } .toc-item { - @apply leading-5; + @apply leading-3; } .toc-item-h1 { @@ -71,7 +78,11 @@ body { } .toc-item .toc-link { - @apply text-sm text-slate-400 hover:text-white no-underline break-normal + @apply text-sm text-slate-400 no-underline break-normal +} + +.toc-item .toc-link:not(.active) { + @apply hover:text-white } .toc-link.active {
*/} + {title && {title}} @@ -161,10 +153,8 @@ export default function MdxPage({ children }) { )} - - - - + + {editUrl && ( { + return ( + + + On this page + + { headings.map(({url, title, level}, i) => ( + + + + { title } + + + + ))} + + ) +} diff --git a/site/components/_getIntersectionObserver.js b/site/components/_getIntersectionObserver.js new file mode 100644 index 0000000..51585b7 --- /dev/null +++ b/site/components/_getIntersectionObserver.js @@ -0,0 +1,16 @@ +const getIntersectionObserver = (callback) => { + if (typeof window !== 'undefined') { + return new IntersectionObserver( + (entries) => { + entries.forEach((entry) => { + callback(entry); + }); + }, + { root: null, + rootMargin: `0% 0% -85% 0%` + } + ); + } +}; + +export default getIntersectionObserver; diff --git a/site/components/_getMDXComponents.js b/site/components/_getMDXComponents.js index 3df1846..8f263f0 100644 --- a/site/components/_getMDXComponents.js +++ b/site/components/_getMDXComponents.js @@ -4,16 +4,20 @@ import { Anchor } from './Anchor' import { Heading } from './Heading' -const getMDXComponents = ({ params: { h } }) => ({ +/** + * @param {object} [props] Props passed to each component + * @param {object} [props.h] Props passed to Heading component + */ +const getMDXComponents = (props) => ({ Head, p: Paragraph, a: Anchor, - h1: Heading({ level: 1, ...h }), - h2: Heading({ level: 2, ...h }), - h3: Heading({ level: 3, ...h }), - h4: Heading({ level: 4, ...h }), - h5: Heading({ level: 5, ...h }), - h6: Heading({ level: 6, ...h }), + h1: Heading({ level: 1, ...props?.h }), + h2: Heading({ level: 2, ...props?.h }), + h3: Heading({ level: 3, ...props?.h }), + h4: Heading({ level: 4, ...props?.h }), + h5: Heading({ level: 5, ...props?.h }), + h6: Heading({ level: 6, ...props?.h }), }); export default getMDXComponents; diff --git a/site/contentlayer.config.ts b/site/contentlayer.config.ts index d58d05e..2968885 100644 --- a/site/contentlayer.config.ts +++ b/site/contentlayer.config.ts @@ -64,7 +64,7 @@ export default makeSource({ rehypePlugins: [ rehypeSlug, rehypeAutolinkHeadings, - [ rehypeToc, { position: 'beforeend' } ] + [ rehypeToc, { position: 'afterend' } ] ] } }) diff --git a/site/styles/global.css b/site/styles/global.css index e965e61..e6e1c74 100644 --- a/site/styles/global.css +++ b/site/styles/global.css @@ -13,7 +13,7 @@ /* OTHERS */ html { - scroll-behavior: smooth; + /* scroll-behavior: smooth; */ } /* bg-neutral-800 @@ -39,23 +39,30 @@ body { background: linear-gradient(to right, rgba(255, 255, 255, 0), rgba(255, 255, 255, 1) 100%); } -/* rehype-toc plugin classes */ +/* rehype-toc classes */ .toc { - @apply hidden lg:block w-[16rem] p-8 pt-14 fixed top-16 bottom-0 right-[max(0px,50%-40rem)] overflow-y-auto border-2 border-blue-500; + @apply + hidden + lg:block + w-[22rem] + p-12 /* 1.5rem */ + pl-12 + py-24 + fixed + top-16 + /* bottom-0 */ + right-[max(2rem,calc(50%-40rem+2rem))] + overflow-y-auto } .toc::before { position: absolute; content: "On this page"; - top: 1.5rem; - line-height: 1.125rem; - color: white; - font-size: 1.125rem; - font-weight: bold; + @apply text-white text-xl font-semibold top-12 } .toc-item { - @apply leading-5; + @apply leading-3; } .toc-item-h1 { @@ -71,7 +78,11 @@ body { } .toc-item .toc-link { - @apply text-sm text-slate-400 hover:text-white no-underline break-normal + @apply text-sm text-slate-400 no-underline break-normal +} + +.toc-item .toc-link:not(.active) { + @apply hover:text-white } .toc-link.active {
{title && {title}} @@ -161,10 +153,8 @@ export default function MdxPage({ children }) { )} - - - - + + {editUrl && ( { + return ( + + + On this page + + { headings.map(({url, title, level}, i) => ( + + + + { title } + + + + ))} + + ) +} diff --git a/site/components/_getIntersectionObserver.js b/site/components/_getIntersectionObserver.js new file mode 100644 index 0000000..51585b7 --- /dev/null +++ b/site/components/_getIntersectionObserver.js @@ -0,0 +1,16 @@ +const getIntersectionObserver = (callback) => { + if (typeof window !== 'undefined') { + return new IntersectionObserver( + (entries) => { + entries.forEach((entry) => { + callback(entry); + }); + }, + { root: null, + rootMargin: `0% 0% -85% 0%` + } + ); + } +}; + +export default getIntersectionObserver; diff --git a/site/components/_getMDXComponents.js b/site/components/_getMDXComponents.js index 3df1846..8f263f0 100644 --- a/site/components/_getMDXComponents.js +++ b/site/components/_getMDXComponents.js @@ -4,16 +4,20 @@ import { Anchor } from './Anchor' import { Heading } from './Heading' -const getMDXComponents = ({ params: { h } }) => ({ +/** + * @param {object} [props] Props passed to each component + * @param {object} [props.h] Props passed to Heading component + */ +const getMDXComponents = (props) => ({ Head, p: Paragraph, a: Anchor, - h1: Heading({ level: 1, ...h }), - h2: Heading({ level: 2, ...h }), - h3: Heading({ level: 3, ...h }), - h4: Heading({ level: 4, ...h }), - h5: Heading({ level: 5, ...h }), - h6: Heading({ level: 6, ...h }), + h1: Heading({ level: 1, ...props?.h }), + h2: Heading({ level: 2, ...props?.h }), + h3: Heading({ level: 3, ...props?.h }), + h4: Heading({ level: 4, ...props?.h }), + h5: Heading({ level: 5, ...props?.h }), + h6: Heading({ level: 6, ...props?.h }), }); export default getMDXComponents; diff --git a/site/contentlayer.config.ts b/site/contentlayer.config.ts index d58d05e..2968885 100644 --- a/site/contentlayer.config.ts +++ b/site/contentlayer.config.ts @@ -64,7 +64,7 @@ export default makeSource({ rehypePlugins: [ rehypeSlug, rehypeAutolinkHeadings, - [ rehypeToc, { position: 'beforeend' } ] + [ rehypeToc, { position: 'afterend' } ] ] } }) diff --git a/site/styles/global.css b/site/styles/global.css index e965e61..e6e1c74 100644 --- a/site/styles/global.css +++ b/site/styles/global.css @@ -13,7 +13,7 @@ /* OTHERS */ html { - scroll-behavior: smooth; + /* scroll-behavior: smooth; */ } /* bg-neutral-800 @@ -39,23 +39,30 @@ body { background: linear-gradient(to right, rgba(255, 255, 255, 0), rgba(255, 255, 255, 1) 100%); } -/* rehype-toc plugin classes */ +/* rehype-toc classes */ .toc { - @apply hidden lg:block w-[16rem] p-8 pt-14 fixed top-16 bottom-0 right-[max(0px,50%-40rem)] overflow-y-auto border-2 border-blue-500; + @apply + hidden + lg:block + w-[22rem] + p-12 /* 1.5rem */ + pl-12 + py-24 + fixed + top-16 + /* bottom-0 */ + right-[max(2rem,calc(50%-40rem+2rem))] + overflow-y-auto } .toc::before { position: absolute; content: "On this page"; - top: 1.5rem; - line-height: 1.125rem; - color: white; - font-size: 1.125rem; - font-weight: bold; + @apply text-white text-xl font-semibold top-12 } .toc-item { - @apply leading-5; + @apply leading-3; } .toc-item-h1 { @@ -71,7 +78,11 @@ body { } .toc-item .toc-link { - @apply text-sm text-slate-400 hover:text-white no-underline break-normal + @apply text-sm text-slate-400 no-underline break-normal +} + +.toc-item .toc-link:not(.active) { + @apply hover:text-white } .toc-link.active {