mirror of
https://github.com/jambonz/next-static-site.git
synced 2026-10-04 02:04:26 +00:00
Implement public getParsedMarkdown function in lib/data.js
This commit is contained in:
+3
-3
@@ -36,7 +36,7 @@ function _getCleanSlug(slug) {
|
||||
}
|
||||
|
||||
// Load Markdown and YAML front-matter to generate the static props for Next.js docs component
|
||||
async function _getDocs(filePath) {
|
||||
export async function getParsedMarkdown(filePath) {
|
||||
const fileContents = fs.readFileSync(filePath, 'utf8');
|
||||
const fileMatter = matter(fileContents);
|
||||
const frontMatter = fileMatter.data;
|
||||
@@ -105,7 +105,7 @@ function _getDocsPaths(dirPath, arrayOfFiles = [{params:{slug:[]}}]) {
|
||||
return arrayOfFiles;
|
||||
}
|
||||
|
||||
// Public proxy for _getDocs() to return static props for Next.js docs component
|
||||
// Public method to return static props for Next.js docs component
|
||||
export async function getDocs(slug) {
|
||||
let filePath = slug ? path.join(
|
||||
docsDir,
|
||||
@@ -134,7 +134,7 @@ export async function getDocs(slug) {
|
||||
}
|
||||
|
||||
if (isMarkdown && fs.existsSync(filePath)) {
|
||||
return _getDocs(filePath);
|
||||
return getParsedMarkdown(filePath);
|
||||
}
|
||||
|
||||
return null;
|
||||
|
||||
Reference in New Issue
Block a user