diff --git a/next.config.js b/next.config.js index 6be6cb0..836b0c6 100644 --- a/next.config.js +++ b/next.config.js @@ -1,7 +1,10 @@ /** @type {import('next').NextConfig} */ const nextConfig = { reactStrictMode: true, + output: 'export', + trailingSlash: true, images: { + unoptimized: true, remotePatterns: [ { protocol: 'https', diff --git a/package-lock.json b/package-lock.json index f2a6c17..3575d43 100644 --- a/package-lock.json +++ b/package-lock.json @@ -2119,9 +2119,9 @@ } }, "node_modules/caniuse-lite": { - "version": "1.0.30001706", - "resolved": "https://registry.npmjs.org/caniuse-lite/-/caniuse-lite-1.0.30001706.tgz", - "integrity": "sha512-3ZczoTApMAZwPKYWmwVbQMFpXBDds3/0VciVoUwPUbldlYyVLmRVuRs/PcUZtHpbLRpzzDvrvnFuREsGt6lUug==", + "version": "1.0.30001735", + "resolved": "https://registry.npmjs.org/caniuse-lite/-/caniuse-lite-1.0.30001735.tgz", + "integrity": "sha512-EV/laoX7Wq2J9TQlyIXRxTJqIw4sxfXS4OYgudGxBYRuTv0q7AM6yMEpU/Vo1I94thg9U6EZ2NfZx9GJq83u7w==", "funding": [ { "type": "opencollective", diff --git a/package.json b/package.json index 6089cae..25f62e4 100644 --- a/package.json +++ b/package.json @@ -6,9 +6,12 @@ "scripts": { "dev": "next dev", "build": "next build", + "build:static": "next build", "start": "next start", "lint": "next lint", - "typecheck": "tsc --noEmit" + "typecheck": "tsc --noEmit", + "deploy:cf": "npm run build:static && npx wrangler deploy", + "preview:cf": "npm run build:static && npx wrangler dev" }, "keywords": [ "blog", diff --git a/src/pages/authors/[author].tsx b/src/pages/authors/[author].tsx index 297bdb7..f2086b1 100644 --- a/src/pages/authors/[author].tsx +++ b/src/pages/authors/[author].tsx @@ -127,17 +127,25 @@ const AuthorPage: React.FC = ({ posts, author }) => { }; export const getStaticPaths: GetStaticPaths = async () => { - const posts = getSortedPostsData(); - const authors = Array.from(new Set(posts.flatMap(post => post.author))); + try { + const posts = getSortedPostsData(); + const authors = Array.from(new Set(posts.flatMap(post => post.author))); - const paths = authors.map((author) => ({ - params: { author }, - })); + const paths = authors.map((author) => ({ + params: { author }, + })); - return { - paths, - fallback: false, - }; + return { + paths, + fallback: 'blocking', + }; + } catch (error) { + console.error('Failed to generate author paths during build:', error); + return { + paths: [], + fallback: 'blocking', + }; + } }; export const getStaticProps: GetStaticProps = async ({ params }) => { diff --git a/src/pages/authors/index.tsx b/src/pages/authors/index.tsx index a582e4d..10ea76d 100644 --- a/src/pages/authors/index.tsx +++ b/src/pages/authors/index.tsx @@ -57,21 +57,27 @@ const AuthorsPage: React.FC = ({ authors }) => { }; export const getStaticProps: GetStaticProps = async () => { - const { data: authorsData, error } = await supabase - .from('authors') - .select('name, bio, x_link, fb_link, insta_link, pfp_link'); + try { + const { data: authorsData, error } = await supabase + .from('authors') + .select('name, bio, x_link, fb_link, insta_link, pfp_link'); - if (error || !authorsData) { - console.error('Error fetching authors:', error); + if (error || !authorsData) { + console.error('Error fetching authors:', error); + // Return empty array for static export fallback + return { props: { authors: [] } }; + } + + return { + props: { + authors: authorsData, + }, + }; + } catch (error) { + console.error('Failed to fetch authors during build:', error); + // Fallback for static export when Supabase is not available during build return { props: { authors: [] } }; } - - return { - props: { - authors: authorsData, - }, - revalidate: 60, - }; }; export default AuthorsPage; diff --git a/wrangler.jsonc b/wrangler.jsonc new file mode 100644 index 0000000..7cf1d80 --- /dev/null +++ b/wrangler.jsonc @@ -0,0 +1,13 @@ +{ + "name": "confessions-of-grace", + "compatibility_date": "2025-08-18", + "assets": { + "directory": "./out" + }, + "routes": [ + { + "pattern": "confessionsofgrace.com", + "custom_domain": true + } + ] +}