Gwitter

July 13, 2025 ยท View on GitHub

ไธญๆ–‡็‰ˆๆœฌ

๐ŸŽฎ Playground

  • ๐ŸŒ Live Demo: https://simonaking.com/Gwitter - Experience Gwitter in action
  • ๐Ÿ’ญ Share Your Thoughts: Create an Issue to join the conversation
  • ๐Ÿ“š Browse Discussions: Explore existing thoughts and insights on the demo site

โœจ Project Introduction

โœจ The Story Behind "Gwitter"

Ever wondered what happens when you combine the world's most powerful issue tracker with the globe's favorite microblogging platform? ๐Ÿค”

GitHub Issues ๐Ÿ“ = The unsung hero of note-taking (seriously, it's brilliant!)

Twitter ๐Ÿฆ = Where thoughts become conversations worldwide

Gwitter ๐Ÿš€ = Turn GitHub Issues into your personal microblog platform!

preview

๐Ÿ“ฑ Author's Gwitter: https://simonaking.com/blog/weibo/ - See how Gwitter is used in practice

Gwitter is a lightweight microblogging application built on GitHub Issues. It records my thoughts on technology, life insights, and interesting discoveries. Welcome to join the discussion!

๐Ÿš€ Key Features

  1. ๐Ÿ“ GitHub Issues Based
    • Utilizes GitHub Issues as content storage, supporting GitHub's label system for content categorization
  2. ๐Ÿ‘ Social Interaction
    • Like Feature: Supports GitHub Reactions (๐Ÿ‘ โค๏ธ ๐Ÿ˜„ ๐Ÿ˜ฎ ๐Ÿ˜ข ๐Ÿ˜ก ๐Ÿš€ ๐Ÿ‘€)
    • Comment System: Complete commenting functionality with nested replies support
  3. โœจ Visual Experience
    • Beautiful Animations: Smooth page animations using Framer Motion
    • Responsive Design: Perfect adaptation for desktop, tablet, and mobile devices
    • Skeleton Screen: Elegant loading state display
  4. ๐ŸŒ User Experience
    • Internationalization Support: Built-in Chinese and English bilingual support
    • Infinite Scroll: Smart pagination loading for smooth browsing experience
  5. ๐Ÿค– Automated Synchronization
    • Multi-platform Sync: Automatically sync newly published Issues to other platforms via GitHub Actions

๐Ÿ“ Usage Instructions

Publishing Content

  1. Create a new Issue in the configured GitHub repository
  2. Write content using Markdown format
  3. Add appropriate labels for categorization
  4. Content will automatically sync to the gwitter application after publishing Create issue example

Content Management

  • Edit: Edit directly in GitHub Issues
  • Delete: Close the corresponding Issue
  • Categorize: Use GitHub Labels for content categorization
  • Pin: Control display order through Issue creation sequence

๐Ÿค– Automated Synchronization Configuration

Gwitter supports automatically syncing newly published Issues to Telegram and GitHub Gist via GitHub Actions.

  1. Create Sync Script

    • Refer to sync.js implementation
    • Create .github/workflows/sync.yml in the repository
  2. Configure Environment Variables In GitHub repository Settings > Secrets and variables

  3. Telegram Configuration

    • Create Telegram Bot (via @BotFather)
    • Get Bot Token and target channel/group Chat ID
    • Add Bot to target channel and grant admin permissions

๐Ÿ› ๏ธ Tech Stack

  • Frontend Framework: React 18 + TypeScript
  • Build Tool: Rsbuild (Fast build tool based on Rspack)
  • Styling Solution: Emotion (CSS-in-JS)
  • Animation Library: Framer Motion + React Flip Move
  • State Management: React Hooks
  • Network Requests: Axios + GitHub GraphQL API
  • Internationalization: i18next
  • Code Standards: ESLint + Prettier
Gwitter/
โ”œโ”€โ”€ src/                  # Main source code
โ”‚   โ”œโ”€โ”€ components/       # React components
โ”‚   โ”‚   โ”œโ”€โ”€ common/      # Shared UI components
โ”‚   โ”‚   โ”œโ”€โ”€ About.tsx    # About page component
โ”‚   โ”‚   โ”œโ”€โ”€ CommentInput.tsx # Comment input component
โ”‚   โ”‚   โ””โ”€โ”€ ...
โ”‚   โ”œโ”€โ”€ hooks/           # Custom React hooks
โ”‚   โ”‚   โ””โ”€โ”€ useAuth.tsx  # Authentication hook
โ”‚   โ”œโ”€โ”€ utils/           # Utility functions
โ”‚   โ”‚   โ”œโ”€โ”€ cache.ts     # Caching utilities
โ”‚   โ”‚   โ”œโ”€โ”€ request.ts   # API request utilities
โ”‚   โ”‚   โ””โ”€โ”€ index.ts     # Common utilities
โ”‚   โ”œโ”€โ”€ config/          # Configuration files
โ”‚   โ”‚   โ””โ”€โ”€ index.ts     # Main configuration
โ”‚   โ”œโ”€โ”€ i18n/            # Internationalization
โ”‚   โ”‚   โ”œโ”€โ”€ index.ts     # i18n setup
โ”‚   โ”‚   โ””โ”€โ”€ locales/     # Language files
โ”‚   โ”œโ”€โ”€ types/           # TypeScript type definitions
โ”‚   โ”‚   โ””โ”€โ”€ global.d.ts  # Global types
โ”‚   โ””โ”€โ”€ lib/             # External libraries
โ”‚       โ””โ”€โ”€ collapse.js  # UI collapse functionality
โ”œโ”€โ”€ demo/                # Demo examples
โ”‚   โ”œโ”€โ”€ npm-demo/        # NPM/React demo
โ”‚   โ”‚   โ”œโ”€โ”€ src/         # React source files
โ”‚   โ”‚   โ”‚   โ”œโ”€โ”€ App.tsx  # Main demo component
โ”‚   โ”‚   โ”‚   โ”œโ”€โ”€ config/  # Demo configuration
โ”‚   โ”‚   โ”‚   โ””โ”€โ”€ ...
โ”‚   โ”‚   โ”œโ”€โ”€ package.json # Dependencies
โ”‚   โ”‚   โ””โ”€โ”€ vite.config.ts # Build config
โ”‚   โ”œโ”€โ”€ umd-demo/        # UMD/Browser demo
โ”‚   โ”‚   โ””โ”€โ”€ index.html   # Complete HTML demo
โ”‚   โ””โ”€โ”€ README.md        # Demo documentation
โ”œโ”€โ”€ docs/                # Documentation assets
โ”‚   โ””โ”€โ”€ *.png           # Setup screenshots
โ””โ”€โ”€ dist/               # Built files for distribution
    โ”œโ”€โ”€ gwitter.min.js  # UMD bundle
    โ””โ”€โ”€ gwitter.min.css # Styles

๐Ÿ“ฆ Installation & Usage

๐ŸŽฏ Quick Start: Check out our live demos to see Gwitter in action!

๐Ÿ“– Demo Examples

Two demo examples to get you started:

๐Ÿ”ง NPM Demo - React Development

For modern React applications with build tools.

cd demo/npm-demo
npm install
npm run dev

๐ŸŒ UMD Demo - Browser Integration

For existing websites without build tools.

<!-- Just open index.html in your browser -->
<script src="https://unpkg.com/gwitter/dist/gwitter.min.js"></script>
<link rel="stylesheet" href="https://unpkg.com/gwitter/dist/gwitter.min.css">

๐Ÿ“‹ Setup Requirements

Both demos need GitHub configuration:

  1. Create a GitHub repository for your content
  2. Generate a Personal Access Token with repo and read:user permissions
  3. Create a GitHub OAuth Application
  4. Update demo config files with your details

See Configuration Setup for detailed instructions.

For modern JavaScript projects using module bundlers:

Requirements

  • React: ^18.0.0 or higher
  • React DOM: ^18.0.0 or higher

Installation

npm install gwitter react react-dom
# or
yarn add gwitter react react-dom

Usage

import gwitter from 'gwitter';
import 'gwitter/dist/gwitter.min.css';

gwitter({
  container: document.getElementById('comments'),
  config: {
    request: {
      // GitHub Personal Access Token
      token: ['your_token_part1', 'your_token_part2'],

      // OAuth configuration
      clientID: 'your_github_oauth_client_id',
      clientSecret: 'your_github_oauth_client_secret',

      // GitHub repository configuration
      owner: 'your_github_username',
      repo: 'your_repo_name',

      // Pagination configuration
      pageSize: 6,

      // CORS proxy (optional)
      autoProxy: 'https://cors-anywhere.azm.workers.dev/https://github.com/login/oauth/access_token',
    },
    app: {
      // Application feature toggles
      onlyShowOwner: false,
      enableRepoSwitcher: false,
      enableAbout: false,
      enableEgg: false,
    },
  }
});

Method 2: UMD (Browser)

For direct browser usage without build tools:

<!-- Include React and ReactDOM -->
<script crossorigin src="https://unpkg.com/react@18/umd/react.production.min.js"></script>
<script crossorigin src="https://unpkg.com/react-dom@18/umd/react-dom.production.min.js"></script>

<!-- Include Gwitter -->
<script src="https://unpkg.com/gwitter/dist/gwitter.min.js"></script>
<link rel="stylesheet" href="https://unpkg.com/gwitter/dist/gwitter.min.css">

<script>
  gwitter({
    container: document.getElementById('comments'),
    config: {
      request: {
        // GitHub Personal Access Token
        token: ['your_token_part1', 'your_token_part2'],

        // OAuth configuration
        clientID: 'your_github_oauth_client_id',
        clientSecret: 'your_github_oauth_client_secret',

        // GitHub repository configuration
        owner: 'your_github_username',
        repo: 'your_repo_name',

        // Pagination configuration
        pageSize: 6,

        // CORS proxy (optional)
        autoProxy: 'https://cors-anywhere.azm.workers.dev/https://github.com/login/oauth/access_token',
      },
      app: {
        // Application feature toggles
        onlyShowOwner: false,
        enableRepoSwitcher: false,
        enableAbout: false,
        enableEgg: false,
      },
    }
  });
</script>

3. Configuration Setup

Before using Gwitter, you need to set up GitHub configuration:

3.1 Create GitHub Repository

  1. Create a new repository on GitHub to store your microblog content
  2. Record the repository's owner (username) and repo (repository name)

Similar to https://github.com/SimonAKing/weibo/issues

GitHub repository example

3.2 Apply for GitHub Personal Access Token

  1. Visit GitHub Settings > Developer settings > Personal access tokens

  2. Click "Generate new token (classic)"

    Generate new token
  3. Select the following permissions:

    • repo (Full repository access)
    • read:user (Read user information)
  4. Generate and save the token

    Token permissions

3.3 Create GitHub OAuth Application

  1. Visit GitHub Settings > Developer settings > OAuth Apps

  2. Click "New OAuth App"

    OAuth Apps
  3. Fill in application information:

    • Application name: Gwitter
    • Homepage URL: Your deployment domain
    • Authorization callback URL: Your deployment domain
  4. After creation, obtain Client ID and Client Secret

4. API Reference

gwitter(options)

Main function to initialize and render Gwitter.

Parameters:

  • options (Object): Configuration options for Gwitter

options.container (HTMLElement | string) - Required

  • The DOM element or CSS selector where Gwitter will be rendered
  • Example: document.getElementById('comments') or '#comments'

options.config (Object) - Required

  • Configuration object containing request and app settings

options.config.request (Object) - Required

  • GitHub API and authentication configuration
PropertyTypeRequiredDescriptionExample
tokenstring[]โœ…GitHub Personal Access Token split into two parts for security['ghp_xxxx', 'xxxx']
clientIDstringโœ…GitHub OAuth Application Client ID'your_client_id'
clientSecretstringโœ…GitHub OAuth Application Client Secret'your_client_secret'
ownerstringโœ…GitHub repository owner (username)'your_username'
repostringโœ…GitHub repository name'your_repo_name'
pageSizenumberโŒNumber of issues to load per page (default: 6)6
autoProxystringโŒCORS proxy URL for OAuth requests'https://cors-anywhere.azm.workers.dev/https://github.com/login/oauth/access_token'

options.config.app (Object) - Optional

  • Application behavior configuration
PropertyTypeDefaultDescriptionExample
onlyShowOwnerbooleanfalseShow only repository owner's issuesfalse
enableRepoSwitcherbooleanfalseEnable repository switching functionalityfalse
enableAboutbooleanfalseShow About page/sectionfalse
enableEggbooleanfalseEnable easter egg featuresfalse

Returns:

  • Promise<void> - Resolves when Gwitter is successfully initialized

Example:

gwitter({
  container: '#comments',
  config: {
    request: {
      token: ['ghp_xxxx', 'xxxx'],
      clientID: 'your_client_id',
      clientSecret: 'your_client_secret',
      owner: 'your_username',
      repo: 'your_repo_name',
      pageSize: 10,
    },
    app: {
      onlyShowOwner: true,
      enableAbout: true,
    }
  }
});

๐Ÿค Contributing

Issues and Pull Requests are welcome!


Thank you for your attention and support!

If you like this project, don't forget to give it a โญ!

Made with โค๏ธ by SimonAKing