diff --git a/lib/post.js b/lib/post.js
index 8a7f411..d9cc200 100644
--- a/lib/post.js
+++ b/lib/post.js
@@ -1,5 +1,5 @@
import path from 'path'
-import matter from 'gray-matter'
+import matter, { test } from 'gray-matter'
import fs from "fs"
import { Node } from "./node"
import { Remark } from "./remark";
@@ -11,19 +11,24 @@ import BiMap from "bimap";
const postsDirectory = path.join(process.cwd(), 'posts')
export function getSinglePost(filename, permalink) {
- // Get file names under /posts
- const filePaths = Node.getFiles(postsDirectory).filter(fn => fn.endsWith(".md"))
+ // Check if sidebar or not
+ var filePaths = Node.getFiles(postsDirectory).filter(fn => fn.endsWith(".md"))
+ console.log("permalink", filename, filePaths)
+ filePaths = filename === "sidebar.md" ? filePaths : filePaths.filter(f => !f.endsWith("sidebar.md"))
+
const fileNames = filePaths.map(f => f.split("/")[f.split("/").length - 1].replace(".md", ""))
const filesFrontMatterData = filePaths.map(fp => Remark.getFrontMatterData(fp))
const currentFile = filePaths.filter(f => {
- const testFileName = f.split("/")[f.split("/").length - 1].replace(".md", "")
- return (filename.replace(".md", "") === testFileName)
+ var testFileName = f.split("/")[f.split("/").length - 1].replace(".md", "")
+ //testFileName = testFileName.replace("Ç","c").replace("ç","c").replace("ı","i").replace("ş","s")
+ const testFileNameAlternative = testFileName.toLowerCase().split(" ").join("-")
+ return (filename.replace(".md", "") === testFileName || filename.replace(".md", "") === testFileNameAlternative)
})[0]
- //console.log("currenFile: ", currentFile)
+ console.log("currenFile: ", currentFile)
//const currentFileFrontMatter = filesFrontMatterData.filter(f => f.permalink === permalink)[0]
//console.log("Current File By Name: ", currentFile)
- const currentFileFrontMatter = Remark.getFrontMatterData(currentFile)
+ //const currentFileFrontMatter = Remark.getFrontMatterData(currentFile)
//console.log("Current File By FrontMatter: ", currentFileFrontMatter)
const fileContent = fs.readFileSync(currentFile, 'utf8')
@@ -34,7 +39,7 @@ export function getSinglePost(filename, permalink) {
return {
id:filename,
- ...currentFileFrontMatter,
+ //...currentFileFrontMatter,
data:htmlContent
}
@@ -105,7 +110,7 @@ export function getPostListData() {
// Combine the data with the slug
return {
- id:slug,
+ id:slug.toLowerCase().split(" ").join("-"),
...matterResult,
}
})
diff --git a/lib/remark.js b/lib/remark.js
index e78876d..082b46e 100644
--- a/lib/remark.js
+++ b/lib/remark.js
@@ -39,6 +39,7 @@ export const Remark = {
},
hrefTemplate: function(permalink){
//console.log("wiki pemalink", permalink);
+ permalink = permalink.replace("ç","c").replace("ı","i").replace("ş","s")
return `/note/${permalink}`
}
}).use(html)
diff --git a/pages/_document.js b/pages/_document.js
index cdacfe7..b61eb25 100644
--- a/pages/_document.js
+++ b/pages/_document.js
@@ -14,6 +14,10 @@ class MyDocument extends Document {
render(props) {
return (
+
+
+