From e9f11ee1e5dd0bbc0bcf1a2875efd0ac13dff40c Mon Sep 17 00:00:00 2001 From: Can <> Date: Tue, 1 Dec 2020 06:28:42 +0300 Subject: [PATCH] working --- components/graph.js | 48 ++++-- components/layout.js | 2 +- lib/node.js | 3 +- lib/post.js | 94 +++++----- lib/transformer.js | 10 +- pages/_document.js | 13 +- pages/index.js | 11 +- pages/note/[id].js | 11 +- posts/.obsidian/config | 2 +- posts/.obsidian/workspace | 34 ++-- .../CSS/{Frost-Effect.md => Frost Effect.md} | 4 +- posts/Code/Codesheet.md | 10 +- posts/Code/Git/Git Komutları.md | 1 + posts/Code/HTML/HTTPS Force Meta Tag.md | 7 + posts/Code/HTML/https-force-meta-tag.md | 1 - posts/Code/Linux/Docker Commands.md | 47 +++++ posts/Code/Linux/Imagemin.md | 47 +++++ .../{linux-commands.md => Linux Commands.md} | 0 posts/Code/Tiddlywiki/Export.md | 17 ++ posts/Code/Tiddlywiki/Tiddlywiki Resources.md | 34 ++++ posts/Code/Tiddlywiki/Toggle Admin.md | 5 + posts/Code/WebFlow/WebFlow.md | 35 ++++ posts/articles-eng/Articles (ENG).md | 7 + posts/articles-eng/Confluence Installation.md | 4 +- .../articles-tr/Arama Motoru Optimizasyonu.md | 160 ++++++++++++++++++ posts/articles-tr/Articles (TR).md | 44 +++++ posts/articles-tr/Clover Notes.md | 6 +- posts/articles-tr/En İyi Blog Siteleri.md | 15 +- ...-rehberi.md => Ghost Blog Açma Rehberi.md} | 0 posts/articles-tr/Sidekick Browser.md | 65 +++++++ .../articles-tr/Zettelkasten Uygulamaları.md | 2 +- posts/articles-tr/zettelkasten-metodu.md | 6 + posts/index.md | 26 +-- posts/notes-eng/checklists/Sell Checklist.md | 21 +++ posts/notes-eng/general/Brave Settings.md | 5 + posts/notes-tr/Kirazın Tadı.md | 7 + posts/notes-tr/iyzico Gereklilikler.md | 28 +++ posts/notes-tr/İdeoloji.md | 10 ++ posts/sidebar.md | 6 +- styles/webflow-layout.css | 67 +++++--- 40 files changed, 766 insertions(+), 149 deletions(-) rename posts/Code/CSS/{Frost-Effect.md => Frost Effect.md} (80%) create mode 100644 posts/Code/HTML/HTTPS Force Meta Tag.md delete mode 100644 posts/Code/HTML/https-force-meta-tag.md create mode 100644 posts/Code/Linux/Docker Commands.md create mode 100644 posts/Code/Linux/Imagemin.md rename posts/Code/Linux/{linux-commands.md => Linux Commands.md} (100%) create mode 100644 posts/Code/Tiddlywiki/Export.md create mode 100644 posts/Code/Tiddlywiki/Tiddlywiki Resources.md create mode 100644 posts/Code/Tiddlywiki/Toggle Admin.md create mode 100644 posts/Code/WebFlow/WebFlow.md create mode 100644 posts/articles-eng/Articles (ENG).md create mode 100644 posts/articles-tr/Arama Motoru Optimizasyonu.md create mode 100644 posts/articles-tr/Articles (TR).md rename posts/articles-tr/{ghost-blog-acma-rehberi.md => Ghost Blog Açma Rehberi.md} (100%) create mode 100644 posts/articles-tr/Sidekick Browser.md create mode 100644 posts/articles-tr/zettelkasten-metodu.md create mode 100644 posts/notes-eng/checklists/Sell Checklist.md create mode 100644 posts/notes-eng/general/Brave Settings.md create mode 100644 posts/notes-tr/Kirazın Tadı.md create mode 100644 posts/notes-tr/iyzico Gereklilikler.md create mode 100644 posts/notes-tr/İdeoloji.md diff --git a/components/graph.js b/components/graph.js index 249ec00..08bc6df 100644 --- a/components/graph.js +++ b/components/graph.js @@ -83,28 +83,39 @@ const Graph = ({ el, graphdata, current }) => { export const Network = ({ el, graphdata, current, router, allNodes }) => { var jsnx = require('jsnetworkx'); + + //const grouper = (id) => id === "index" ? 1 : (id === "codesheet" ? 2 : 3) var currentnode = graphdata.filter(g => g.data.id === current)[0] - currentnode = [currentnode.data.id, { href:current==="index" ? "/" : `/note/${currentnode.data.id}` }]; - + currentnode = [currentnode.data.id, { + label:current==="index" ? "HOME" : currentnode.data.title ? currentnode.data.title : currentnode.data.id, + href:current==="index" ? "/" : `/note/${currentnode.data.id}`, + //group:grouper(current) + }]; + //var currentTargetNames = graphdata.filter(g => g.data.source === current).map(e => e.data.target) + //var currentTargetNodes = graphdata.filter(g => currentTargetNames.includes(g.data.id)) + var othernodes, edges; if (allNodes){ - othernodes = graphdata.filter(g => g.data.id !== current) + othernodes = graphdata.filter(g => (g.data.id !== current) && !g.data.source) othernodes = othernodes.map(on => [on.data.id ,{ - title:on.data.title ? on.data.title : on.data.id, - href: current === "index" ? "/" : `/note/${on.data.id}` + label:on.data.title ? on.data.title : on.data.id, + href: on.data.id === "index" ? "/" : `/note/${on.data.id}`, + //group: grouper(on.data.id) } ]) + //console.log(othernodes) edges = graphdata.filter(g => g.data.source) edges = edges.map(e => [e.data.source, e.data.target]) } else { + //console.log("else") var indexnode = graphdata.filter(g => g.data.id === "index")[0] indexnode = ["Home", { width:30, height:30, - weight:10, + weight:1, href:`/`, title: "Home", fill:"blueviolet", @@ -112,7 +123,7 @@ export const Network = ({ el, graphdata, current, router, allNodes }) => { }] var currentRawEdges = graphdata.filter(g => g.data.source === current) - edges = currentRawEdges.map(ce => [ce.data.source, ce.data.target, {weight:5 } ]) + edges = currentRawEdges.map(ce => [ce.data.source, ce.data.target, {weight:1 } ]) var currentTargetNames = currentRawEdges.map(ie => ie.data.target) var currentTargets = graphdata.filter(g => currentTargetNames.includes(g.data.id)) @@ -122,13 +133,13 @@ export const Network = ({ el, graphdata, current, router, allNodes }) => { - var G = new jsnx.completeGraph(); + var G = new jsnx.DiGraph(); G.addNodesFrom( [ currentnode, ...othernodes, ], - {color: 'black', width:60, height:60} + {color: '#999999', width:40, height:40} ); G.addEdgesFrom(edges); @@ -136,7 +147,10 @@ export const Network = ({ el, graphdata, current, router, allNodes }) => { element: el, withLabels: true, labelStyle:{ - color:"#ffffff" + color:"#333", + fill:function(n){ + return n.node === current ? "#fff" : "#000" + } }, labelAttr:{ class: "node-label", @@ -148,16 +162,22 @@ export const Network = ({ el, graphdata, current, router, allNodes }) => { } }, layoutAttr:{ - linkDistance:260, + linkDistance:160, + charge:function(c){ return -280}, }, nodeStyle: { - fill:"black" + fill: function(d) { + return "#999" + //console.log("group", d.data.group) + //return color(d.data.group); + }, + stroke: 'none' }, nodeAttr:{ - + class: "node-node", click:function(l){ - //console.log("lll",this, "\n", l); this.addEventListener("click", function(){ + console.log("lll", l.data); router.push(l.data.href) }) } diff --git a/components/layout.js b/components/layout.js index 400f1db..1adf12f 100644 --- a/components/layout.js +++ b/components/layout.js @@ -9,7 +9,7 @@ export default function Layout({ children, home }) { const [isOpen, setIsOpen] = useState(null) const toggle = () => setIsOpen(!isOpen) - const sidebarposition = isOpen ? "0px" : "-350px" + const sidebarposition = isOpen ? "0px" : "-250px" //console.log("effect: ", isOpen, sidebarposition) useEffect(()=>{ diff --git a/lib/node.js b/lib/node.js index d951cdb..571b7d2 100644 --- a/lib/node.js +++ b/lib/node.js @@ -23,7 +23,8 @@ export const Node = { results.push(file); } }); - return results; + const markdownFiles = results.filter(f => f.endsWith(".md")) + return markdownFiles }, readFileSync:function(fullPath){ return fs.readFileSync(fullPath, "utf8") diff --git a/lib/post.js b/lib/post.js index c523a51..8db4e68 100644 --- a/lib/post.js +++ b/lib/post.js @@ -5,25 +5,41 @@ import { Node } from "./node" import { Transformer } from "./transformer"; import BiMap from "bimap"; - +function pathSelector(filename, allFilePaths){ + if (filename.replace(".md", "") === "index"){ + return "/index.md" + } + else if (filename.replace(".md", "") === "sidebar"){ + return "/sidebar.md" + } + const editedFilePaths = allFilePaths.filter(f => !(f.endsWith("index.md") && f.endsWith("sidebar.md") )) + return editedFilePaths +} const postsDirectory = path.join(process.cwd(), 'posts') export function getSinglePost(filename) { - console.log("\n\nFile is scanning: ", filename) - // Check if sidebar or not - var filePaths = Node.getFiles(postsDirectory).filter(fn => fn.endsWith(".md")) - - // IF filename is not sidebar.md THEN Exclude sidebar.md from file list - filePaths = filename === "sidebar.md" ? filePaths : filePaths.filter(f => !f.endsWith("sidebar.md")) + //console.log("\n\nFile is scanning: ", filename) - // List of filenames that will provide existing links to wikilink - const fileNames = filePaths.map(f => Transformer.parseFileNameFromPath(f)) - - //console.log("\tDirectory is scanning to find corresponding filename") - const currentFilePath = Transformer.pairCurrentFile(filename, filePaths) - //console.log("\tScan is finished. Founded filepath", currentFilePath, "\n") + // List of filenames that will provide existing links to wikilink + var filePaths = Node.getFiles(postsDirectory) + const fileNames = filePaths.map(f => Transformer.parseFileNameFromPath(f)) + + // IF filename is not sidebar.md THEN Exclude sidebar.md from file list + var currentFilePath; + if (filename === "sidebar"){ + currentFilePath = path.join(postsDirectory, "/sidebar.md") + } + else if (filename === "index"){ + currentFilePath = path.join(postsDirectory, "/index.md") + } + else { + filePaths = filePaths.filter(f => !(f.endsWith("sidebar.md") && f.endsWith("index.md"))) + //console.log("\tDirectory is scanning to find corresponding filename") + currentFilePath = Transformer.pairCurrentFile(filename, filePaths) + //console.log("\tScan is finished. Founded filepath", currentFilePath, "\n") + } var fileContent = Node.readFileSync(currentFilePath) @@ -31,7 +47,7 @@ export function getSinglePost(filename) { //console.log("\tSearching any front matter data") const currentFileFrontMatter = Transformer.getFrontMatterData(fileContent) //console.log("\tFounded front matter data: ", currentFileFrontMatter, "\n") - + fileContent = Transformer.preprocessThreeDashes(fileContent) //fileContent = fileContent.split("---").join("") //console.log("filecontent end") @@ -53,7 +69,7 @@ export function getAllBacklinks(){ var internalLinks = [] // Get file names under /posts - const filePaths = Node.getFiles(postsDirectory).filter(fn => fn.endsWith(".md")).filter(f => !f.endsWith("sidebar.md")) + const filePaths = Node.getFiles(postsDirectory).filter(f => !f.endsWith("sidebar.md")) const fileNames = filePaths.map(f => Transformer.parseFileNameFromPath(f)) //console.log("\tFounded filePaths: ", fileNames) @@ -148,32 +164,32 @@ export function getGraphData(){ export function getPostListData() { //console.log("\n\nAll Posts are scanning") // Get file names under /posts - const filePaths = Node.getFiles(postsDirectory).filter(fn => fn.endsWith(".md")) + const filePaths = Node.getFiles(postsDirectory).filter(f => !(f.endsWith("index") || f.endsWith("sidebar"))) const fileNames = filePaths.map(f => Transformer.parseFileNameFromPath(f)) //console.log("filePaths", filePaths) - var allPostsData = filePaths.map(filePath => { - //console.log("filePath", filePaths) - // Remove ".md" from file name to get id - const slug = Transformer.parseFileNameFromPath(filePath) - //console.log("slug", slug) - - // Read markdown file as string - var fileContent = Transformer.preprocessThreeDashes(Node.readFileSync(filePath)) - //console.log("all backlinks fn") - // Use gray-matter to parse the post metadata section - const matterResult = Transformer.getFrontMatterData(fileContent) || [] // matter(fileContent).data - //console.log("all post fn....") - - //const permalink = matterResult.permalink - //const content = fileContent.split("---\n")[fileContent.split("---").length -1 ] - - // Combine the data with the slug - return { - id:slug.toLowerCase().split(" ").join("-"), - ...matterResult, - } - }) + //var allPostsData = filePaths.map(filePath => { + // //console.log("filePath", filePaths) + // // Remove ".md" from file name to get id + // const slug = Transformer.parseFileNameFromPath(filePath) + // //console.log("slug", slug) +// + // // Read markdown file as string + // var fileContent = Transformer.preprocessThreeDashes(Node.readFileSync(filePath)) + // //console.log("all backlinks fn") + // // Use gray-matter to parse the post metadata section + // const matterResult = Transformer.getFrontMatterData(fileContent) || [] // matter(fileContent).data + // //console.log("all post fn....") +// + // //const permalink = matterResult.permalink + // //const content = fileContent.split("---\n")[fileContent.split("---").length -1 ] +// + // // Combine the data with the slug + // return { + // id:slug.toLowerCase().split(" ").join("-"), + // ...matterResult, + // } + //}) - return allPostsData + return fileNames } \ No newline at end of file diff --git a/lib/transformer.js b/lib/transformer.js index d4b77f0..2b9e422 100644 --- a/lib/transformer.js +++ b/lib/transformer.js @@ -103,11 +103,17 @@ export const Transformer = { /* Normalize File Names */ normalizeFileName:function(filename){ var processedFileName = filename.replace(".md", "") + processedFileName = processedFileName.replace('(', '').replace(')', '') processedFileName = processedFileName.split(" ").join("-") processedFileName = processedFileName.toLowerCase() - const conversionLetters = [["ç", "c"], ["ş","s"], ["ı", "i"], ["ü","u"], ["ö","o"], ["ğ","g"]]; + const conversionLetters = [ + ["ç", "c"], ["ş","s"], ["ı", "i"], ["ü","u"], ["ö","o"], ["ğ","g"], + ["Ç", "C"], ["Ş","S"], ["İ", "I"], ["Ü","U"], ["Ö","O"], ["Ğ","G"] + + ]; conversionLetters.forEach(letterPair => { - processedFileName = processedFileName.replace(letterPair[0], letterPair[1]) + processedFileName = processedFileName.split(letterPair[0]).join(letterPair[1]) + //processedFileName = processedFileName.replace(letterPair[0], letterPair[1]) } ) //console.log("filename", processedFileName) diff --git a/pages/_document.js b/pages/_document.js index ce31d56..7709a35 100644 --- a/pages/_document.js +++ b/pages/_document.js @@ -9,7 +9,7 @@ class MyDocument extends Document { static async getInitialProps(ctx) { const initialProps = await Document.getInitialProps(ctx) //console.log("doc", initialProps) - const sidebar = getSinglePost("sidebar.md") + const sidebar = getSinglePost("sidebar") return { sidebar, ...initialProps } } @@ -28,15 +28,15 @@ class MyDocument extends Document { data-duration="400" role="banner" className="navbar w-nav" id="navbar" > -