mirror of
https://github.com/jakejarvis/jarv.is.git
synced 2025-10-26 01:05:49 -04:00
organize types a bit more sanely & bump deps
This commit is contained in:
@@ -4,7 +4,6 @@ import { MDXRemote } from "next-mdx-remote";
|
||||
import { htmlEscape } from "escape-goat";
|
||||
import Content from "../../components/Content/Content";
|
||||
import NoteMeta from "../../components/NoteMeta/NoteMeta";
|
||||
import NoteTitle from "../../components/NoteTitle/NoteTitle";
|
||||
import Comments from "../../components/Comments/Comments";
|
||||
import * as mdxComponents from "../../lib/mdx-components";
|
||||
import { getNote, getNoteSlugs } from "../../lib/parse-notes";
|
||||
@@ -51,15 +50,15 @@ const Note = ({ frontMatter, source }: NoteType) => {
|
||||
{...articleJsonLd}
|
||||
/>
|
||||
|
||||
<NoteMeta slug={frontMatter.slug} date={frontMatter.date} title={frontMatter.title} tags={frontMatter.tags} />
|
||||
<NoteTitle slug={frontMatter.slug} htmlTitle={frontMatter.htmlTitle} />
|
||||
<NoteMeta {...frontMatter} />
|
||||
|
||||
<Content>
|
||||
{/* @ts-ignore */}
|
||||
<MDXRemote {...source} components={{ ...mdxComponents }} />
|
||||
</Content>
|
||||
|
||||
{frontMatter.noComments !== true && (
|
||||
{/* 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}>
|
||||
@@ -72,8 +71,8 @@ const Note = ({ frontMatter, source }: NoteType) => {
|
||||
);
|
||||
};
|
||||
|
||||
export const getStaticProps: GetStaticProps = async ({ params }) => {
|
||||
const { frontMatter, source } = await getNote(params.slug as string);
|
||||
export const getStaticProps: GetStaticProps = async ({ params }: { params: Pick<NoteType["frontMatter"], "slug"> }) => {
|
||||
const { frontMatter, source } = await getNote(params.slug);
|
||||
|
||||
return {
|
||||
props: {
|
||||
|
||||
@@ -1,11 +1,11 @@
|
||||
import { NextSeo } from "next-seo";
|
||||
import { format } from "date-fns";
|
||||
import Content from "../../components/Content/Content";
|
||||
import NotesList from "../../components/NotesList/NotesList";
|
||||
import NotesList, { NotesListProps } from "../../components/NotesList/NotesList";
|
||||
import { getAllNotes } from "../../lib/parse-notes";
|
||||
import type { GetStaticProps } from "next";
|
||||
|
||||
const Notes = ({ notesByYear }) => (
|
||||
const Notes = ({ notesByYear }: NotesListProps) => (
|
||||
<>
|
||||
<NextSeo
|
||||
title="Notes"
|
||||
@@ -23,9 +23,10 @@ const Notes = ({ notesByYear }) => (
|
||||
|
||||
export const getStaticProps: GetStaticProps = async () => {
|
||||
// parse the year of each note and group them together
|
||||
const notesByYear = {};
|
||||
const notesByYear: NotesListProps["notesByYear"] = {};
|
||||
|
||||
getAllNotes().map((note) => {
|
||||
const year = Number.parseInt(format(new Date(note.date), "yyyy"));
|
||||
const year = format(new Date(note.date), "yyyy");
|
||||
(notesByYear[year] || (notesByYear[year] = [])).push(note);
|
||||
});
|
||||
|
||||
|
||||
Reference in New Issue
Block a user