Skip to content

Commit 007fbd1

Browse files
authored
Merge pull request #4 from ut-code/cloudflare
Cloudflareにデプロイできるようにする
2 parents 7fd6956 + c7012bb commit 007fbd1

File tree

13 files changed

+13864
-1489
lines changed

13 files changed

+13864
-1489
lines changed

.gitignore

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,8 @@
11
# See https://help.github.com/articles/ignoring-files/ for more about ignoring files.
22

3+
/.open-next
4+
/cloudflare-env.d.ts
5+
36
# dependencies
47
/node_modules
58
/.pnp

README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,3 +32,4 @@ npm run lint
3232
- よくわからなかったらstyle直接指定でも良い
3333
- [react-markdown](https://www.npmjs.com/package/react-markdown)
3434
- オプションがいろいろあり、今はほぼデフォルト設定で突っ込んでいるがあとでなんとかする
35+
- [OpenNext](https://opennext.js.org/cloudflare)

app/[docs_id]/page.tsx

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,7 @@
11
import { notFound } from "next/navigation";
2-
import { readFile } from "node:fs/promises";
3-
import { join } from "node:path";
42
import { ChatForm } from "./chatForm";
53
import { StyledMarkdown } from "./markdown";
4+
import { getCloudflareContext } from "@opennextjs/cloudflare";
65

76
export default async function Page({
87
params,
@@ -13,10 +12,10 @@ export default async function Page({
1312

1413
let mdContent: string;
1514
try {
16-
mdContent = await readFile(
17-
join(process.cwd(), "docs", `${docs_id}.md`),
18-
"utf-8"
19-
);
15+
const cfAssets = getCloudflareContext().env.ASSETS;
16+
mdContent = await cfAssets!
17+
.fetch(`https://assets.local/docs/${docs_id}.md`)
18+
.then((res) => res.text());
2019
} catch (error) {
2120
console.error(error);
2221
notFound();
@@ -29,4 +28,3 @@ export default async function Page({
2928
</div>
3029
);
3130
}
32-

next.config.ts

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,16 @@
11
import type { NextConfig } from "next";
2+
import { initOpenNextCloudflareForDev } from "@opennextjs/cloudflare";
3+
4+
initOpenNextCloudflareForDev();
25

36
const nextConfig: NextConfig = {
47
/* config options here */
8+
eslint: {
9+
ignoreDuringBuilds: true,
10+
},
11+
typescript: {
12+
ignoreBuildErrors: true,
13+
},
514
};
615

716
export default nextConfig;

open-next.config.ts

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
import { defineCloudflareConfig } from "@opennextjs/cloudflare";
2+
3+
export default defineCloudflareConfig();

0 commit comments

Comments
 (0)