Skip to content

Commit

Permalink
Live Release (#1335)
Browse files Browse the repository at this point in the history
  • Loading branch information
jdamner authored Jan 2, 2025
2 parents 7e4958e + e3b4d57 commit a0301a4
Show file tree
Hide file tree
Showing 8 changed files with 2,487 additions and 2,135 deletions.
15 changes: 11 additions & 4 deletions app/[slug]/page.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,18 @@ import { Blog, Header, TableOfContents } from "@/components";
import { Container, Article } from "@/components/Layouts/";

/* API */
import { useAllPostLinks, usePost } from "@/utils";
import { getAllPostLinks, getPost } from "@/utils";

const Page = ({ params }: { params: { slug: string } }) => {
const post = usePost(params.slug);
const postLinks = useAllPostLinks();
export async function generateStaticParams() {
return getAllPostLinks().map((post) => ({
slug: post.slug,
}));
}

const Page = async ({ params }: { params: Promise<{ slug: string }> }) => {
const slug = (await params).slug;
const post = getPost(slug);
const postLinks = getAllPostLinks();

if (!post) {
return null;
Expand Down
4 changes: 2 additions & 2 deletions app/page.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { useAllPostLinks, useAllServices } from "@/utils";
import { getAllPostLinks, useAllServices } from "@/utils";

import Content from "@/content/home.mdx";
import Service from "@/content/services.mdx";
Expand All @@ -17,7 +17,7 @@ export const metadata: Metadata = {

const Page = () => {
const services = useAllServices();
const posts = useAllPostLinks();
const posts = getAllPostLinks();
return (
<>
<Header title="James Amner" subtitle="Senior PHP Developer">
Expand Down
3 changes: 0 additions & 3 deletions components/Layouts/__snapshots__/Article.stories.tsx.snap
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@ exports[`Layout/Article Default smoke-test 1`] = `
<div class="basis-1/3">
<div class>
<img alt
fetchpriority="high"
width="500"
height="500"
decoding="async"
Expand Down Expand Up @@ -60,7 +59,6 @@ exports[`Layout/Article NoChildren smoke-test 1`] = `
<div class="basis-1/3">
<div class>
<img alt
fetchpriority="high"
width="500"
height="500"
decoding="async"
Expand Down Expand Up @@ -168,7 +166,6 @@ exports[`Layout/Article Offset smoke-test 1`] = `
<div class="basis-1/3">
<div class="-mt-10 md:-mt-20 h-full">
<img alt
fetchpriority="high"
width="500"
height="500"
decoding="async"
Expand Down
21 changes: 20 additions & 1 deletion mdx-components.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ const makeSlug = (value: ReactNode | ReactNode[]): string => {
)
return node;

if (typeof node === "object" && node !== null && "props" in node) {
if (isNodeWithChildren(node)) {
return makeSlug(node.props.children);
}

Expand All @@ -41,6 +41,25 @@ const makeSlug = (value: ReactNode | ReactNode[]): string => {
);
};

const isNodeWithChildren = (
value: unknown,
): value is { props: { children: string | number | boolean | Array<any> } } => {
return (
typeof value === "object" &&
value !== null &&
"props" in value &&
value.props !== null &&
typeof value.props === "object" &&
"children" in value.props &&
value.props.children !== null &&
typeof value.props.children !== "undefined" &&
(typeof value.props.children === "string" ||
typeof value.props.children === "number" ||
typeof value.props.children === "boolean" ||
Array.isArray(value.props.children))
);
};

export const components = {
a: (
props: DetailedHTMLProps<
Expand Down
2 changes: 1 addition & 1 deletion next-env.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,4 @@
/// <reference types="next/image-types/global" />

// NOTE: This file should not be edited
// see https://nextjs.org/docs/app/building-your-application/configuring/typescript for more information.
// see https://nextjs.org/docs/app/api-reference/config/typescript for more information.
Loading

0 comments on commit a0301a4

Please sign in to comment.