文档 — 接入
零框架绑定。Astro 默认不发 JS,评论只在岛屿里水合。
在后台创建站点并验证你要嵌入的域名。
用 client:load 岛屿或直接把 <script type="module"> 放到 layout,无需额外打包配置。
在 .astro 页面或 layout 里加入 <div id="comment"></div>。
需要响应式 props 就包一层 client:load 岛屿,否则直接 module script 足够。
---
// Base.astro — works for both SSG & SSR
---
<html>
<head>
<link rel="stylesheet" href="https://unpkg.com/@roudanio/awesome-comment@latest/dist/style.css" />
</head>
<body>
<slot />
<div id="comment" style="min-height:360px"></div>
<script type="module">
import { getInstance } from 'https://unpkg.com/@roudanio/awesome-auth@latest/dist/awesome-auth.js';
import Comment from 'https://unpkg.com/@roudanio/awesome-comment@latest/dist/awesome-comment.js';
const auth = getInstance({ googleId: "YOUR_GOOGLE_CLIENT_ID", root: "https://awesomecomment.org/api/site/auth" });
Comment.init(document.querySelector('#comment'), {
siteId: "YOUR_SITE_ID",
apiUrl: "https://awesomecomment.org",
awesomeAuth: auth,
postId: location.pathname,
locale: navigator.language,
});
</script>
</body>
</html>client:load 或 client:visible 延迟到可见再加载。支持。Starlight 基于 Astro,给自定义文档页或覆盖默认 layout 即可。
组件 gz 后约 18kB,只水合评论岛屿,Astro 仍可 100 分。