静的サイトジェネレータを作った

.md

rustで静的サイトジェネレータを作りました。ailogといいます。hugoからの移行になります。

ailogは、最初にatproto-comment-system(oauth)とask-AIという機能をつけました。

quick start

$ git clone https://git.syui.ai/ai/log
$ cd log
$ cargo build
$ ./target/debug/ailog init my-blog
$ ./target/debug/ailog serve my-blog

install

$ cargo install --path .
---
$ export CARGO_HOME="$HOME/.cargo"
$ export RUSTUP_HOME="$HOME/.rustup"
$ export PATH="$HOME/.cargo/bin:$PATH"
---
$ which ailog
$ ailog -h

build deploy

$ cd my-blog
$ vim config.toml
$ ailog new test
$ vim content/posts/`date +"%Y-%m-%d"`.md
$ ailog build

# publicの中身をweb-serverにdeploy
$ cp -rf ./public/* ./web-server/root/

atproto-comment-system

example

$ cd ./oauth
$ npm i
$ npm run build
$ npm run preview
# Production environment variables
VITE_APP_HOST=https://syui.ai
VITE_OAUTH_CLIENT_ID=https://syui.ai/client-metadata.json
VITE_OAUTH_REDIRECT_URI=https://syui.ai/oauth/callback
VITE_ADMIN_DID=did:plc:uqzpqmrjnptsxezjx4xuh2mn

# Base collection (all others are derived via getCollectionNames)
VITE_OAUTH_COLLECTION=ai.syui.log

# AI Configuration
VITE_AI_ENABLED=true
VITE_AI_ASK_AI=true
VITE_AI_PROVIDER=ollama
VITE_AI_MODEL=gemma3:4b
VITE_AI_HOST=https://ollama.syui.ai
VITE_AI_SYSTEM_PROMPT="ai"
VITE_AI_DID=did:plc:4hqjfn7m6n5hno3doamuhgef

# API Configuration
VITE_BSKY_PUBLIC_API=https://public.api.bsky.app
VITE_ATPROTO_API=https://bsky.social

これはailog oauth build my-blog./my-blog/config.tomlから./oauth/.env.productionが生成されます。

$ ailog oauth build my-blog

use

簡単に説明すると、./oauthで生成するのがatproto-comment-systemです。

<script type="module" crossorigin src="/assets/comment-atproto-${hash}}.js"></script>
<link rel="stylesheet" crossorigin href="/assets/comment-atproto-${hash}.css">
<section class="comment-section"> <div id="comment-atproto"></div> </section>

ただし、oauthであるため、色々と大変です。本番環境(もしくは近い形)でテストを行いましょう。cf, tailscale, ngrokなど。

tunnel: ${hash}
credentials-file: ${path}.json

ingress:
  - hostname: example.com
    service: http://localhost:4173
    originRequest:
      noHappyEyeballs: true

  - service: http_status:404
# tunnel list, dnsに登録が必要です
$ cloudflared tunnel list
$ cloudflared tunnel --config cloudflared-config.yml run
$ cloudflared tunnel route dns ${uuid} example.com
$ ailog auth init
$ ailog stream server

このコマンドでai.syui.logjetstreamから監視して、書き込みがあれば、管理者のai.syui.log.userに記録され、そのuser-listに基づいて、コメント一覧を取得します。

つまり、コメント表示のアカウントを手動で設定するか、自動化するか。自動化するならserverでailog stream serverを動かさなければいけません。

ask-AI

ask-AIの仕組みは割愛します。後に変更される可能性が高いと思います。

llm, mcp, atprotoなどの組み合わせです。

現在、/index.jsonを監視して、更新があれば、翻訳などを行い自動ポストする機能があります。

code syntax

# comment
d=${0:a:h}
// This is a comment
fn main() {
    println!("Hello, world!");
}
// This is a comment
console.log("Hello, world!");