Skip to content

Commit

Permalink
fix compatible to next export
Browse files Browse the repository at this point in the history
  • Loading branch information
tkc310 committed Oct 10, 2022
1 parent 3db4850 commit 3e466a3
Show file tree
Hide file tree
Showing 8 changed files with 13 additions and 52 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
# next.js build output
.next
out

# dotenv environment variables file (build for Zeit Now)
.env
Expand Down
7 changes: 5 additions & 2 deletions next.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,9 @@
const nextConfig = {
reactStrictMode: true,
swcMinify: true,
}
images: {
unoptimized: true,
},
};

module.exports = nextConfig
module.exports = nextConfig;
1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
"scripts": {
"dev": "next dev",
"build": "next build",
"export": "next export",
"start": "next start",
"lint": "next lint",
"fastly-serve": "next build && cd compute-js && fastly compute serve",
Expand Down
13 changes: 0 additions & 13 deletions pages/api/hello.ts

This file was deleted.

19 changes: 0 additions & 19 deletions pages/api/posts/[id].ts

This file was deleted.

9 changes: 0 additions & 9 deletions pages/api/posts/index.ts

This file was deleted.

9 changes: 4 additions & 5 deletions pages/posts/[id].tsx
Original file line number Diff line number Diff line change
@@ -1,12 +1,11 @@
import { TPost } from '@/data';
import { posts, TPost } from '@/data';
import type { NextPage } from 'next';
import { NextRouter, useRouter } from 'next/router';
import { useEffect, useState } from 'react';

const fetchPost = async (id: TPost['id']): Promise<TPost> => {
const res = await fetch(`/api/posts/${id}`);
const data = await res.json();
return data;
const fetchPost = async (id: TPost['id']): Promise<TPost | null> => {
const data = posts.find((item) => item.id === id);
return data || null;
};

const isId = (id: NextRouter['query']['id']): id is string =>
Expand Down
6 changes: 2 additions & 4 deletions pages/posts/index.tsx
Original file line number Diff line number Diff line change
@@ -1,12 +1,10 @@
import { TPost } from '@/data';
import { posts, TPost } from '@/data';
import type { NextPage } from 'next';
import Link from 'next/link';
import { useEffect, useState } from 'react';

const fetchPosts = async (): Promise<TPost[]> => {
const res = await fetch('/api/posts');
const data = await res.json();
return data;
return posts;
};

const Posts: NextPage = () => {
Expand Down

0 comments on commit 3e466a3

Please sign in to comment.