AIGCS

Widget Embedding

How to embed the AIGCS comment widget on your website

Overview

The AIGCS widget is a native JavaScript Web Component with Shadow DOM isolation — zero framework dependencies, compatible with any website.

Quick Embed

Option 1: Container Element (Auto-detect)

<div id="aigcs"
  data-domain="blog.example.com"
  data-path="/post/hello-world"
  data-server="https://comments.example.com"
  data-auto-generate="true">
</div>
<script src="https://comments.example.com/widget.js" defer></script>

Option 2: Custom Element

<aigcs-widget
  domain="blog.example.com"
  path="/post/hello-world"
  server="https://comments.example.com"
  theme="auto"
  lang="zh">
</aigcs-widget>
<script src="https://comments.example.com/widget.js" defer></script>

Option 3: JavaScript API

<div id="my-comments"></div>
<script>
  AIGCS.init({
    el: '#my-comments',
    site: 'blog.example.com',
    path: '/post/hello-world',
    server: 'https://comments.example.com',
    lang: 'en',
    theme: 'auto',
    autoGenerate: false,
    commentLimit: 0,
    maxReactions: 5,
  });
</script>

HTML Attributes Reference

AttributeDefaultDescription
domainlocation.hostnameSite domain registered in AIGCS
pathlocation.pathnamePage path for comment lookup
server(same origin)AIGCS server URL
themeautoColor mode (auto/light/dark)
light-themelightLight theme variant name
dark-themedark_dimmedDark theme variant name
langauto-detectLanguage (zh/en)
auto-generatefalseAuto-trigger AI generation (true/false)
hide-titlefalseHide the comment section title
disable-copyrightfalseHide "Powered by AIGCS"
comment-limit0Max comments to display (0 = unlimited)
max-reactions5Visible reactions before folding

JavaScript API Reference

AIGCS.init(options)

OptionTypeDefaultDescription
elstring | HTMLElementMount element selector or node
sitestringSite domain (required)
pathstringlocation.pathnamePage path
serverstring(same origin)Server URL
lang'zh' | 'en'auto-detectLanguage
theme'auto' | 'light' | 'dark''auto'Color mode
lightThemestring'light'Light theme variant
darkThemestring'dark_dimmed'Dark theme variant
autoGeneratebooleanfalseAuto-trigger AI generation
commentLimitnumber0Max comments (0 = unlimited)
maxReactionsnumber5Visible reactions before fold

Theme System

Light Themes

NameDescription
lightDefault light
light_high_contrastHigh contrast light
light_protanopiaAccessible (protanopia)
light_tritanopiaAccessible (tritanopia)
noborder_lightLight without borders
catppuccin_latteCatppuccin Latte
gruvbox_lightGruvbox light
froFro theme

Dark Themes

NameDescription
dark_dimmed / dimmedDefault dimmed dark
darkFull dark
dark_high_contrastHigh contrast dark
dark_protanopiaAccessible (protanopia)
dark_tritanopiaAccessible (tritanopia)
transparent_darkTransparent dark
noborder_darkDark without borders
noborder_grayGray without borders
cobaltRStudio Cobalt
purple_darkPurple dark
gruvboxGruvbox
gruvbox_darkGruvbox dark
catppuccin_frappeCatppuccin Frappé
catppuccin_macchiatoCatppuccin Macchiato
catppuccin_mochaCatppuccin Mocha

Avatar Cache Modes

Configure in Site Settings under avatarMode:

ModeDescription
aigcsAIGCS proxies and caches avatars locally (WebP, 10K limit)
mravatarUse Mravatar external service
offNo avatar proxy

Framework Integration

React

import { useEffect, useRef } from 'react';
 
function AIGCSWidget({ domain, path }: { domain: string; path: string }) {
  const ref = useRef<HTMLDivElement>(null);
 
  useEffect(() => {
    const script = document.createElement('script');
    script.src = 'https://comments.example.com/widget.js';
    script.defer = true;
    ref.current?.appendChild(script);
 
    return () => { script.remove(); };
  }, []);
 
  return (
    <div
      ref={ref}
      id="aigcs"
      data-domain={domain}
      data-path={path}
    />
  );
}

Vue

<template>
  <div id="aigcs" :data-domain="domain" :data-path="path" />
</template>
 
<script setup>
import { onMounted } from 'vue';
const props = defineProps({ domain: String, path: String });
 
onMounted(() => {
  const script = document.createElement('script');
  script.src = 'https://comments.example.com/widget.js';
  script.defer = true;
  document.body.appendChild(script);
});
</script>

Markdown Support

Comments are rendered as GitHub Flavored Markdown using the marked library. All comment content — both AI-generated and visitor-submitted — supports:

  • Bold, italic, inline code
  • Code blocks with syntax language tags
  • Links, ordered/unordered lists, blockquotes

Raw markdown is sanitized server-side via DOMPurify before rendering.

Full vs Lite

The widget is available in two build variants:

VersionSizeCSSUse Case
aigcs.js (Full)30 KB gzipInlineQuick embed, zero config
aigcs-lite.js (Lite)25 KB gzipExternalCustom theming, CSS control

Full Version (default)

<script src="https://cdn.jsdelivr.net/npm/@aigcs/widget@1/dist/aigcs.js" defer></script>

Lite Version

<script src="https://cdn.jsdelivr.net/npm/@aigcs/widget@1/dist/aigcs-lite.js" defer></script>
<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/@aigcs/widget@1/dist/aigcs.css">

The Lite version outputs the same HTML structure but leaves styling entirely to you. Override CSS variables for full control:

aigcs-widget {
  --outer-bg: #f5f5f5;
  --card-bg: #fafafa;
  --text: #1f2937;
  --text-secondary: #6b7280;
  --border: #e5e7eb;
  --link: #3b82f6;
  --error-color: #ef4444;
}

Performance

  • Shadow DOM — complete style isolation, no CSS conflicts
  • ETag — conditional requests with 304 support
  • CDN CacheCache-Control: public, s-maxage=300, stale-while-revalidate=86400
  • Lazy Loading — defer loading until widget is in viewport