GithubHelp home page GithubHelp logo

nova1751 / hexo-shiki-plugin Goto Github PK

View Code? Open in Web Editor NEW
3.0 1.0 1.0 50 KB

A code highlight plugin,use shiki for better highlight,built for hexo!

License: MIT License

JavaScript 63.24% CSS 36.76%
hexo highlight plugin shiki

hexo-shiki-plugin's Introduction

Hexo Shiki Plugin

NPM Version Build Status Hexo Version License

A code highlight plugin based on shiki,built for hexo.You can go to my blog for preview.

Installation

  1. Intall the plugin.
    yarn add hexo-shiki-plugin
  2. Setup config.
    shiki:
      theme: one-dark-pro

Warning

To avoid conflicts with the native code highlight plugin,please disable the native plugins.

highlight:
  enable: false
prismjs:
  enable: false

for hexo>=7.0.0 versions,please add a additional line,leave syntax_highlighter to empty,just like below.

syntax_highlighter:

Usage

this plugin has four themes built in,you can choose one of theme to display:

  • one-dark-pro
  • material-theme-palenight
  • github-light
  • github-dark

If you choose a theme other than one of the built-in themes,the plugin will use the one-dark-pro codeblock style,and load the specific theme code.You can load more code highlight themes in Themes.

There are some other features ported from hexo-theme-butterfly.The available settings are below:

Note

If you want to enable the code block beautify config, please make sure your website has introduced the font-awesome icon set.

shiki:
  theme: github-light # highlight-theme
  line_number: true # whether to show the line_number
  beautify: false # whether to add highlight tool true or false
  highlight_copy: true # copy button
  highlight_lang: false # show the code language
  highlight_height_limit: 360 # code-block max height,unit: px
  is_highlight_shrink: false # true: shrink the code blocks / false: expand the code blocks | none: expand code blocks and hide the button
  copy: # copy message
    success: "Copy Success"
    error: "Copy Error"
    no_support: "Browser Not Support"

Note

Since shiki support a lot of beautiful themes,you can add your own cutom css files to cusomize your codeblock style,here is a example:

:root {
  --hl-color: #e1e4e8;
  --hl-bg: #24292e;
  --hltools-bg: #1f2428;
  --hltools-color: #c5c5c5;
  --hlnumber-bg: #24292e;
  --hlnumber-color: #444d56;
  --hlscrollbar-bg: #32383e;
  --hlexpand-bg: linear-gradient(
    180deg,
    rgba(36, 41, 46, 0.6),
    rgba(36, 41, 46, 0.9)
  );
}

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.