From fc00ad5bffcd5a1b89a4c1cb19b12d77238cc4c2 Mon Sep 17 00:00:00 2001
From: Blake Allen <blakesnake100@gmail.com>
Date: Fri, 22 Oct 2021 21:04:09 +0000
Subject: [PATCH] fix for notes with spaces not linking properly
---
layouts/_default/single.html | 11 ++++-------
layouts/partials/graph.html | 4 ++--
layouts/partials/backlinks.html | 10 +++++++---
3 files changed, 13 insertions(+), 12 deletions(-)
diff --git a/layouts/_default/single.html b/layouts/_default/single.html
index c30cd4f..0025cd3 100644
--- a/layouts/_default/single.html
+++ b/layouts/_default/single.html
@@ -1,3 +1,6 @@
+<!-- {{replaceRE `(http.+) (\w+)` "$1-$2" .Content}} -->
+{{$content := replaceRE `a href="\.\.\/(.+%20.+)+"` `$1` .Content}}
+{{$content = replace $content "%20" "-"}}
<!DOCTYPE html>
<html lang="en">
{{ partial "head.html" . }}
@@ -13,13 +16,7 @@
{{partial "darkmode.html" .}}
</header>
<article>
- {{if $.Site.Data.config.enableToc}}
- <aside class="mainTOC">
- <h3>Table of Contents</h3>
- {{ .TableOfContents }}
- </aside>
- {{end}}
- {{- .Content -}}
+ {{ $content | safeHTML }}
</article>
{{partial "footer.html" .}}
</div>
diff --git a/layouts/partials/backlinks.html b/layouts/partials/backlinks.html
index 2e97820..48ffecc 100644
--- a/layouts/partials/backlinks.html
+++ b/layouts/partials/backlinks.html
@@ -6,9 +6,13 @@
{{$inbound := index $.Site.Data.linkIndex.index.backlinks $curPage}}
{{if $inbound}}
{{- range $inbound -}}
- <li>
- <a href="{{index . "source"}}">{{index . "source"}}</a>
- </li>
+ {{$src := index . "source"}}
+ {{$src = replace $src " " "-"}}
+ {{$src = replace $src `\` ""}}
+
+ <li>
+ <a href="../{{$src | safeHTML}}">{{index . "source"}}</a>
+ </li>
{{- end -}}
{{else}}
<li>
diff --git a/layouts/partials/graph.html b/layouts/partials/graph.html
index 0e9684d..16a9f6a 100644
--- a/layouts/partials/graph.html
+++ b/layouts/partials/graph.html
@@ -126,7 +126,7 @@
.attr("fill", color)
.style("cursor", "pointer")
.on("click", (_, d) => {
- window.location.href = {{.Site.BaseURL}} + d.id;
+ window.location.href = {{.Site.BaseURL}} + d.id.replace(" ", "-");
})
.on("mouseover", function (_, d) {
d3.selectAll(".node")
@@ -184,7 +184,7 @@
const labels = graphNode.append("text")
.attr("dx", 12)
.attr("dy", ".35em")
- .text((d) => d.id)
+ .text((d) => d.id.replace("%20", "-"))
.style("opacity", 0)
.style("pointer-events", "none")
.call(drag(simulation));
--
Gitblit v1.10.0