Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit92fb3ac

Browse files
committed
files can be fetched, exists a bug when directly inputting URL
1 parentfd8dd6a commit92fb3ac

File tree

7 files changed

+48
-19
lines changed

7 files changed

+48
-19
lines changed

‎frontend/next.config.js‎

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,9 @@
11
/**@type {import('next').NextConfig} */
22
constnextConfig={
3-
reactStrictMode:true
3+
reactStrictMode:true,
4+
experimental:{
5+
serverActions:true,// Enable Server Actions
6+
},
47
};
58

69
module.exports=nextConfig;

‎frontend/package-lock.json‎

Lines changed: 7 additions & 0 deletions
Some generated files are not rendered by default. Learn more aboutcustomizing how changed files appear on GitHub.

‎frontend/package.json‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@
2121
"axios":"^1.7.2",
2222
"eslint-config-next":"13.4.19",
2323
"framer-motion":"^11.2.13",
24+
"fs":"^0.0.1-security",
2425
"lucide-react":"^0.511.0",
2526
"next":"13.4.12",
2627
"next-emoji-rain":"^1.0.2",
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
This is the article content for test article 2
2+
3+
changes to article 2
Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
{
2-
"title" :"Test article1",
3-
"author" :"The Author!",
4-
"date" :"1st July 2025"
2+
"title" :"Test article2",
3+
"author" :"The Author of test article 2",
4+
"date" :"1st July 2025 (date for test article 2)"
55
}
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
{
2+
"title" :"Test article 1",
3+
"author" :"The Author of test article 1",
4+
"date" :"1st July 2025 (date for test article 1)"
5+
}

‎frontend/src/components/Media/article-template.tsx‎

Lines changed: 25 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1,31 +1,42 @@
1+
// "use server"
12
importReactMarkdownfrom'react-markdown'
23
importremarkGfmfrom'remark-gfm'
3-
importReact,{useState,useEffect}from"react";
4+
importReact,{useState,useEffect}from"react"
5+
// import fs from "fs"
46

7+
exportdefaultfunctionArticle({articleName} :{articleName :string|string[]|undefined}){
58

6-
exportdefaultfunctionArticle({articleName} :{articleName :string}){
79

8-
const[markdown,setMarkdown]=useState("");
10+
letarticleUrl="/articles/"+articleName
11+
12+
// let infoFile = fs.readFileSync(articleUrl)
13+
// console.log(infoFile)
14+
915

16+
// import markdown from `@/../public/articles/${articleName}/content.md`
17+
18+
const[markdown,setMarkdown]=useState("");
1019
useEffect(()=>{
11-
fetch('/articles/test-article/content.md')
20+
fetch(`${articleUrl}/content.md`)//, { cache: 'no-store' })
1221
.then((res)=>res.text())
1322
.then((text)=>setMarkdown(text));
1423
},[]);
1524

16-
constarticleUrl="/articles/"+articleName
17-
1825
const[infoObj,setInfo]=useState("");
19-
2026
useEffect(()=>{
21-
fetch('/articles/test-article/info.json')
27+
fetch(`${articleUrl}/info.json`)//, { cache: 'no-store' })
2228
.then((res)=>res.text())
23-
.then((text)=>setInfo(text));
29+
.then((text)=>JSON.parse(`${text}`))
30+
.then((object)=>setInfo(object));
2431
},[]);
2532

26-
// const obj = JSON.parse(infoObj)
33+
console.log(infoObj)
34+
35+
// const obj = JSON.parse(`${infoObj}`)
36+
// const obj = JSON.parse(`{"title" : "TEST TITLE", "author": "test auth", "date" : "test date"}`)
2737

2838
return(
39+
2940
<articleclassName="mt-[6px]">
3041
<headerclassName="mb-[6vmin] w-[100vmin] justify-self-center">
3142
<divclassName="mb-[6vmin] w-[120vmin] justify-self-center">
@@ -34,22 +45,21 @@ export default function Article( {articleName} : {articleName : string} ) {
3445
{/* title, author, date */}
3546
<divclassName="">
3647
<divclassName="mb-[16px]">
37-
Articles
48+
Article
3849
</div>
3950
<h1className="font-black xl:text-6xl text-xl">
40-
{infoObj}
41-
TITLE
51+
{infoObj.title}
4252
</h1>
4353
<divclassName="mt-[24px] flex">
4454
<divclassName="inline-flex">
4555
<imgsrc={articleUrl+"/author.jpg"}className="inline ml-[4px] mr-[14px] w-[56px] h-[56px] rounded-full"/>
4656
</div>
4757
<divclassName="inline-flex flex-col self-center">
4858
<pclassName="font-bold self-start">
49-
{articleUrl+"/info.json"}
59+
{infoObj.author}
5060
</p>
5161
<pclassName="self-end">
52-
thedate is blah blah blah
62+
{infoObj.date}
5363
</p>
5464
</div>
5565
</div>

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp