Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Next Upgrade to v15 #1333

Merged
merged 4 commits into from
Jan 2, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading