Skip to content

Commit

Permalink
Refactor getCanvasFromEmbed function to be a bit cleaner and fetch ma…
Browse files Browse the repository at this point in the history
…rkdown assuming its not in the ssr folder
  • Loading branch information
lovettbarron committed Jul 9, 2024
1 parent d01e48f commit 80bd4a4
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 6 deletions.
3 changes: 3 additions & 0 deletions example/markdown/example.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
# Test test

Testing
14 changes: 8 additions & 6 deletions src/plugin.ts
Original file line number Diff line number Diff line change
Expand Up @@ -97,13 +97,15 @@ export async function getCanvasFromEmbed(
canvasMarkdown = text
})
} else if (options.ssrPath !== undefined) {
const opPath =
extension === "md" ? options.mdPath : options.assetPath || null
const pathArr = [process.cwd()]

if (options.ssrPath && extension !== "md") pathArr.push(options.ssrPath)
if (extension === "md" && options.mdPath) pathArr.push(options.mdPath)

pathArr.push(markdownPath)

const ssrPath = path.join(...pathArr)

const ssrPath = opPath
? path.join(process.cwd(), options.ssrPath, opPath, markdownPath)
: path.join(process.cwd(), options.ssrPath, markdownPath)
console.log(ssrPath)
try {
canvasMarkdown = fs.readFileSync(ssrPath, {
encoding: "utf8",
Expand Down

0 comments on commit 80bd4a4

Please sign in to comment.