Skip to content

Commit

Permalink
改路径+++
Browse files Browse the repository at this point in the history
  • Loading branch information
Cksheuen committed Nov 2, 2023
1 parent 67d5f43 commit 57d854d
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 6 deletions.
7 changes: 4 additions & 3 deletions server/api/posts/getContent.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,11 +13,12 @@ const __dirname = dirname(__filename)
export default defineEventHandler(async (event) => {
const body = await readBody(event)

const postsDirectory = path.join(process.cwd(), 'public', 'posts', body.path)
// = path.join(__dirname, '..', 'posts', body.path)
const postsDirectory
// = path.join(process.cwd(), 'public', 'posts', body.path)
= path.join(__dirname, '..', 'public', 'posts', body.path)
// = path.join(process.cwd(), `posts/${body.path}`)
// = `/posts/${body.path}`
// console.log(postsDirectory)
console.log(postsDirectory)

const fullPath = path.join(postsDirectory, `${body.id}.md`)
const fileContent = fs.readFileSync(fullPath, 'utf8')
Expand Down
7 changes: 4 additions & 3 deletions server/api/posts/postDirs.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,11 +11,12 @@ const __dirname = dirname(__filename)
export default defineEventHandler(async (event) => {
const body = await readBody(event)

const postsDirectory = path.join(process.cwd(), 'public', 'posts', body.path)
// = path.join(__dirname, '..', '..', 'posts', body.path)
const postsDirectory
// = path.join(process.cwd(), 'public', 'posts', body.path)
= path.join(__dirname, '..', 'public', 'posts', body.path)
// = path.join(process.cwd(), `posts/${body.path}`)
// = `/posts/${body.path}`
// console.log(postsDirectory)
console.log(postsDirectory)

const fileNames = fs.readdirSync(postsDirectory)
const allPostsData = fileNames.map((fileName) => {
Expand Down

0 comments on commit 57d854d

Please sign in to comment.