aboutsummaryrefslogtreecommitdiffhomepage
path: root/nuldoc-src/components/post_page_entry.ts
blob: 685c03a8a5010fa6db665f5bff4d6d882d5b3f02 (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
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
import { el, Element, text } from "../dom.ts";
import {
  getPostCreatedDate,
  getPostUpdatedDate,
  PostPage,
} from "../pages/post.ts";
import { dateToString } from "../revision.ts";

export function postPageEntry(post: PostPage): Element {
  return el(
    "article",
    [["class", "post-entry"]],
    el(
      "a",
      [["href", post.href]],
      el(
        "header",
        [["class", "entry-header"]],
        el("h2", [], text(post.title)),
      ),
      el(
        "section",
        [["class", "entry-content"]],
        el("p", [], text(post.summary)),
      ),
      el(
        "footer",
        [["class", "entry-footer"]],
        el(
          "time",
          [["datetime", dateToString(getPostCreatedDate(post))]],
          text(dateToString(getPostCreatedDate(post))),
        ),
        text(" 投稿"),
        ...(post.revisions.length > 1
          ? [
            text("、"),
            el("time", [[
              "datetime",
              dateToString(getPostUpdatedDate(post)),
            ]], text(dateToString(getPostUpdatedDate(post)))),
            text(" 更新"),
          ]
          : []),
      ),
    ),
  );
}