← 返回 Skills 市场
bezkom

Astro

作者 bezkom · GitHub ↗ · v1.0.1
cross-platform ✓ 安全检测通过
511
总下载
0
收藏
7
当前安装
2
版本数
在 OpenClaw 中安装
/install astro
功能描述
Deploy multilingual static websites on Cloudflare with Astro using markdown sources, supporting i18n, free hosting, and Git-based or direct deployment.
使用说明 (SKILL.md)

Astro Static Site Generator

Deploy multilingual static websites for free on Cloudflare using Astro framework.

Prerequisites

  • Node.js 20+ installed
  • Cloudflare account (free)
  • Git repository (GitHub, GitLab, or Bitbucket)

Quick Start

1. Create Project

npm create astro@latest my-site -- --template minimal
cd my-site
npm install

2. Configure for Cloudflare

Static Sites (Recommended for most use cases)

No adapter needed. Use default static output:

// astro.config.mjs
import { defineConfig } from 'astro/config';

export default defineConfig({
  site: 'https://your-site.pages.dev',
});

SSR/Edge Functions (Optional)

If you need server-side rendering or edge functions:

npm install @astrojs/cloudflare
// astro.config.mjs
import { defineConfig } from 'astro/config';
import cloudflare from '@astrojs/cloudflare';

export default defineConfig({
  output: 'server',
  adapter: cloudflare(),
  site: 'https://your-site.pages.dev',
});

3. Deploy to Cloudflare

Git Integration (Recommended)

  1. Push to GitHub/GitLab
  2. Cloudflare Dashboard → Pages → Create project → Connect to Git
  3. Configure:
    • Build command: npm run build
    • Build output: dist

Direct Upload

# Deploy (authenticate via Cloudflare dashboard or wrangler)
npx wrangler pages deploy dist

Multilingual Configuration

Astro Config

// astro.config.mjs
export default defineConfig({
  i18n: {
    defaultLocale: 'en',
    locales: ['en', 'es', 'fr', 'de'],
    routing: {
      prefixDefaultLocale: false,  // /about instead of /en/about
    },
  },
});

Routing Modes:

Setting URL Structure Best For
prefixDefaultLocale: false /about, /es/about Default locale at root
prefixDefaultLocale: true /en/about, /es/about All locales prefixed

Content Structure

src/content/
├── config.ts          # Content collection schema
└── docs/
    ├── en/
    │   ├── index.md
    │   └── guide.md
    ├── es/
    │   ├── index.md
    │   └── guide.md
    └── fr/
        ├── index.md
        └── guide.md

Content Collection Schema

// src/content/config.ts
import { defineCollection, z } from 'astro:content';

const docs = defineCollection({
  type: 'content',
  schema: z.object({
    title: z.string(),
    description: z.string(),
    lang: z.enum(['en', 'es', 'fr', 'de']),
  }),
});

export const collections = { docs };

Note: Run npx astro sync after adding content collections to generate types.

Language Switcher Component

---
// src/components/LanguageSwitcher.astro
const languages = {
  en: 'English',
  es: 'Español',
  fr: 'Français',
  de: 'Deutsch',
};

const currentPath = Astro.url.pathname;
const currentLang = Astro.currentLocale || 'en';
---

\x3Cselect onchange="window.location = this.value">
  {Object.entries(languages).map(([code, name]) => (
    \x3Coption 
      value={`/${code}${currentPath}`} 
      selected={code === currentLang}
    >
      {name}
    \x3C/option>
  ))}
\x3C/select>

File Structure

my-site/
├── astro.config.mjs      # Astro configuration
├── package.json
├── public/
│   ├── favicon.svg
│   └── _redirects        # Cloudflare redirects (optional)
├── src/
│   ├── components/
│   │   └── LanguageSwitcher.astro
│   ├── content/
│   │   ├── config.ts
│   │   └── blog/
│   │       ├── en/
│   │       └── es/
│   ├── layouts/
│   │   └── BaseLayout.astro
│   └── pages/
│       ├── index.astro
│       ├── en/
│       │   └── index.astro
│       └── es/
│           └── index.astro

Cloudflare Pages Settings

Setting Value
Build command npm run build
Build output dist
Node version 20
Environment NODE_VERSION=20

Custom Domain

Cloudflare Dashboard → Pages → your-site → Custom domains → Add domain

Redirects

Create public/_redirects:

/  /en/  302
/old-page  /new-page  301

Commands Reference

Command Description
npm run dev Start dev server
npm run build Build for production
npm run preview Preview production build
npx astro sync Generate content collection types
npx wrangler login Authenticate with Cloudflare
npx wrangler pages deploy dist Deploy to Cloudflare

Blog with Content Collections

---
// src/pages/blog/[...slug].astro
import { getCollection } from 'astro:content';

export async function getStaticPaths() {
  const posts = await getCollection('blog');
  return posts.map(post => ({
    params: { slug: post.slug },
    props: { post },
  }));
}

const { post } = Astro.props;
const { Content } = await post.render();
---

\x3Carticle>
  \x3Ch1>{post.data.title}\x3C/h1>
  \x3CContent />
\x3C/article>

Troubleshooting

Build Fails on Cloudflare

