@happyvertical/smrt-template-site-static-json

中文文档
0.62.1发布于 2026/11/17MITES Module零依赖近 30 天下载 1.5万

Static community site template with JSON data storage and SMRT framework

原始使用文档
文档目录10 节
  1. What This Template Provides
  2. Prerequisites
  3. Usage
  4. Environment Variables
  5. Configuration
  6. Available Scripts
  7. Template Structure
  8. Placeholder Substitution
  9. Deployment
  10. Related

@happyvertical/smrt-template-site-static-json

Template for static community news sites with JSON-based data storage. Generates a SvelteKit static site with weather integration (Caelus) and council meeting scraping (Praeco).

What This Template Provides

  • SvelteKit with adapter-static for static site generation
  • JSON file-based data storage in data/
  • Config-driven site identity, navigation, categories, and theming via smrt.config.js
  • Weather forecasts via Caelus (Environment Canada)
  • Council meeting scraping and article generation via Praeco
  • Typed site config helper (initSiteConfig()/getSite())
  • Pre-built routes: home, about, contact
  • Markdown utility for content rendering

Prerequisites

  • Node.js 18+
  • pnpm (recommended)
  • Gemini API key (for Praeco article generation)

Usage

smrt gnode create my-town-site --template site-static-json \
  --location "My Town, AB" \
  --lat 53.5 --lon -113.5

cd my-town-site
pnpm install
cp .env.example .env      # Add your GEMINI_API_KEY
pnpm run init-data        # Initialize data directory
pnpm dev                  # Start dev server

Environment Variables

Defined in .env.example:

VariableRequiredDescription
GEMINI_API_KEYYesGoogle Gemini API key for Praeco article generation
PUBLIC_GTM_IDNoGoogle Tag Manager container ID
CUSTOM_DOMAINNoCustom domain for deployment

Configuration

Edit smrt.config.js to customize. Key sections:

  • site -- name, description, location, navigation links, theme colors
  • categories -- content categories for routing (e.g., politics/local)
  • modules.praeco -- council meeting sources and report configurations
  • modules.caelus -- weather location (set automatically from --lat/--lon flags)

Available Scripts

ScriptDescription
pnpm devStart development server
pnpm buildBuild static site to ./build
pnpm previewPreview the built site
pnpm run init-dataInitialize JSON data files
pnpm run workflow:caelusFetch weather data
pnpm run workflow:praecoScrape council meetings
pnpm run validate:jsonValidate JSON data files
pnpm run validate:slugsValidate content slugs

Template Structure

template/
├── .env.example              # Environment variables
├── .gitignore
├── package.json              # Scripts and dependency placeholders
├── smrt.config.js            # Site identity, modules, theme
├── svelte.config.js          # SvelteKit with adapter-static
├── tsconfig.json
├── vite.config.ts
├── data/                     # JSON data storage directory
├── scripts/
│   └── init-data.ts          # Data initialization script
└── src/
    ├── app.css               # Global styles
    ├── app.d.ts              # SvelteKit type declarations
    ├── app.html              # HTML shell
    ├── site.config.ts        # Typed config helper (initSiteConfig/getSite)
    ├── lib/
    │   └── utils/
    │       └── markdown.ts   # Markdown rendering utility
    └── routes/
        ├── +layout.server.ts # Loads site config for all routes
        ├── +layout.svelte    # Root layout
        ├── +page.server.ts   # Home page data
        ├── +page.svelte      # Home page
        ├── about/            # About page
        └── contact/          # Contact page

Placeholder Substitution

During smrt gnode create, placeholders like {{SITE_NAME}}, {{LOCATION_NAME}}, {{LATITUDE}}, {{LONGITUDE}}, and {{TIMEZONE}} are replaced from CLI flags. See template.config.js for the full mapping.

Deployment

This template uses SvelteKit's static adapter. Build and deploy to any static host:

pnpm build
# Deploy ./build to S3, Netlify, Vercel, Cloudflare Pages, etc.

版本与发布记录

@happyvertical/smrt-template-site-static-json 共发布 365 个版本,首次发布于 2026/06/23;过去 12 个月发布了 365 个版本。

版本发布日期距今
0.62.1latest2026/11/17今天
0.62.02026/11/17今天
0.61.62026/11/161 天前
0.61.52026/11/161 天前
0.61.42026/11/161 天前
0.61.32026/11/152 天前

关于 @happyvertical/smrt-template-site-static-json 的常见问题

@happyvertical/smrt-template-site-static-json 是什么?

Static community site template with JSON data storage and SMRT framework

如何安装 @happyvertical/smrt-template-site-static-json?

在项目目录运行 npm install @happyvertical/smrt-template-site-static-json,或使用 pnpm add / yarn add / bun add。它还需要宿主项目提供 peer 依赖:@happyvertical/smrt-core(0.62.1)、@happyvertical/smrt-config(0.62.1)。npm 7 及以上与 pnpm 8 及以上默认会自动安装必需的 peer 依赖,Yarn 需要手动安装。

@happyvertical/smrt-template-site-static-json 支持 TypeScript 吗?

该包的 package.json 没有声明类型入口。需要类型提示时,可以在 npm 上查找社区维护的 @types/happyvertical__smrt-template-site-static-json 是否存在。

@happyvertical/smrt-template-site-static-json 支持 ESM 还是 CommonJS?

以 ES Module 形式发布,推荐使用 import 引入。在 CommonJS 项目中,Node.js 20.19+ / 22.12+ 可以直接 require() 不含顶层 await 的 ES Module,更早的版本需要改用动态 import()。

@happyvertical/smrt-template-site-static-json 可以商用吗?

@happyvertical/smrt-template-site-static-json 使用 MIT 许可。宽松许可:允许商业使用、修改和再分发,通常只需在分发时保留原版权与许可声明。以上为概括,不构成法律意见,请以许可原文为准。

@happyvertical/smrt-template-site-static-json 的下载量有多少?

根据 npm 官方下载统计,@happyvertical/smrt-template-site-static-json 在 2026/10/17 – 2026/11/15 这 30 天内被下载 14,826 次,日均约 494 次。下载量会把 CI 构建、镜像同步和作为其他包依赖的安装一并计入,适合横向比较热度,不能直接等同于使用人数。

@happyvertical/smrt-template-site-static-json 还在维护吗?

最新版本 0.62.1 发布于 2026/11/17(今天);至今共发布 365 个版本,其中过去 12 个月发布了 365 个;首次发布于 2026/06/23。发布频率只是参考信号:功能稳定的工具可能很少需要更新,建议结合源码仓库的 issue 和提交记录判断。