Giter Site home page Giter Site logo

presentkim / vuepress-plugin-giscus-comment Goto Github PK

View Code? Open in Web Editor NEW
2.0 2.0 0.0 97 KB

Add <Giscus/> component to VuePress@v2

License: MIT License

Vue 38.00% TypeScript 62.00%
vue vuejs vue3 vuepress vuepress2 vuepress-next vuepress-plugin vuepress2-plugin giscus comment-system

vuepress-plugin-giscus-comment's Introduction

vuepress-plugin-giscus-comment

npm GitHub license

Note: This plugin is provided for VuePress 2

Giscus plugin for VuePress 2.
This plugin register <GiscusComment/> custom element to your VuePress site.
You are free to use it on any theme or page.

Installation

yarn add -D vuepress-plugin-giscus-comment
# OR
npm install -D vuepress-plugin-giscus-comment

Usage

Method 1: Using the simple plugin configuration array

This method is simple and the most common.

module.exports = {
    plugins: [
        ['vuepress-plugin-giscus-comment',{/*options*/}]
    ]
};

When using with TypeScript, you can specify the type as shown below.

import {GiscusCommentPluginConfig} from 'vuepress-plugin-giscus-comment'

module.exports = {
    plugins: [
        ['vuepress-plugin-giscus-comment', {/*options*/}] as GiscusCommentPluginConfig
    ]
};

Method 2: Using the plugin configuration generator function

This method is a goes well with TypeScript.

import {GiscusCommentPlugin} from 'vuepress-plugin-giscus-comment';

module.exports = {
    plugins: [
        new GiscusCommentPlugin({/*options*/})
    ]
}

๐Ÿ—ƒ๏ธ Options

The plugin option has an interface as shown below.

interface GiscusCommentPluginOptions{
    /** @description The repository name */
    repo: `${string}/${string}`;

    /** @description The repository id */
    repoId: string;
    
    /** 
     * @description The discussion category name of repository
     * Required if 'mapping' value is not 'specific'
    */
    category?: string;

    /** 
     * @description The discussion category id of repository
     * Required if 'mapping' value is not 'specific'
    */
    categoryId?: string;

    /**
     * @description The mapping method between the embedding page and the embedded discussion
     * @default 'pathname'
     */
    mapping?: 'url' | 'title' | 'og:title' | 'pathname' | 'specific' | 'number';
    
    /**
     * @description Not required by Common mapping method
     * Required when 'mapping' value is 'specific' or 'number'
     */
    term?: string|number;
    
     /**
     * @description Whether to enable reactions for main post
     * @default true
     */
    reactionsEnabled?: boolean;

    /**
     * @description Whether to enable emit discussion metadata
     * @default false
     */
    emitMetadata?: boolean;

    /**
     * @description The theme name or custom theme css path that apply to giscus
     * @default 'light'
     */
    theme?:
        'light' | 'light_high_contrast' | 'light_protanopia' |
        'dark' | 'dark_high_contrast' | 'dark_protanopia' | 'dark_dimmed' |
        'transparent_dark' | 'preferred_color_scheme' |
        `/${string}` | `https://${string}`;

    /**
     * @description The location of comment box
     * @default 'bottom'
     */
    inputPosition?: 'top' | 'bottom';

    /**
     * @description The language name that apply to giscus
     * @default 'en'
     */
    lang?:
        'de' | 'en' | 'es' | 'fr' | 'gsw' | 'id' | 'it' | 'ja' |
        'ko' | 'pl' | 'ro' | 'ru' | 'tr' | 'vi' | 'zh-CN' | 'zh-TW';

    /**
     * @description Whether to load the comments lazily
     * @default true
     */
    lazyLoading?: boolean;
}

Example:

import {GiscusCommentPlugin} from 'vuepress-plugin-giscus-comment';

module.exports = {
    plugins: [
        new GiscusCommentPlugin({
               repo: '[ENTER REPOSITORY NAME HERE]',
               repoId: '[ENTER REPOSITORY ID HERE]',
               category: '[ENTER CATEGORY NAME HERE]',
               categoryId: '[ENTER CATEGORY ID HERE]',
               mapping: 'url',
               reactionsEnabled: false,
               emitMetadata: true,
               theme: 'dark',
               inputPosition: 'top',
               lang: 'en',
               lazyLoading: false
           })
    ]
}

๐Ÿ’ก How to get my repo and category ids?

You can easily get it from Giscus Main page.

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.