Skip to content

Commit

Permalink
fix giscus
Browse files Browse the repository at this point in the history
  • Loading branch information
chai2010 committed Aug 8, 2024
1 parent cddc9de commit 3f6da8d
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 10 deletions.
4 changes: 0 additions & 4 deletions pkg/render/page.go
Original file line number Diff line number Diff line change
Expand Up @@ -136,10 +136,6 @@ func (p *BookRendor) renderPage(idx int, page *PageInfo) error {
},
}

if page.Book == nil {
panic("aa22")
}

t := template.Must(template.New("").Funcs(fnMap).Parse(tmplPage))
err := t.Execute(&buf, page)
if err != nil {
Expand Down
2 changes: 1 addition & 1 deletion pkg/render/static.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ var _staticFS embed.FS

func (p *BookRendor) renderStaticFile() error {
if p.Book.Info.Giscus.Enabled {
dst := filepath.Join(p.Book.Root, "book", "giscus.js")
dst := filepath.Join(p.Book.Root, "book/static/mnbook/giscus.js")
js, err := p.genGiscusJs()
if err != nil {
panic(err)
Expand Down
17 changes: 12 additions & 5 deletions pkg/render/tmpl/page.html
Original file line number Diff line number Diff line change
Expand Up @@ -122,8 +122,15 @@ <h1 class="menu-title"><a href="{{$page.Root}}/index.html">{{$page.Book.Title}}<
</script>

<div id="content" class="content">
<!-- Page table of contents -->
<div class="sidetoc"><nav class="pagetoc"></nav></div>

<main>
{{$page.RawHtml}}

{{if $page.Book.Giscus.Enabled}}
<div id="giscus-container"></div>
{{end}}
</main>

<nav class="nav-wrapper" aria-label="Page navigation">
Expand Down Expand Up @@ -157,10 +164,6 @@ <h1 class="menu-title"><a href="{{$page.Root}}/index.html">{{$page.Book.Title}}<
{{end}}
</nav>

{{if $page.Book.Giscus.Enabled}}
<div id="giscus-container"></div>
{{end}}

</div>

<script type="text/javascript">
Expand All @@ -170,11 +173,15 @@ <h1 class="menu-title"><a href="{{$page.Root}}/index.html">{{$page.Book.Title}}<
<script src="{{$page.Root}}/static/mnbook/clipboard.min.js" type="text/javascript" charset="utf-8"></script>
<script src="{{$page.Root}}/static/mnbook/highlight.js" type="text/javascript" charset="utf-8"></script>
<script src="{{$page.Root}}/static/mnbook/book.js" type="text/javascript" charset="utf-8"></script>

<script type="text/javascript" charset="utf-8">
var pagePath = "{{$page.Path}}"
</script>

<!-- Custom JS scripts -->
{{if $page.Book.Giscus.Enabled}}
<script src="{{$page.Root}}/static/mnbook/giscus.js" type="text/javascript" charset="utf-8"></script>
{{end}}

<!-- Custom JS scripts -->
</body>
</html>

0 comments on commit 3f6da8d

Please sign in to comment.