mirror of
https://github.com/jakejarvis/jarv.is.git
synced 2025-04-27 07:38:29 -04:00
* gymnastics to make theme script work with react 18 hydration * try next 12.1.3 canary to fix SSG head tags? * revert theme script changes * next 12.1.3-canary.3 * double-revert some of the use-theme.tsx changes * separate theme restoration script & move to _document * bump next * bump next (again) * clean up some theme stuff * use hashed image URLs in webmanifest and feeds * text experimental react config * Update ThemeScript.tsx * switch selfie image to `layout="raw"` * use `layout="raw"` for all non-imported images * revert raw images in some places, messes up responsiveness * fix nitpicky "no divs inside buttons" html validation error * fix react-player hydration errors * fix hydration errors from server/client time zone differences * clean up hydration fixes * Update format-date.ts * last-minute cleanup
97 lines
2.8 KiB
TypeScript
97 lines
2.8 KiB
TypeScript
import { InView } from "react-intersection-observer";
|
|
import { NextSeo, ArticleJsonLd } from "next-seo";
|
|
import { MDXRemote } from "next-mdx-remote";
|
|
import Content from "../../components/Content";
|
|
import NoteMeta from "../../components/NoteMeta";
|
|
import Comments from "../../components/Comments";
|
|
import * as mdxComponents from "../../lib/helpers/mdx-components";
|
|
import { getNote, getNoteSlugs } from "../../lib/helpers/parse-notes";
|
|
import * as config from "../../lib/config";
|
|
import { articleJsonLd } from "../../lib/config/seo";
|
|
import type { GetStaticProps, GetStaticPaths } from "next";
|
|
import type { NoteType } from "../../types";
|
|
|
|
const Note = ({ frontMatter, source }: NoteType) => {
|
|
return (
|
|
<>
|
|
<NextSeo
|
|
title={frontMatter.title}
|
|
description={frontMatter.description}
|
|
canonical={frontMatter.permalink}
|
|
openGraph={{
|
|
title: frontMatter.title,
|
|
url: frontMatter.permalink,
|
|
type: "article",
|
|
article: {
|
|
authors: [config.authorName],
|
|
tags: frontMatter.tags,
|
|
publishedTime: frontMatter.date,
|
|
modifiedTime: frontMatter.date,
|
|
},
|
|
images: frontMatter.image && [
|
|
{
|
|
url: `${config.baseUrl}${frontMatter.image}`,
|
|
alt: frontMatter.title,
|
|
},
|
|
],
|
|
}}
|
|
twitter={{
|
|
cardType: "summary_large_image",
|
|
}}
|
|
/>
|
|
<ArticleJsonLd
|
|
url={frontMatter.permalink}
|
|
title={frontMatter.title}
|
|
description={frontMatter.description}
|
|
datePublished={frontMatter.date}
|
|
dateModified={frontMatter.date}
|
|
images={frontMatter.image && [`${config.baseUrl}${frontMatter.image}`]}
|
|
{...articleJsonLd}
|
|
/>
|
|
|
|
<NoteMeta {...frontMatter} />
|
|
|
|
<Content>
|
|
<MDXRemote
|
|
{...source}
|
|
// @ts-ignore
|
|
components={{ ...mdxComponents }}
|
|
/>
|
|
</Content>
|
|
|
|
{/* comments can be disabled for an individual post via `noComments: true` in its front matter */}
|
|
{!frontMatter.noComments && (
|
|
<InView rootMargin="140px" triggerOnce fallbackInView>
|
|
{({ inView, ref }) => (
|
|
<div id="comments" ref={ref}>
|
|
{inView && <Comments title={frontMatter.title} />}
|
|
</div>
|
|
)}
|
|
</InView>
|
|
)}
|
|
</>
|
|
);
|
|
};
|
|
|
|
export const getStaticProps: GetStaticProps = async ({ params }: { params: Pick<NoteType["frontMatter"], "slug"> }) => {
|
|
const { frontMatter, source } = await getNote(params.slug);
|
|
|
|
return {
|
|
props: {
|
|
frontMatter,
|
|
source,
|
|
},
|
|
};
|
|
};
|
|
|
|
export const getStaticPaths: GetStaticPaths = async () => {
|
|
const paths = getNoteSlugs().map((slug) => ({ params: { slug } }));
|
|
|
|
return {
|
|
paths,
|
|
fallback: false,
|
|
};
|
|
};
|
|
|
|
export default Note;
|