Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

sonic-theme-papermod使用Artalk评论系统 #2

Open
aaro-n opened this issue May 7, 2024 · 1 comment
Open

sonic-theme-papermod使用Artalk评论系统 #2

aaro-n opened this issue May 7, 2024 · 1 comment

Comments

@aaro-n
Copy link

aaro-n commented May 7, 2024

sonic-theme-papermod默认没有引入第三方评论系统,但我又想使用第三方评论系统,后来发现只要在post.tmpl中引入Artalk即可。

参考代码

{{- define "sonic_theme_paper_mod/post" -}}
<!DOCTYPE html>
<html lang="zh" dir="auto">

<head>
<title>{{ .post.Title }} - {{ .blog_title }}</title>
{{ template "sonic_theme_paper_mod/module/head" .}}
</head>

<body id="top">

{{template "sonic_theme_paper_mod/module/header" .}}

<main class="main">

<article class="post-single">
<h1 class="post-title"><a href="{{ .post.FullPath }}">{{ .post.Title }}</a></h1>
<div class="post-meta">
    <div class="post-info">
        Create Time: {{ unix_milli_time_format "2006-01-02 15:04:05" .post.CreateTime }}  Words: {{ .post.WordCount }}
    </div>
</div>

<div class="post-content">
    <hr>
    {{noescape .post.Content}}
    <hr>
</div>

<footer class="post-footer">
<nav class="paginav">
    {{if .prevPost}}
    <a class="prev" href="{{.prevPost.FullPath}}">
        <span class="title">« Prev</span>
        <br>
        <span>{{.prevPost.Title}}</span>
    </a>
    {{end}}
    {{if .nextPost}}
    <a class="next" href="{{.nextPost.FullPath}}">
        <span class="title">Next »</span>
        <br>
        <span>{{.nextPost.Title}}</span>
    </a>
    {{end}}
</nav>

<br>

</footer>

</article>

<link href="//cdn.staticfile.org/artalk/2.8.3/ArtalkLite.css" rel="stylesheet" />
<script src="//cdn.staticfile.org/artalk/2.8.3/ArtalkLite.js"></script>

<!-- Artalk -->
<div id="Comments"></div>

<script>
  Artalk.init({
    el: '#Comments',
    pageKey: '{{ .post.FullPath }}',
    pageTitle: '{{ .post.Title }}',
    server: 'https://Artalk地址',
    site: '{{ .settings.header_title }}',
   })
</script>

</main>

{{template "sonic_theme_paper_mod/module/footer" .}}

</body>
</html>
{{end}}

原文:Sonic的PaperMod主题启用Artalk评论

@aaro-n
Copy link
Author

aaro-n commented May 8, 2024

 pageKey: '{{ .post.FullPath }}',

可以设置为

pageKey: '{{ .blog_url }}{{ .post.FullPath }}',

获取完整网页。

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant