Skip to content

Commit

Permalink
fix: added extra head-note partial for notes
Browse files Browse the repository at this point in the history
  • Loading branch information
bwaklog committed Apr 15, 2024
1 parent 2ff3361 commit b73f41a
Show file tree
Hide file tree
Showing 5 changed files with 101 additions and 43 deletions.
1 change: 1 addition & 0 deletions pkg/parser/parser.go
Original file line number Diff line number Diff line change
Expand Up @@ -191,6 +191,7 @@ func (p *Parser) AddFile(baseDirPath string, dirEntryPath string, frontmatter Fr
MarkdownBody: markdownContent,
// preallocating the slice
LinkedNoteURLs: make([]template.URL, 0, 5),
LiveReload: p.LiveReload,
}

p.Notes[note.CompleteURL] = note
Expand Down
1 change: 1 addition & 0 deletions pkg/parser/zettel_parser.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ type Note struct {
Body template.HTML
MarkdownBody string
LinkedNoteURLs []template.URL
LiveReload bool
}

var backlinkRE = regexp.MustCompile(`\[[^\]]*\]\]`)
Expand Down
2 changes: 1 addition & 1 deletion site/layout/note.html
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{{ define "note"}}
{{$PageData := index .DeepDataMerge.Notes .PageURL}}
{{ template "head" .}}
{{ template "head-note" .}}

<body>

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

<!doctype html>
<html lang="en">

<head>
<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}}" />

<!-- External Stylesheets and Plugins -->
<script src="https://cdn.jsdelivr.net/gh/highlightjs/cdn-release@11.9.0/build/highlight.min.js"></script>
<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>
const eventSource = new EventSource('http://localhost:8000/events');
eventSource.onmessage = function (event) {
location.reload()
};
</script>
{{ end }}


{{range $PageData.Frontmatter.JSFiles}}
<script src="/script/{{.}}" defer></script>
{{end}} {{range .DeepDataMerge.LayoutConfig.SiteScripts }}
<script src="/script/{{.}}" defer></script>
{{end}}


<meta property="og:type" content="website" />
<meta property="og:title" content="{{ $PageData.Frontmatter.Title }}" />
<meta property="og:description" content="{{ $PageData.Frontmatter.Description }}" />
<meta property="og:image" content="{{ $PageData.Frontmatter.PreviewImage }}" />

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

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

</html>
84 changes: 42 additions & 42 deletions site/layout/partials/head.html
Original file line number Diff line number Diff line change
Expand Up @@ -2,54 +2,54 @@
<!-- 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>
<html lang="en">

<head>
<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}}" />

<!-- 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://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>
const eventSource = new EventSource('http://localhost:8000/events');
eventSource.onmessage = function (event) {
location.reload()
};
</script>
{{ end }}


{{range $PageData.Frontmatter.JSFiles}}
<script src="/script/{{.}}" defer></script>
{{end}} {{range .DeepDataMerge.LayoutConfig.SiteScripts}}
<script src="/script/{{.}}" defer></script>
{{end}}


<meta property="og:type" content="website" />
<meta property="og:title" content="{{ $PageData.Frontmatter.Title }}" />
<meta property="og:description" content="{{ $PageData.Frontmatter.Description }}" />
<meta property="og:image" content="{{ $PageData.Frontmatter.PreviewImage }}" />

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

<script defer>
hljs.highlightAll();
hljs.addPlugin(new CopyButtonPlugin());
</script>
<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}}" />

<!-- External Stylesheets and Plugins -->
<script src="https://cdn.jsdelivr.net/gh/highlightjs/cdn-release@11.9.0/build/highlight.min.js"></script>
<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>
const eventSource = new EventSource('http://localhost:8000/events');
eventSource.onmessage = function (event) {
location.reload()
};
</script>
{{ end }}


{{range $PageData.Frontmatter.JSFiles}}
<script src="/script/{{.}}" defer></script>
{{end}} {{range .DeepDataMerge.LayoutConfig.SiteScripts}}
<script src="/script/{{.}}" defer></script>
{{end}}


<meta property="og:type" content="website" />
<meta property="og:title" content="{{ $PageData.Frontmatter.Title }}" />
<meta property="og:description" content="{{ $PageData.Frontmatter.Description }}" />
<meta property="og:image" content="{{ $PageData.Frontmatter.PreviewImage }}" />

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

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

Expand Down

0 comments on commit b73f41a

Please sign in to comment.