master
 1---
 2import { licenseConfig, profileConfig, siteConfig } from '@/config';
 3import { t } from '@utils/i18n';
 4
 5interface Props {
 6  time: Date;
 7  lang?: string;
 8  license?: string;
 9  licenseUrl?: string;
10}
11
12const { time, license, licenseUrl, lang } = Astro.props;
13
14const infomations = [
15  {
16    key: t.meta.publishedAt(),
17    value: time.toLocaleDateString(lang || siteConfig.lang.replace('_', '-')),
18    time: time,
19  },
20  {
21    key: t.meta.author(),
22    value: profileConfig.name,
23    link: '/about/',
24  },
25  {
26    key: t.meta.license(),
27    value: license || licenseConfig.name,
28    link: licenseUrl || licenseConfig.url,
29  },
30];
31---
32
33<div class="card border-primary/10 from-primary/35 to-primary/15 my-4 border bg-linear-150">
34  <div class="card-body grid grid-cols-2 gap-x-4 p-4 text-lg text-shadow-lg">
35    {
36      infomations.map((info) => (
37        <Fragment>
38          <span class="mr-4 text-right font-bold">{info.key}</span>
39          {(() => {
40            const text = info.time ? (
41              <time datetime={info.time?.toISOString()}>{info.value}</time>
42            ) : (
43              <span>{info.value}</span>
44            );
45            return info.link ? (
46              <a href={info.link} title={info.value} class="text-primary hover:underline">
47                {text}
48              </a>
49            ) : (
50              text
51            );
52          })()}
53        </Fragment>
54      ))
55    }
56  </div>
57</div>