Skip to content

Commit

Permalink
solve ssg issue (#167)
Browse files Browse the repository at this point in the history
  • Loading branch information
perryd01 authored Oct 15, 2023
1 parent 180b32a commit 4ded4cb
Show file tree
Hide file tree
Showing 5 changed files with 68 additions and 4 deletions.
10 changes: 10 additions & 0 deletions src/app/blog/[slug]/page.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -104,3 +104,13 @@ export default async function SelectedNewsPage({
</div>
);
}

export async function generateStaticParams() {
const allNews = await getNews();

return (
allNews.items.map(({ fields }) => ({
slug: fields.slug,
})) ?? []
);
}
12 changes: 11 additions & 1 deletion src/app/esemenyek/[slug]/page.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import type { Metadata } from "next";
import Image from "next/image";

import { BackButton } from "@/components/buttons/BackButton";
import { getEvent } from "@/utils/contentful";
import { getEvent, getEvents } from "@/utils/contentful";
import { renderOptions } from "@/utils/RenderOptions";

type Props = {
Expand Down Expand Up @@ -59,3 +59,13 @@ export default async function EventsPage({ params }: Props) {
</article>
);
}

export async function generateStaticParams() {
const events = await getEvents();

return (
events.items.map(({ fields }) => ({
slug: fields.slug,
})) ?? []
);
}
19 changes: 18 additions & 1 deletion src/app/galeria/[slug]/@modal/(.)[id]/page.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import Image from "next/image";
import { notFound } from "next/navigation";

import Modal from "@/components/modal/Modal";
import { getOneGallery } from "@/utils/contentful";
import { getGalleries, getOneGallery } from "@/utils/contentful";

type Props = {
params: {
Expand Down Expand Up @@ -34,3 +34,20 @@ export default async function PhotoModal({ params }: Props) {
</Modal>
);
}

export async function generateStaticParams() {
const galleries = await getGalleries();

return (
galleries.items
.map(({ fields }) => {
const { slug } = fields;
const images = fields.images ?? [];
return images.map(({ sys }) => ({
slug,
id: sys.id,
}));
})
.flat() ?? []
);
}
19 changes: 18 additions & 1 deletion src/app/galeria/[slug]/[id]/page.tsx
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import Image from "next/image";
import Link from "next/link";

import { getOneGallery } from "@/utils/contentful";
import { getGalleries, getOneGallery } from "@/utils/contentful";

type Props = {
params: { slug: string; id: string };
Expand All @@ -27,3 +27,20 @@ export default async function SelectedImagePage({ params }: Props) {
</div>
);
}

export async function generateStaticParams() {
const galleries = await getGalleries();

return (
galleries.items
.map(({ fields }) => {
const { slug } = fields;
const images = fields.images ?? [];
return images.map(({ sys }) => ({
slug,
id: sys.id,
}));
})
.flat() ?? []
);
}
12 changes: 11 additions & 1 deletion src/app/galeria/[slug]/page.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import Image from "next/image";
import Link from "next/link";

import { SelectedGalleryPageLayout } from "@/components/layouts/SelectedGalleryPageLayout";
import { getOneGallery } from "@/utils/contentful";
import { getGalleries, getOneGallery } from "@/utils/contentful";

type Props = {
params: { slug: string };
Expand Down Expand Up @@ -54,3 +54,13 @@ export default async function SelectedGalleryPage({ params }: Props) {
</SelectedGalleryPageLayout>
);
}

export async function generateStaticParams() {
const galleries = await getGalleries();

return (
galleries.items.map(({ fields }) => ({
slug: fields.slug,
})) ?? []
);
}

0 comments on commit 4ded4cb

Please sign in to comment.