Giter Site home page Giter Site logo

xenwayne / hexo-artitalk-static Goto Github PK

View Code? Open in Web Editor NEW

This project forked from lete114/hexo-artitalk-static

0.0 0.0 0.0 36 KB

Artitalk 静态版,本地编写说说(就像写文章一样),需要 hexo g 生成

License: MIT License

JavaScript 30.56% EJS 69.44%

hexo-artitalk-static's Introduction

Hexo-Artitalk-Static

Artitalk 静态版,本地编写说说(就像写文章一样),需要 hexo g 生成 (不会有人天天发说说吧?)

Installation

npm install hexo-artitalk-static

Usage

在你的博客根目录的 source/_data 创建文件 artitalk.yml。 以后你的所有说说都会写在这里面

## 说说格式
- content: Hexo-Artitalk-Static 真不错,没有后端,没有请求,速度是真的快
- content: |
    如果你的 JavaScript 基础还不错
    你还可以为 Hexo-Artitalk-Static 写自定义插件,还可以自定义说说的模板
    自由度是真的高(也可以安装别人的插件)

以上方式不会自动实时生成说说的时间,只有在执行了 hexo shexo g 的时候才会自动生成说说的时间 (而且是当前执行这个命令的时间,并不是你写说说的时间)

你可以在写说说前执行 hexo s 命令,然后再打开 source/_data/artitalk.yml 编写新说说,这样它才会实时生成说说的时间

Configuration

配置信息

artitalk:
  enable: true
  title: Artitalk ## 标题
  path: artitalk/index.html ## 生成路径
  pageSize: 5 ## 显示几条说说
  avatar: ## 说说头像
  plugins: [] ## 插件,具体请看下文
  template: ## 说说模板,可查看仓库中的 main.ejs
  imports: ## 在说说模板的开头和结尾处插入内容
    before:
      -
    after:
      -
    # - <link rel="stylesheet" href="/css/index.css">
    # - '<style>body{color: red}</style>' ## 注意由于css的‘{}’是关键符号所以需要(单/双)引号''
    # - <script>alert(1)</script>

Plugins

是一个数组,可以传入多个 js 文件路径,建议是绝对路径,如果是相对路径的话,那么它因该是相对于 hexo 的根目录

举例:自定义插件使得 Hexo-Artitalk-Static 支持 markdown 语法

在 hexo 根目录创建 artitalk_plugins/markdown.js,并安装解析 markdown 的第三方库,这里以 marked 作为演示 npm i marked

// artitalk_plugins/markdown.js
const marked = require('marked')

/**
 * @param {{content:string,timestamp:number}[]} atData
 */
module.exports = (atData) => {
  for (const item of atData) {
    // 关于 marked 的可选参数以及代码高亮可以查看官网: https://marked.js.org/using_advanced#highlight
    // 或自己上网搜索解决
    item.content = marked(item.content)
  }
}

然后再 hexo 的配置文件中的 artitlk.plugins 数组中加上路径(一下配置只是演示,其它配置信息已省略)

artitalk:
  enable: true
  plugins: ['artitalk_plugins/markdown.js']

当你自己写完一个插件后,你也可以分享给其它人使用,例如发布一个 npm 包让别人安装

包名建议命名为 hexo-artitalk-static-xxx (如上 markdown 插件 hexo-artitalk-static-markdown)

当别人安装你的插件后 npm install hexo-artitalk-static-markdown 在 artitlk.plugins 填写路径

artitalk:
  enable: true
  plugins: ['node_modules/hexo-artitalk-static-markdown']

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.