-
-
+
+
{editUrl && (
{
+ const customComponents = {
+ Head,
+ p: Paragraph,
+ a: Anchor,
+ h1: Heading({ level: 1, observer }),
+ h2: Heading({ level: 2, observer }),
+ h3: Heading({ level: 3, observer }),
+ h4: Heading({ level: 4, observer }),
+ h5: Heading({ level: 5, observer }),
+ h6: Heading({ level: 6, observer }),
+ }
+ const Component = useMDXComponent(body.code);
+
+ return
+};
+
+export default React.memo(MdxContent);
diff --git a/site/components/_getIntersectionObserver.js b/site/components/_getIntersectionObserver.js
index edbadd4..2be2208 100644
--- a/site/components/_getIntersectionObserver.js
+++ b/site/components/_getIntersectionObserver.js
@@ -1,22 +1,16 @@
const getIntersectionObserver = (callback) => {
- if (typeof window !== 'undefined') {
- return new IntersectionObserver(
- (entries) => {
- const intersectingEntries = entries.filter((e) => e.isIntersecting);
- const firstEntry = intersectingEntries[0];
- if (firstEntry) {
- callback(firstEntry);
- }
- // entries.forEach((entry) => {
- // callback(entry);
- // });
- },
- { root: null,
- threshold: 0.9,
- rootMargin: `0% 0% -90% 0%`
- }
- );
- }
+ return new IntersectionObserver(
+ (entries) => {
+ entries.forEach((entry) => {
+ callback(entry);
+ });
+ },
+ {
+ root: null,
+ // 65px is a navbar height
+ rootMargin: `-65px 0% -90% 0%`
+ }
+ );
};
export default getIntersectionObserver;
diff --git a/site/components/_getMDXComponents.js b/site/components/_getMDXComponents.js
deleted file mode 100644
index 8f263f0..0000000
--- a/site/components/_getMDXComponents.js
+++ /dev/null
@@ -1,23 +0,0 @@
-import Head from 'next/head'
-import { Paragraph } from './Paragraph'
-import { Anchor } from './Anchor'
-import { Heading } from './Heading'
-
-
-/**
- * @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, ...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/pages/[...slug].js b/site/pages/[...slug].js
index 32329e3..b2754d4 100644
--- a/site/pages/[...slug].js
+++ b/site/pages/[...slug].js
@@ -1,19 +1,23 @@
-import MdxPage from "../components/MDX";
-import { allOtherPages } from "contentlayer/generated";
-import { useMDXComponent } from "next-contentlayer/hooks";
+import { allOtherPages } from 'contentlayer/generated';
-import siteConfig from "../config/siteConfig";
+import MdxPage from '../components/MDX';
+import siteConfig from "../config/siteConfig"
-export default function Page({ body, ...rest }) {
- const Component = useMDXComponent(body.code);
- const children = {
- Component,
- frontmatter: {
- ...rest,
- },
- };
+export default function Page({ body, ...meta }) {
+ const frontMatter = {
+ ...meta,
+ date: meta.date === "Invalid Date" ? null : meta.date,
+ created: meta.created === "Invalid Date" ? null : meta.created
+ }
- return ;
+ // enable editing content only for claims, concepts, and guide for now
+ const editUrl = ['claims', 'concepts', 'guide'].includes(meta._raw.sourceFileDir)
+ ? siteConfig.repoRoot + siteConfig.repoEditPath + meta._raw.sourceFilePath
+ : null
+
+ return (
+
+ );
}
export const getStaticProps = async ({ params }) => {
diff --git a/site/styles/global.css b/site/styles/global.css
index 929940b..ff720b0 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
@@ -40,36 +40,32 @@ body {
}
/* rehype-toc classes */
+/* nav element */
.toc {
@apply
hidden
lg:block
w-[20rem]
+ my-12
+ pt-12
px-8
- py-24
fixed
top-16
- /* bottom-0 */
+ bottom-0
right-[max(2rem,calc(50%-40rem+2rem))]
overflow-y-auto
- border-2
- border-red-500
+ border-l
+ border-slate-800
}
+/* toc title */
.toc::before {
position: absolute;
content: "On this page";
- @apply text-white text-xl font-semibold top-12
-}
-
-.toc-item {
- @apply leading-3;
-}
-
-.toc-item-h1 {
- @apply p-0;
+ @apply text-white text-xl font-semibold top-1
}
+/* list (ol) element */
.toc-level {
@apply list-none p-0;
}
@@ -78,6 +74,20 @@ body {
@apply pl-2
}
+/* list item (li) element */
+.toc-item {
+ @apply leading-3;
+}
+
+.toc-item-h1 {
+ @apply p-0;
+}
+
+.toc-link {
+ @apply transition-colors;
+}
+
+/* link (a) element */
.toc-item .toc-link {
@apply text-sm text-slate-400 no-underline break-normal
}