aboutsummaryrefslogtreecommitdiffhomepage
path: root/services/nuldoc/nuldoc-src/components/PostPageEntry.ts
blob: 482a3a8e82e6f91c2385f396b6db292c55c29d0e (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
50
51
52
53
54
55
import {
  getPostPublishedDate,
  getPostUpdatedDate,
  postHasAnyUpdates,
  PostPage,
} from "../generators/post.ts";
import { dateToString } from "../revision.ts";
import { Config } from "../config.ts";
import {
  a,
  article,
  elem,
  Element,
  footer,
  h2,
  header,
  p,
  section,
} from "../dom.ts";
import TagList from "./TagList.ts";

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

export default function PostPageEntry({ post, config }: Props): Element {
  return article(
    { class: "post-entry" },
    a(
      { href: post.href },
      header({ class: "entry-header" }, h2({}, post.title)),
      section(
        { class: "entry-content" },
        p({}, post.description),
      ),
      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,
      ),
    ),
  );
}