logo
0
0
WeChat Login
Huazie<huazie.lgh@gmail.com>
Mod: 添加模板引擎支持描述

Hexo Comments Gitalk

NPM version Required Node.js version Required Hexo version License GitHub Repo stars

Easily integrate the Gitalk comment system into your Hexo blog, a modern comment solution based on GitHub Issues.

中文说明/Chinese Documentation

Features

FeatureDescriptionAdvantages
GitHub IntegrationBased on GitHub Issues, no database requiredZero maintenance cost, high availability
OAuth AuthenticationSupports GitHub OAuth secure loginProtects user privacy, secure and reliable
Theme SwitchingSupports light/dark theme auto-switchingPerfectly adapts to various theme styles
Responsive DesignAdapts to various device screensMobile-friendly user experience
Multi-language SupportSupports multiple interface languagesInternationalization friendly
Easy ConfigurationSimple YAML configurationQuick setup, flexible customization

Quick Start

Installation

# 1. Install multi-comment system core plugin (required) npm install hexo-generator-comments --save # 2. Install Gitalk comment plugin npm install hexo-comments-gitalk --save

Note: hexo-comments-gitalk needs to be used with hexo-generator-comments More info: hexo-generator-comments

Configuration Guide

Basic Configuration

Add the following content to your Hexo site configuration _config.yml or theme configuration _config.yml, _config.[theme].yml:

gitalk: # Enable Gitalk comment system enable: false # GitHub Application Client ID client_id: your-client-id # GitHub Application Client Secret client_secret: your-client-secret # GitHub repository name repo: your-repo-name # GitHub repository owner github_id: your-github-id # GitHub repository administrator admin_user: your-github-id # Page unique identifier issue_term: pathname # Language settings language: # Enable distraction-free mode distraction_free_mode: true # Proxy URL (optional) proxy: https://cors-anywhere.azm.workers.dev/https://github.com/login/oauth/access_token

Important: Replace the placeholders in the configuration with your actual GitHub application information

Configuration Options Details

OptionTypeDefaultRequiredDescription
enableBooleanfalseYesEnable Gitalk comment system
client_idString-YesGitHub Application Client ID
client_secretString-YesGitHub Application Client Secret
repoString-YesGitHub repository name for storing comments
github_idString-YesGitHub repository owner's username
admin_userString-YesGitHub repository administrator's username
issue_termStringpathnameYesHow to generate page unique identifier
languageStringnavigator.languageNoInterface language settings
distraction_free_modeBooleantrueYesEnable distraction-free mode
proxyString-NoProxy URL for solving CORS issues

Advanced Configuration Options

issue_term Mapping Methods

ValueDescriptionUse Cases
pathnameUse page path as issue titleRecommended, suitable for most scenarios
urlUse full page URL as issue titleWhen domain information is needed
titleUse page title as issue titleWhen you want more friendly issue titles
[issue-number]Specify specific issue numberManual comment management

language Options

Language CodeLanguage Name
enEnglish
zh-CNSimplified Chinese
zh-TWTraditional Chinese
es-ESSpanish
frFrench
ruRussian
......

Supported Template Engines

This plugin supports all Hexo themes using the following template engines:

Template EngineFile ExtensionSupport Status
EJS.ejs✅ Fully Supported
Nunjucks.njk✅ Fully Supported
JSX + Inferno.jsx✅ Fully Supported

Prerequisites

Before getting started, please ensure the following requirements are met:

1. GitHub Repository Preparation

  • Have a public GitHub repository
  • Issues feature is enabled for the repository

2. Create GitHub OAuth Application

Note: The Authorization callback URL of the OAuth application can be set to your blog domain

How It Works

Detailed Process

  1. Page Loading: Visitor opens the page, Gitalk script starts working
  2. Search Issue: Search for related issues in the specified repository based on configured issue_term
  3. Display Comments: If corresponding issue is found, display comments from it
  4. OAuth Authentication: Visitors need to log in via GitHub OAuth to comment
  5. Create Issue: When administrator visits the page for the first time, automatically create a new issue

System Requirements

DependencyVersion RequirementDescription
Node.js>= 14.0.0JavaScript runtime environment
Hexo>= 5.3.0Static site generator
GitHub RepositoryPublic repositoryStores comment data

Related Links

Official Resources

Hexo Documentation

Related Plugins

License

This project is open source under the MIT license.