syntaxai/tdd.md · main · src / d21_handlers_contributing.ts

d21_handlers_contributing.ts 31 lines · 1326 bytes raw
// c21 — handler: /contributing reads ./CONTRIBUTING.md from the repo
// root and renders it through the docs layout. Mirrors the shape of
// other content-driven pages (samaLandingHandler, blogLandingHandler)
// but reads from the project-meta root file rather than from a
// per-section content/ subdirectory. The file is also browseable at
// /GIT/tdd.md/blob/main/CONTRIBUTING.md via the SAMA-native source
// viewer — same content, two URLs.

import { renderDocsPage } from "./b51_render_docs_layout.ts";
import { htmlResponse, renderNotFound } from "./b51_render_layout.ts";

export const contributingHandler = async (): Promise<Response> => {
  const file = Bun.file("./CONTRIBUTING.md");
  if (!(await file.exists())) {
    const html = await renderNotFound("/contributing");
    return htmlResponse(html, 404);
  }
  const body = await file.text();
  const html = await renderDocsPage({
    title: "Contributing — tdd.md",
    description:
      "How to add a feature, blog post, /goal, image, or top-level directory to tdd.md. Single-source-of-truth on-ramp that links to the canonical artifacts; doesn't restate them.",
    bodyMarkdown: body,
    ogPath: "https://tdd.md/contributing",
    active: "contributing",
    pathForDocs: "/contributing",
    editPathOverride: null,
  });
  return htmlResponse(html);
};