diff --git a/lib/interpolate-source-code.js b/lib/interpolate-source-code.mjs similarity index 86% rename from lib/interpolate-source-code.js rename to lib/interpolate-source-code.mjs index 3de5182..db922d1 100644 --- a/lib/interpolate-source-code.js +++ b/lib/interpolate-source-code.mjs @@ -1,7 +1,7 @@ // https://github.com/nuxt/content/pull/676 -const path = require('path'); -const fs = require('fs/promises'); +import path from 'path' +import fs from 'fs/promises' const interpolateSourceCode = async (file) => { if (file.extension !== '.md') { @@ -26,8 +26,7 @@ const interpolateSourceCode = async (file) => { if (inCodeBlock && line.startsWith(sourceKey)) { try { const [lineIndent, relativePath] = lines[i].split(sourceKey) - // const sourceCode = path.resolve(path.dirname(file.path), relativePath) - const sourceCode = path.resolve(basePath, relativePath) + const sourceCode = path.resolve(basePath, relativePath.trim()) const buffer = await fs.readFile(sourceCode,{encoding: 'utf8'}) let indentedLine = lineIndent + buffer.toString().replace(/\n/g, "\n" + lineIndent)