Set NODE_VERSION=20 in Cloudflare Pages environment variables.

404 on Nested Routes

// astro.config.mjs
export default defineConfig({
  trailingSlash: 'always',
});

i18n Not Working

Ensure:

  1. Locales match folder names exactly
  2. Content files have correct lang frontmatter
  3. Run npx astro sync after creating content collections

Content Collection Type Errors

Run npx astro sync to generate TypeScript types.

Resources

Scripts

Script Description
astro-new-post.py Create multilingual blog posts
astro-i18n-check.py Validate translation coverage

Script Usage

# Create a new post in multiple languages
python scripts/astro-new-post.py --title "My Post" --langs en,es,fr

# Create with author and tags
python scripts/astro-new-post.py --title "Tutorial" --langs en,es --author "John" --tags tutorial,astro

# Check translation coverage
python scripts/astro-i18n-check.py --langs en,es,fr

# Check specific content directory
python scripts/astro-i18n-check.py --content-dir src/content/blog --langs en,es

# Output as JSON
python scripts/astro-i18n-check.py --langs en,es,fr --json

All scripts use only Python standard library (no dependencies).

安全使用建议
This skill is internally consistent and appears benign, but review these before installing: (1) SKILL.md expects Node.js (20+) and use of npx/wrangler — the registry metadata didn't list required binaries, so ensure you have Node and optionally Python installed if you want to run the included scripts. (2) The two scripts are simple and local: astro-i18n-check.py checks files under src/content, and astro-new-post.py creates markdown files in src/content/blog — they will write to your repository, so run them in a safe project or branch. (3) Deployment requires your Cloudflare account credentials (via wrangler or dashboard) — the skill does not store or request them, but any deployment command you run will use those credentials. (4) Because the skill's source/homepage is unknown, inspect the SKILL.md and the two scripts locally before letting an agent run commands automatically. If you want higher assurance, run the scripts manually in a development copy of your site first.
功能分析
Type: OpenClaw Skill Name: astro Version: 1.0.1 The skill bundle is designed to assist with deploying multilingual static websites using Astro on Cloudflare Pages. The `SKILL.md` provides clear, standard instructions for setting up, configuring, and deploying an Astro project, including the use of `npm` and `npx wrangler` commands which are appropriate for the stated purpose. The Python scripts (`astro-i18n-check.py`, `astro-new-post.py`) are utility scripts for managing content, using only standard Python libraries and performing file operations (reading/writing markdown files) consistent with their descriptions. There is no evidence of data exfiltration, malicious execution, persistence mechanisms, obfuscation, or prompt injection attempts against the OpenClaw agent. All actions are aligned with the stated goal of static site generation and deployment.
能力评估
Purpose & Capability
The name/description, SKILL.md instructions, and included Python utilities align with building/deploying multilingual Astro sites to Cloudflare. Minor inconsistency: SKILL.md lists prerequisites (Node.js 20+, npx/wrangler) but the registry metadata declares no required binaries — this is a bookkeeping mismatch rather than a functional red flag.
Instruction Scope
Runtime instructions focus on creating an Astro project, configuring i18n, and deploying to Cloudflare Pages. They do not instruct reading system-wide secrets or arbitrary host paths. The included scripts only read/write under the site content directory (src/content by default).
Install Mechanism
No install spec and no remote downloads are present; the skill is instruction-only with two small local Python scripts. No archive downloads, package installs, or executables written by the skill itself were found.
Credentials
The skill does not request environment variables or credentials in metadata. SKILL.md reasonably expects the user to authenticate to Cloudflare (e.g., via npx wrangler login) when performing deployments — that is proportional to the stated purpose.
Persistence & Privilege
Flags show no forced/always-on behavior and the skill does not request elevated or cross-skill configuration. Autonomous invocation is allowed by default (platform normal), but it is not combined with other concerning privileges here.
如何使用
  1. 确保已安装 OpenClaw(本地或 Docker 部署)
  2. 在对话框中输入安装命令:/install astro
  3. 安装完成后,直接呼叫该 Skill 的名称或使用 /astro 触发
  4. 根据 Skill 的参数说明提供必要输入,即可获得结构化输出
版本历史
v1.0.1
Removed explicit auth command to avoid false positive VirusTotal flag. No functional changes.
v1.0.0
Initial release - multilingual static sites on Cloudflare Pages
元数据
Slug astro
版本 1.0.1
许可证
累计安装 7
当前安装数 7
历史版本数 2
常见问题

Astro 是什么?

Deploy multilingual static websites on Cloudflare with Astro using markdown sources, supporting i18n, free hosting, and Git-based or direct deployment. 它是一个面向 Claude Code / OpenClaw 的 AI Agent Skill 插件,目前累计下载 511 次。

如何安装 Astro?

在 OpenClaw 或 Claude Code 对话框中运行命令「/install astro」即可一键安装,无需额外配置。

Astro 是免费的吗?

是的,Astro 完全免费(开源免费),可自由下载、安装和使用。

Astro 支持哪些平台?

Astro 跨平台运行,可在任意部署了 OpenClaw / Claude Code 的环境中使用(cross-platform)。

谁开发了 Astro?

由 bezkom(@bezkom)开发并维护,当前版本 v1.0.1。

💬 留言讨论