Remove lint

Fix build error
This commit is contained in:
Tuan Cao 2022-04-15 11:20:32 +07:00
parent 5195f9bdcc
commit 5b914a148c
2 changed files with 1 additions and 114 deletions

View File

@ -13,7 +13,7 @@ function BackLinks({linkList}) {
<h3 className="backlink-heading">Link to this note</h3> <h3 className="backlink-heading">Link to this note</h3>
<div className="backlink-container"> <div className="backlink-container">
{linkList.map(aLink => {linkList.map(aLink =>
<div className="backlink"> <div key={aLink.slug} className="backlink">
<Link href={aLink.slug}> <Link href={aLink.slug}>
<a> <a>
<p className="backlink-title">{aLink.title}</p> <p className="backlink-title">{aLink.title}</p>

View File

@ -15,116 +15,3 @@ const postsDirectory = path.join(process.cwd(), 'posts')
const isFile = fileName => { const isFile = fileName => {
return fs.lstatSync(fileName).isFile() return fs.lstatSync(fileName).isFile()
} }
export function getSortedPostsData() {
// Get file names under /posts
const filePaths = Node.getFiles(postsDirectory).filter(fn => fn.endsWith(".md"))
const fileNames = filePaths.map(f => f.split("/")[f.split("/").length - 1].replace(".md", ""))
//console.log("filePaths", filePaths)
var allPostsData = filePaths.map(fileName => {
//console.log("filename", fileNames)
// Remove ".md" from file name to get id
const slug = fileName.replace(/\.md$/, '').split("/")[fileName.split("/").length - 1]
//console.log("slug", slug)
// Read markdown file as string
const fileContent = fs.readFileSync(fileName, 'utf8')
// Use gray-matter to parse the post metadata section
const matterResult = Remark.getFrontMatterData(fileContent)// matter(fileContent).data
const permalink = matterResult.permalink
const content = fileContent.split("---\n")[fileContent.split("---").length -1 ]
//console.log("content", content)
//console.log("frontmatter \n\n", fileContents)
// let processor = unified()
// .use(markdown, { gfm: true })
// .use(wikiLinkPlugin)
// const htmlContent = Remark.getHtmlContent(fileContent, {
// fileNames:fileNames,
// permalink: `/note/${permalink}`
// })
//unified()
//.use(markdown)
//.use(wikiLinkPlugin, {
// permalinks:fileNames,
// pageResolver: function(pageName){return [pageName.replace(/ /g, "-").toLowerCase()]},
// hrefTemplate: function(permalink){return `/note/${permalink}`}
//}).use(html)
//.process(content,
// function (err, file) {
// //console.log("asd", String(file).slice(0,50))
// //console.error("remark: ", report(err || file))
// htmlContent.push(String(file).replace("\n", ""))
// }
//)
//console.log("tree",tree)
console.log("htmlContent", htmlContent,)
// Combine the data with the slug
return {
id:slug,
...matterResult,
data:htmlContent
}
})
return allPostsData
}
export async function getSortedPostsData() {
// Get file names under /posts
const fileNames = Node.getFiles(postsDirectory).filter(fn => fn.endsWith(".md"))
console.log("filenames", fileNames)
var allPostsData = fileNames.map(fileName => {
//console.log("filename", fileName)
// Remove ".md" from file name to get id
const slug = fileName.replace(/\.md$/, '').split("/")[fileName.split("/").length - 1]
//console.log("slug", slug)
// Read markdown file as string
const fileContents = fs.readFileSync(fileName, 'utf8')
// Use gray-matter to parse the post metadata section
const matterResult = matter(fileContents).data
const content = fileContents.split("---\n")[fileContents.split("---").length -1 ]
//console.log("content", content)
//console.log("frontmatter \n\n", fileContents)
// let processor = unified()
// .use(markdown, { gfm: true })
// .use(wikiLinkPlugin)
const htmlContent = []
remark().use(html).
process(content,
function (err, file) {
//console.log("asd", String(file).slice(0,50))
//console.error("remark: ", report(err || file))
htmlContent.push(String(file).replace("\n", ""))
})
//var processor = unified()
// .use(markdown, { gfm: true })
// .use(wikiLinkPlugin)
//console.log("processor", processor);
//const res = process.stdin.pipe(stream(processor)).pipe(process.stdout)
var tree = unified().use(markdown).parse(content)
console.log(tree)
console.log("htmlContent", htmlContent.length,)
// Combine the data with the slug
return {
id:slug,
...matterResult,
data:htmlContent.join("")
}
})
return allPostsData
}