aboutsummaryrefslogtreecommitdiffhomepage
path: root/nuldoc-src/components/post_page_entry.ts
blob: e825dfd8159486a405e5a6bcebde0e5a958089de (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
import { el, Element, text } from "../dom.ts";
import {
  getPostCreatedDate,
  getPostUpdatedDate,
  PostPage,
} from "../pages/post.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", getPostCreatedDate(post)]],
          text(getPostCreatedDate(post)),
        ),
        text(" 投稿"),
        ...(post.revisions.length > 1
          ? [
            text("、"),
            el("time", [[
              "datetime",
              getPostUpdatedDate(post),
            ]], text(getPostUpdatedDate(post))),
            text(" 更新"),
          ]
          : []),
      ),
    ),
  );
}