aboutsummaryrefslogtreecommitdiffhomepage
path: root/services/nuldoc/nuldoc-src/generators/tag.ts
blob: efe2da54c56318ee1b4a070bfbc06b313895f6ed (plain)
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
import TagPage from "../pages/TagPage.ts";
import { Config, getTagLabel } from "../config.ts";
import { Page } from "../page.ts";
import { TaggedPage } from "./tagged_page.ts";

export interface TagPage extends Page {
  tagSlug: string;
  tagLabel: string;
  numOfPosts: number;
  numOfSlides: number;
}

export async function generateTagPage(
  tagSlug: string,
  pages: TaggedPage[],
  site: "blog" | "slides",
  config: Config,
): Promise<TagPage> {
  const html = await TagPage(tagSlug, pages, site, config);

  return {
    root: html,
    renderer: "html",
    site,
    destFilePath: `/tags/${tagSlug}/index.html`,
    href: `/tags/${tagSlug}/`,
    tagSlug: tagSlug,
    tagLabel: getTagLabel(config, tagSlug),
    numOfPosts: pages.filter((p) => !("event" in p)).length,
    numOfSlides: pages.filter((p) => "event" in p).length,
  };
}