Skip to content

Commit

Permalink
killing pages router 💀 (tinacms#2814)
Browse files Browse the repository at this point in the history
* killing pages router 💀

* removing vercel crap 🚮

* adding back file output tracing

* some misc AI ideas 😕🤷

* no dynamic rendering 🚮

* Revert "some misc AI ideas 😕🤷"

This reverts commit 7b3ed7b.
  • Loading branch information
isaaclombardssw authored Jan 31, 2025
1 parent f7a8229 commit d196572
Show file tree
Hide file tree
Showing 8 changed files with 788 additions and 826 deletions.
10 changes: 6 additions & 4 deletions app/[slug]/page.tsx
Original file line number Diff line number Diff line change
@@ -1,12 +1,14 @@
import { client } from '../../tina/__generated__/client';
import ClientPage from './client-page';
import { fileToUrl } from 'utils/urls';
import { notFound } from 'next/navigation';
import { Metadata } from 'next';
import { notFound } from 'next/navigation';
import path from 'path';
import { fileToUrl } from 'utils/urls';
import { client } from '../../tina/__generated__/client';
import ClientPage from './client-page';

const fg = require('fast-glob');

export const dynamicParams = false;

interface PageProps {
params: {
slug?: string;
Expand Down
6 changes: 3 additions & 3 deletions app/blog/[...slug]/page.tsx
Original file line number Diff line number Diff line change
@@ -1,10 +1,12 @@
import { notFound } from 'next/navigation';
import client from 'tina/__generated__/client';
import BlogPageClient from './BlogPageClient';
import { TinaMarkdownContent } from 'tinacms/dist/rich-text';
import BlogPageClient from './BlogPageClient';
import { BlogPost } from './BlogType';
import { getExcerpt } from 'utils/getExcerpt';

export const dynamicParams = false;

export async function generateStaticParams() {
let allPosts = [];
let hasNextPage = true;
Expand Down Expand Up @@ -36,8 +38,6 @@ export async function generateStaticParams() {
return allPosts;
}

export const dynamicParams = true;

export async function generateMetadata({
params,
}: {
Expand Down
16 changes: 11 additions & 5 deletions app/blog/page/[page_index]/page.tsx
Original file line number Diff line number Diff line change
@@ -1,10 +1,12 @@
import client from 'tina/__generated__/client';
import { glob } from 'fast-glob';
import BlogIndexPageClient from './BlogIndexPageClient';
import { notFound } from 'next/navigation';
import client from 'tina/__generated__/client';
import BlogIndexPageClient from './BlogIndexPageClient';

const POSTS_PER_PAGE = 8;

export const dynamicParams = false;

export async function generateStaticParams() {
const contentDir = './content/blog/';
const files = await glob(`${contentDir}**/*.mdx`);
Expand All @@ -14,7 +16,11 @@ export async function generateStaticParams() {
}));
}

export async function generateMetadata({ params }: { params: { page_index: string } }) {
export async function generateMetadata({
params,
}: {
params: { page_index: string };
}) {
const title = 'TinaCMS Blog';
const description =
'Stay updated with the TinaCMS blog. Get tips, guides and the latest news on content management and development';
Expand Down Expand Up @@ -50,7 +56,7 @@ export default async function BlogPaginationPage({
});
} catch (err) {
console.error('Error fetching postConnection:', err);
notFound()
notFound();
}

let reversedPosts = [];
Expand All @@ -61,7 +67,7 @@ export default async function BlogPaginationPage({
?.reverse();
} catch (err) {
console.error('Error processing posts:', err);
notFound()
notFound();
}

const finalisedPostData = reversedPosts.slice(
Expand Down
26 changes: 13 additions & 13 deletions app/docs/[...slug]/page.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -6,22 +6,22 @@ import getTableOfContents from 'utils/docs/getTableOfContents';
import DocsClient from './DocsPagesClient';
import { getExcerpt } from 'utils/getExcerpt';

export const dynamicParams = false;

export async function generateStaticParams() {
try{
const contentDir = './content/docs/';
const files = await glob(`${contentDir}**/*.mdx`);
return files
.filter((file) => !file.endsWith('index.mdx'))
.map((file) => {
const path = file.substring(contentDir.length, file.length - 4); // Remove "./content/docs/" and ".mdx"
return { slug: path.split('/') };
});
} catch(error)
{
try {
const contentDir = './content/docs/';
const files = await glob(`${contentDir}**/*.mdx`);
return files
.filter((file) => !file.endsWith('index.mdx'))
.map((file) => {
const path = file.substring(contentDir.length, file.length - 4); // Remove "./content/docs/" and ".mdx"
return { slug: path.split('/') };
});
} catch (error) {
console.error(error);
notFound()
notFound();
}

}

export async function generateMetadata({
Expand Down
1 change: 0 additions & 1 deletion next-env.d.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
/// <reference types="next" />
/// <reference types="next/image-types/global" />
/// <reference types="next/navigation-types/compat/navigation" />

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

0 comments on commit d196572

Please sign in to comment.