Skip to content
b4mossPublic

About

Extended Markdown template engine for TypeScript / JavaScript.

Topics

Resources

Code of conduct

Contributing

Security policy

Stars

1 star

Watchers

0 watching

Forks

Repository files navigation

hyogen.md (@b4moss/hyogen-md)

masthead

CI Coverage npm Release License OpenSSF Scorecard

Extended Markdown template engine for TypeScript / JavaScript.

Control flow and templating live in HTML comments (@hg … @endhg or @@ … @@), so source files stay preview-friendly. The library outputs Markdown only (HTML is left to the consumer).

Homepage: https://github.com/b4m-oss/hyogen-md

This file is kept in sync at the repository root and at app/README.md (npm package root).


Install

npm install @b4moss/hyogen-md

Requires Node.js >= 24.


Quick start

CLI (hyogen-md)

npx hyogen-md create my-site
cd my-site
npm install
npm run dev    # preview with file tree + HMR (default http://127.0.0.1:4173)
npm run build  # write Markdown to outDir (default ./out)

hyogen.config.js (or .ts):

import { defineConfig } from "@b4moss/hyogen-md/config";

export default defineConfig({
  input: "./src/**/*.md",
  // outDir: "./out",
});

Client / CSR (@b4moss/hyogen-md/client)

import { renderClient } from "@b4moss/hyogen-md/client";

const result = await renderClient(
  { path: "/src/index.md" },
  { siteName: "Demo" },
  {
    loader: async (path) => {
      // resolve path → file contents (virtual FS, fetch, etc.)
      return await readSomewhere(path);
    },
  },
);

console.log(result.markdown);
console.log(result.warnings);

Server / SSR (@b4moss/hyogen-md)

import { renderServer, createNodeLoader } from "@b4moss/hyogen-md";

const result = await renderServer(
  { path: "./pages/index.md" },
  { title: "Hello" },
  {
    loader: createNodeLoader(),
    // serverContext: { apiKey: "…" }, // server-only; not available on renderClient
  },
);

SSG batch (build)

import { build } from "@b4moss/hyogen-md";

const { files, warnings } = await build({
  input: "./src/**/*.md",
  outDir: "./out",
  context: { siteName: "Demo" },
});

API details: docs/specs/api.md.


Repository layout

Path Role
app/ Library published to npm (files: dist, plus README / LICENSE)
docs-site/ Documentation site + Playground on GitHub Pages (not in npm)
user-docs/ User-facing docs (e.g. changelog)
docs/ Specs and roadmap (Japanese, maintainers)

Documentation & Playground

Site: https://hyogenmd.oss.b4m.jp (GitHub Pages; /ja, /en, /playground).
Playground: https://hyogenmd.oss.b4m.jp/playground

Local:

make install-docs
make dev-docs

Open http://localhost:3000 (docs) and /playground. Uses ../app via Vite alias. Virtual FS + localStorage only.


Status

This is 0.x. APIs and output may change until 1.0.0.
Published: @b4moss/hyogen-md@0.14.1 (git tag v0.14.1).

Playground UX ships with the documentation site and is not included in the npm tarball.

The coverage badge reflects statement coverage for app/ (library) from Vitest (≥90% target; enforced by Vitest thresholds). Coverage is uploaded to Codecov from .github/workflows/quality.yml on pushes to main.


Changelog

See user-docs/changelog.md (Japanese: changelog_ja.md).


License

MIT © Kohki SHIKATA

About

Extended Markdown template engine for TypeScript / JavaScript.

Topics

Resources

Code of conduct

Contributing

Security policy

Stars

1 star

Watchers

0 watching

Forks

Releases

Packages

Used by

Contributors

Languages