1
mirror of https://github.com/jakejarvis/jarv.is.git synced 2025-11-05 09:05:39 -05:00

refactor "notes" into "posts" (only on the backend)

This commit is contained in:
2024-02-26 12:08:48 -05:00
parent 955cfe421f
commit dbde73c63c
19 changed files with 201 additions and 202 deletions

View File

@@ -21,7 +21,7 @@ const HitCounter = ({ slug }: HitCounterProps) => {
fetcher
);
// fail somewhat silently, see error boundary in NoteMeta component
// fail somewhat silently, see error boundary in PostMeta component
if (error) {
showBoundary(`${error}`);
return null;

View File

@@ -1,2 +0,0 @@
export * from "./NoteMeta";
export { default } from "./NoteMeta";

View File

@@ -1,2 +0,0 @@
export * from "./NoteTitle";
export { default } from "./NoteTitle";

View File

@@ -1,2 +0,0 @@
export * from "./NotesList";
export { default } from "./NotesList";

View File

@@ -2,11 +2,11 @@ import { ErrorBoundary } from "react-error-boundary";
import Link from "../Link";
import Time from "../Time";
import HitCounter from "../HitCounter";
import NoteTitle from "../NoteTitle";
import PostTitle from "../PostTitle";
import { FiCalendar, FiTag, FiEdit, FiEye } from "react-icons/fi";
import { styled, theme } from "../../lib/styles/stitches.config";
import * as config from "../../lib/config";
import type { NoteFrontMatter } from "../../types";
import type { PostFrontMatter } from "../../types";
const Wrapper = styled("div", {
display: "inline-flex",
@@ -55,9 +55,9 @@ const Tag = styled("span", {
},
});
export type NoteMetaProps = Pick<NoteFrontMatter, "slug" | "date" | "title" | "htmlTitle" | "tags">;
export type PostMetaProps = Pick<PostFrontMatter, "slug" | "date" | "title" | "htmlTitle" | "tags">;
const NoteMeta = ({ slug, date, title, htmlTitle, tags }: NoteMetaProps) => {
const PostMeta = ({ slug, date, title, htmlTitle, tags }: PostMetaProps) => {
return (
<>
<Wrapper>
@@ -116,9 +116,9 @@ const NoteMeta = ({ slug, date, title, htmlTitle, tags }: NoteMetaProps) => {
)}
</Wrapper>
<NoteTitle {...{ slug, title, htmlTitle }} />
<PostTitle {...{ slug, title, htmlTitle }} />
</>
);
};
export default NoteMeta;
export default PostMeta;

View File

@@ -0,0 +1,2 @@
export * from "./PostMeta";
export { default } from "./PostMeta";

View File

@@ -1,7 +1,7 @@
import Link from "../Link";
import { styled, theme } from "../../lib/styles/stitches.config";
import type { ComponentPropsWithoutRef } from "react";
import type { NoteFrontMatter } from "../../types";
import type { PostFrontMatter } from "../../types";
const Title = styled("h1", {
margin: "0.3em 0 0.5em -1px", // misaligned left margin, super nitpicky
@@ -18,10 +18,10 @@ const Title = styled("h1", {
},
});
export type NoteTitleProps = Pick<NoteFrontMatter, "slug" | "title" | "htmlTitle"> &
export type PostTitleProps = Pick<PostFrontMatter, "slug" | "title" | "htmlTitle"> &
ComponentPropsWithoutRef<typeof Title>;
const NoteTitle = ({ slug, title, htmlTitle, ...rest }: NoteTitleProps) => {
const PostTitle = ({ slug, title, htmlTitle, ...rest }: PostTitleProps) => {
return (
<Title {...rest}>
<Link
@@ -37,4 +37,4 @@ const NoteTitle = ({ slug, title, htmlTitle, ...rest }: NoteTitleProps) => {
);
};
export default NoteTitle;
export default PostTitle;

View File

@@ -0,0 +1,2 @@
export * from "./PostTitle";
export { default } from "./PostTitle";

View File

@@ -2,7 +2,7 @@ import Link from "../Link";
import Time from "../Time";
import { styled, theme } from "../../lib/styles/stitches.config";
import type { ReactElement } from "react";
import type { NotesByYear } from "../../types";
import type { PostsByYear } from "../../types";
const Section = styled("section", {
fontSize: "1.1em",
@@ -55,19 +55,19 @@ const PostDate = styled(Time, {
color: theme.colors.medium,
});
export type NotesListProps = {
notesByYear: NotesByYear;
export type PostsListProps = {
postsByYear: PostsByYear;
};
const NotesList = ({ notesByYear }: NotesListProps) => {
const PostsList = ({ postsByYear }: PostsListProps) => {
const sections: ReactElement[] = [];
Object.entries(notesByYear).forEach(([year, notes]) => {
Object.entries(postsByYear).forEach(([year, posts]) => {
sections.push(
<Section key={year}>
<Year>{year}</Year>
<List>
{notes.map(({ slug, date, title, htmlTitle }) => (
{posts.map(({ slug, date, title, htmlTitle }) => (
<Post key={slug}>
<PostDate date={date} format="MMM D" />
<span>
@@ -86,10 +86,10 @@ const NotesList = ({ notesByYear }: NotesListProps) => {
);
});
// grouped notes enter this component ordered chronologically -- we want reverse chronological
// grouped posts enter this component ordered chronologically -- we want reverse chronological
const reversed = sections.reverse();
return <>{reversed}</>;
};
export default NotesList;
export default PostsList;

View File

@@ -0,0 +1,2 @@
export * from "./PostsList";
export { default } from "./PostsList";