Skip to content

Commit

Permalink
fix: fix graph titles, copy plugin and preload tag
Browse files Browse the repository at this point in the history
  • Loading branch information
anirudhsudhir committed Apr 15, 2024
1 parent fc048a3 commit 992c5df
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 12 deletions.
6 changes: 5 additions & 1 deletion site/layout/page.html
Original file line number Diff line number Diff line change
Expand Up @@ -37,8 +37,12 @@ <h1>{{ $PageData.Frontmatter.Title }}</h1>
</section>
</article>
{{template "footer" .}}
<script>
hljs.highlightAll();
hljs.addPlugin(new CopyButtonPlugin());
</script>
</body>

</html>

{{ end}}
{{ end}}
16 changes: 7 additions & 9 deletions site/layout/partials/head.html
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
<!-- If the template for a particular url does not exist(posts.html), setting it to the specific page template data -->
{{ $PageData := index .DeepDataMerge.Templates .PageURL }}
{{if eq $PageData nil }}
{{ $PageData = .TemplateData }}
{{ $PageData = .TemplateData }}
{{end}}

<!doctype html>
Expand All @@ -12,15 +12,17 @@
<meta charset="UTF-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<title>{{$PageData.Frontmatter.Title}}</title>
<link rel="preload stylesheet" href="{{.DeepDataMerge.LayoutConfig.ThemeURL}}" />
<link rel="preload stylesheet" href="{{.DeepDataMerge.LayoutConfig.ThemeURL}}" as="style" />

<!-- External Stylesheets and Plugins -->
<script src="https://cdn.jsdelivr.net/gh/highlightjs/cdn-release@11.9.0/build/highlight.min.js"></script>
<script defer src="https://unpkg.com/highlightjs-copy/dist/highlightjs-copy.min.js"></script>
<link rel="stylesheet"
href="https://cdn.jsdelivr.net/gh/highlightjs/cdn-release@11.7.0/build/styles/tomorrow-night.css">

<script src="https://unpkg.com/highlightjs-copy/dist/highlightjs-copy.min.js"></script>
<link rel="stylesheet" href="https://unpkg.com/highlightjs-copy/dist/highlightjs-copy.min.css" />
<link rel="alternate" type="application/atom+xml" title="feed" href="/feed.xml" />


<!-- Scripts filled in from plugins -->
{{ if $PageData.LiveReload }}
<script>
Expand All @@ -46,11 +48,7 @@

<meta name="description" content="{{ $PageData.Frontmatter.Description }}">

<script defer>
hljs.highlightAll();
hljs.addPlugin(new CopyButtonPlugin());
</script>
</head>
{{end}}

</html>
</html>
12 changes: 10 additions & 2 deletions site/static/scripts/graph.js
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,15 @@ function drawNodes(nodes) {
.call(d3.drag().on("start", dragstarted).on("drag", dragged).on("end", dragended))
.on("click", onClick);

node.append("title").text(d => d.id);
node.append("title").text(d => {
//Removing the url prefix and file extension

if (d.id.indexOf("/") != -1) {
d.id = d.id.replace(/.*\//, "")
}
d.id = d.id.replace(/.html/, "")
d.id;
})
}

function drawLabels(nodes) {
Expand Down Expand Up @@ -88,7 +96,7 @@ async function onClick(event, d) {
.map(([key, post]) => ({ filename: key, title: post.Frontmatter.Title }));

if (commonPosts.length === 0 && d.group !== 0) {
const nodeName = d.id.replace(/\.md$/, ""); // Remove the ".md" extension from the node name (eh)
nodeName = "posts/" + d.id + ".html" // Adding url prefix and extension for posts
window.location.href = `/${nodeName}`; // If it's a leaf node, automatically redirect
}
else {
Expand Down

0 comments on commit 992c5df

Please sign in to comment.