npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

halo-comment-normal

v1.5.0-alpha.0

Published

<h1 align="center"><a href="https://github.com/halo-dev" target="_blank">halo-comment-normal</a></h1> > 适用于 Halo 的评论组件。

Downloads

327

Readme

适用于 Halo 的评论组件。

npm

使用指南

  1. 进入后台 -> 系统 -> 博客设置 -> 评论设置

  2. 评论模块 JS 修改为:https://cdn.jsdelivr.net/npm/[email protected]/dist/halo-comment.min.js

自定义配置

如果你需要自定义该评论组件,下面提供了一些属性:

| 属性 | 说明 | 默认值 | 可选 | | -------------- | ------------------------ | ------------------------- | -------------------------- | | autoLoad | 是否自动加载评论列表 | true | true false | | showUserAgent | 是否显示评论者的 UA 信息 | true | true false | | loadingStyle | 评论加载样式 | default | default circle balls |

配置方法:

在引入评论组件的页面加上:

<script>
var configs = {
    autoLoad: true,
    showUserAgent: true
}
</script>

修改评论组件标签加上:

:configs="configs"

示例:

<halo-comment id="${post.id?c}" type="post" :configs="configs">
<halo-comment id="${sheet.id?c}" type="sheet" :configs="configs">
<halo-comment id="${journal.id?c}" type="journal" :configs="configs">

主题开发引用指南

方法一

新建 comment.ftl:

<#macro comment target,type>
    <#if !post.disallowComment!false>
        <script src="//cdn.jsdelivr.net/npm/[email protected]/dist/vue.min.js"></script>
        <script src="${options.comment_internal_plugin_js!'//cdn.jsdelivr.net/npm/[email protected]/dist/halo-comment.min.js'}"></script>
        <script>
        var configs = {
            autoLoad: true,
            showUserAgent: true
        }
        </script>
        <halo-comment id="${target.id?c}" type="${type}" :configs="configs"/>
    </#if>
</#macro>

然后在 post.ftl/sheet.ftl 中引用:

post.ftl:

<#include "comment.ftl">
<@comment target=post type="post" />

sheet.ftl:

<#include "comment.ftl">
<@comment target=sheet type="sheet" />

方法二

一般在主题制作过程中,我们可以将 head 部分抽出来作为宏模板,如:https://github.com/halo-dev/halo-theme-anatole/blob/master/module/macro.ftl,那么我们就可以将所需要的依赖放在 head 标签中:

<head>
    ...
    
    <#if is_post?? && is_sheet??>
        <script src="//cdn.jsdelivr.net/npm/[email protected]/dist/vue.min.js"></script>
        <script src="${options.comment_internal_plugin_js!'//cdn.jsdelivr.net/npm/[email protected]/dist/halo-comment.min.js'}"></script>
        <script>
        var configs = {
            autoLoad: true,
            showUserAgent: true
        }
        </script>
    </#if>
    
    ...
</head>

然后在 post.ftl/sheet.ftl 中引用:

post.ftl:

<#if !post.disallowComment!false>
    <halo-comment id="${post.id?c}" type="post" :configs="configs"/>
</#if>

sheet.ftl:

<#if !sheet.disallowComment!false>
    <halo-comment id="${sheet.id?c}" type="sheet" :configs="configs"/>
</#if>

进阶:

可以将 configs 中的属性通过 settings.yaml 保存数据库中,以供用户自行选择,如:

settings.yaml:

...

comment:
  label: 评论设置
  items:
    autoLoad:
      name: autoLoad
      label: 自动加载评论
      type: radio
      data-type: bool
      default: true
      options:
        - value: true
          label: 开启
        - value: false
          label: 关闭
    showUserAgent:
      name: showUserAgent
      label: 评论者 UA 信息
      type: radio
      data-type: bool
      default: true
      options:
        - value: true
          label: 显示
        - value: false
          label: 隐藏

...

那么我们需要将上面的 script 改为下面这种写法:

<script>
var configs = {
    autoLoad: ${settings.autoLoad!},
    showUserAgent: ${settings.showUserAgent!}
}
</script>

说明

  1. configs 可以不用配置。
  2. 具体主题开发文档请参考:https://halo.run/develop/theme/ready.html