Skip to content

Conversation

azu
Copy link
Member

@azu azu commented Aug 20, 2025

概要

textlint-website-generatorを使用して、GitHub Pages上で動作するtextlintプレビューサイトを追加しました。これにより、ユーザーがブラウザ上で直接@textlint-ja/textlint-rule-preset-ai-writingの動作を確認できるようになります。

変更内容

主な機能

  • GitHub Pagesへの自動デプロイ: mainブランチへのpush時に自動的にWebサイトがデプロイされます
  • PRプレビュー機能: Pull Request作成時に自動的にプレビューサイトが生成され、変更内容を確認できます
  • インタラクティブなtextlintチェッカー: ブラウザ上でリアルタイムにテキストの校正が可能

実装詳細

ディレクトリ構造

example/
├── .textlintrc.json     # Webサイト用のtextlint設定
├── package.json         # textlint-website-generator設定
└── dist/               # ビルド成果物(.gitignore済み)

GitHub Actions ワークフロー

  1. deploy-website.yml: mainブランチへのpush時にGitHub Pagesへデプロイ

    • textlintルールのビルド
    • exampleディレクトリでWebサイト生成
    • GitHub Pagesへのアーティファクトアップロード
  2. website-preview.yml: PR作成時にプレビューサイトを生成

    • pr-preview-actionを使用したプレビューデプロイ
    • PRごとに独立したプレビューURL生成
    • PRクローズ時の自動クリーンアップ

設定ファイル

  • example/.textlintrc.json: Webサイト用のtextlint設定(プリセットを有効化)
  • example/package.json: textlint-website-generatorの設定
    • タイトル: "AI Writing Checker"
    • メタデータ設定(namespace、homepage)

テスト方法

ローカルでの動作確認

# ルールのビルド
npm run build

# exampleディレクトリに移動
cd example

# 依存関係のインストール
npm install

# Webサイトのビルド
npm run website

# distディレクトリにHTMLファイルが生成されることを確認
ls -la dist/

ブラウザでの確認

  1. example/dist/index.htmlをブラウザで開く
  2. テキストエリアに以下のようなAIライティング特有の文章を入力:
    • 「〜について説明します:」(全角コロンパターン)
    • 重要:テキスト」(見出し内の太字パターン)
    • その他、このプリセットが検出するパターン
  3. リアルタイムでエラーが表示されることを確認

GitHub Pagesでの確認

影響範囲

  • 既存の機能への影響はありません
  • GitHub Pagesの設定が必要(リポジトリ設定から有効化)
  • ビルド成果物は.gitignoreに追加済み

チェックリスト

  • ローカルでWebサイトが正常にビルドされる
  • GitHub Actionsワークフローが正常に動作する
  • PRプレビュー機能が動作する
  • textlintルールが正しく適用される
  • GitHub Pages設定の有効化(マージ後に設定)

関連情報

- textlint-website-generatorを使用したWebサイト生成
- exampleディレクトリ構成でプリセットをインストール
- PRプレビュー機能(rossjrw/pr-preview-action使用)
- メインブランチへの自動デプロイ設定
Copy link
Contributor

github-actions bot commented Aug 20, 2025

PR Preview Action v1.6.2
Preview removed because the pull request was closed.
2025-08-20 01:12 UTC

.textlintrc.json Outdated
Comment on lines 5 to 11
"preset-japanese": true
"preset-ai-writing": {
"no-ai-colon-continuation": true,
"no-ai-emphasis-patterns": true,
"no-ai-hype-expressions": true,
"no-ai-list-formatting": true,
"ai-tech-writing-guideline": true
}
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

revert

package.json Outdated
Comment on lines 62 to 64
"@textlint/website-generator": "^0.18.0",
"@types/node": "^24.0.1",
"gh-pages": "^6.3.0",
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

remove

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

remove

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

gitignore?

- .textlintrc.jsonを元のpreset-japanese設定に戻す
- package.jsonから不要な依存関係とスクリプトを削除
- website関連の一時ファイルを削除
- exampleからgh-pages依存を削除
@azu azu added the Type: Documentation Documentation only changes label Aug 20, 2025
@azu azu marked this pull request as ready for review August 20, 2025 01:11
@azu azu merged commit 63350c2 into main Aug 20, 2025
5 checks passed
@azu azu deleted the feature/add-github-pages-website branch August 20, 2025 01:11
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Type: Documentation Documentation only changes
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant