All files / src/lib/docs published-docs.ts

100% Statements 7/7
100% Branches 2/2
100% Functions 6/6
100% Lines 4/4

Press n or j to go to the next uncovered block, b, p or k for the previous block.

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54                                          14x             676x             195x                     60x              
import data from "@/content/published-docs.json";
 
/** A section of the published documentation, one route under /docs each. */
export type DocSection =
  | "security"
  | "klarbefund"
  | "operations"
  | "ehds"
  | "developer";
 
export interface PublishedDoc {
  section: DocSection;
  slug: string;
  title: string;
  summary: string;
  /** Path of the source file in the repository. */
  source: string;
  markdown: string;
}
 
export const REPO_URL =
  "https://github.com/ma3u/MinimumViableHealthDataspacev2";
 
/** Every document copied from docs/ by scripts/gen-docs-content.py, in
 *  index order. */
export const publishedDocs: PublishedDoc[] = data.docs as PublishedDoc[];
 
export function docsInSection(section: DocSection): PublishedDoc[] {
  return publishedDocs.filter((d) => d.section === section);
}
 
export function findDoc(
  section: DocSection,
  slug: string,
): PublishedDoc | undefined {
  return publishedDocs.find((d) => d.section === section && d.slug === slug);
}
 
/** What a section page's cards show of a document; the Markdown stays on
 *  the server. */
export type DocCard = Pick<
  PublishedDoc,
  "section" | "slug" | "title" | "summary"
>;
 
export function docCards(docs: readonly PublishedDoc[]): DocCard[] {
  return docs.map(({ section, slug, title, summary }) => ({
    section,
    slug,
    title,
    summary,
  }));
}