aboutsummaryrefslogtreecommitdiffhomepage
path: root/services/nuldoc/nuldoc-src/components/PostPageEntry.ts
blob: 75ad11c1d988980716ed880b68426345e3eec5fb (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
49
import {
  getPostPublishedDate,
  getPostUpdatedDate,
  postHasAnyUpdates,
  PostPage,
} from "../generators/post.ts";
import { dateToString } from "../revision.ts";
import { Config } from "../config.ts";
import { elem, Element } from "../dom.ts";
import TagList from "./TagList.ts";

type Props = { post: PostPage; config: Config };

export default function PostPageEntry({ post, config }: Props): Element {
  return elem(
    "article",
    { class: "post-entry" },
    elem(
      "a",
      { href: post.href },
      elem("header", { class: "entry-header" }, elem("h2", {}, post.title)),
      elem(
        "section",
        { class: "entry-content" },
        elem("p", {}, post.description),
      ),
      elem(
        "footer",
        { class: "entry-footer" },
        elem(
          "time",
          { datetime: dateToString(getPostPublishedDate(post)) },
          dateToString(getPostPublishedDate(post)),
        ),
        " 投稿",
        postHasAnyUpdates(post) ? "、" : null,
        postHasAnyUpdates(post)
          ? elem(
            "time",
            { datetime: dateToString(getPostUpdatedDate(post)) },
            dateToString(getPostUpdatedDate(post)),
          )
          : null,
        postHasAnyUpdates(post) ? " 更新" : null,
        post.tags.length !== 0 ? TagList({ tags: post.tags, config }) : null,
      ),
    ),
  );
}