Files
..
2026-10-21 16:53:53 +08:00
2026-10-21 16:53:53 +08:00
2026-10-21 16:53:53 +08:00
2026-10-21 16:53:53 +08:00

MonkeyAI public website

中文原文

The public website presents MonkeyAI, client downloads, and the two demo paths. It also serves the blog, legal documents, and the app-link page for device pairing. Astro emits HTML and SEO metadata at build time; React islands add interaction without making the content depend on client-side routing.

Where to start

Path Responsibility
src/pages/ and src/layouts/ Homepage, localized route entries, blog and legal pages, sitemap, and the shared layout.
src/components/ and src/styles/ Astro sections, interactive React components, and styling.
src/i18n/ and src/blog/ Route definitions, dictionaries, legal translations, and localized articles.
src/lib/, src/assets/, and public/ Shared logic, bundled images/fonts, static downloads metadata, and license notices.
tests/ and scripts/ Node regression tests and the font import script.
astro.config.mjs, Dockerfile, and Caddyfile Static build, image, and serving configuration.

Run locally

Use Node 22.12 or later and npm 9.6.5 or later (the requirements declared by the locked Astro package); the Docker builder uses Node 26.13.1. Run these commands in monkeyai/landing. This module uses npm and package-lock.json for reproducible builds. A pnpm lockfile exists in this snapshot, but it isn't used by the npm or image build. Don't generate or update pnpm metadata as part of a site change.

npm ci
npm run dev

Astro normally serves on http://localhost:4321/; open /en/ directly for English. The config isolates Vite caches by Astro command in node_modules/.vite/astro-* so a check or build won't replace a running dev server's optimized dependencies.

Build, test, and preview

npm test         # node --test tests/*.test.mjs
npm run check    # Astro and TypeScript diagnostics
npm run build    # runs check, then writes the static site to dist/
npm run preview  # serves the build locally

The tests cover locale selection, locale dictionary parity, legal translations, app-link query preservation, platform detection, and release-download URL validation. When translating site copy, run both the tests and the build. Before deploying, set the canonical origin with SITE_URL and any mount prefix with PUBLIC_BASE_PATH. Set PUBLIC_GA_ID to override the GA4 property; an invalid value disables analytics. See .env.example for the current defaults. After a deployment-prefix change, inspect the canonical links, sitemap, paths to static assets, and pairing pages in the built output.

Localization and content

  • Ten homepages are generated. The root HTML is Simplified Chinese; on the unprefixed entry the language preference code honors a saved choice, then matches the browser's list, and falls back to English. A direct URL with a language prefix stays in that language. Follow languages.ts for route IDs rather than hard-coding them.
  • Update the source copy and corresponding dictionaries together. Register copy used by React islands in islands.json so the page ships only the locale and keys it needs. The three legal pages have reference translations for the nine other locales alongside the Simplified Chinese source. Language switches on the scan page must preserve the pairing query, including duplicate keys and encoding.
  • To publish a blog entry, add src/blog/<slug>/zh-CN.md with title and summary in the front matter, optionally seoTitle. The directory name determines /blog/<slug>/ and its sort order. Store translations as locale-named siblings such as en-US.md. The build generates localized article pages and sitemap entries; untranslated articles label the Simplified Chinese fallback. See an existing article.
  • Keep the canonical URL, hreflang, robots directives, Open Graph/Twitter metadata, and structured data in sync with route changes. The build emits /sitemap.xml and /robots.txt.

Styling and interaction

  • Use Astro with React islands and Tailwind CSS v4. BaseLayout.astro supplies the shared header and footer. Maintain site colors in site.css; use semantic type roles from the typography guide and typography.css. Don't reintroduce Tailwind Preflight or unrelated component font sizes.
  • Hydrate only interactive boundaries with client:load or client:visible. Keep full text and navigation available in the initial HTML; the FAQ retains native details/summary before hydration. Preserve keyboard operation, focus restoration, and reduced-motion behavior. The demo dialog distinguishes installed-client access from the web admin console. Use the shared clipboard feedback component and respect the site base path for the downloads jump. Keep a static, readable fallback for shader cards when JavaScript or WebGL2 is unavailable.
  • Keep the promotion's content in promotion.ts. If changing the sticky banner or header, ensure anchor offsets follow the measured top bar height. Reuse the community QR asset and keep hover, keyboard, touch, and dismiss behavior accessible. For new UI primitives, run npx shadcn@latest add dialog from this module and review the generated styles against components.json and shadcn.css. Keep the distinction between buttons and native links; only include the icons used in the build.
  • Fonts and license notices are checked in; everyday builds do not download fonts. MiSans uses three local static weights and JetBrains Mono is the local code font. To reimport MiSans, obtain the official archive and run the following with Python 3.11+; the script checks the archive hash and writes the expected weights, CSS, and metadata. Review source hashes and the license before upgrading. Notices are in public/licenses/.
npm run fonts:sync -- --archive /path/to/MiSans.zip

Container and deployment files

The Dockerfile runs the npm build and copies dist/ into Caddy. Its COPY sources are relative to a build context containing a homepage/ directory. They do not match a direct docker build . from monkeyai/landing; for normal development use the npm workflow above. The Compose file runs a prebuilt image, controlled by HOMEPAGE_IMAGE and IMAGE_TAG. Its checked-in defaults still use the Jiying hostname and image. Confirm the image, SITE_ADDRESS, and canonical build origin with the deployment owner rather than assuming these defaults describe the live MonkeyAI website.

For a deployment that uses this Caddy bundle, preserve the certificate state, configuration, and log mounts under data/caddy/. Release files in data/releases are mounted read-only, served by explicit path, and not listed. The internal health check reads the built index through Caddy; the public /healthz also provides an endpoint for checking DNS and TLS from outside the container. The systemd files are for the existing Linux deployment layout (/data/homepage and jiying-homepage), not for local development. The timer runs a Compose update and the script checks the resulting container's health.