summaryrefslogtreecommitdiff
path: root/src/components/organisms/KeywordsList.astro
blob: 551986577959cdaa709c276f21fc45632f469ee4 (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
56
57
58
59
60
61
62
---
interface Props {
  keywords: (string | [string, number])[];
}

const { keywords } = Astro.props;
---

<p role="list">
  {
    keywords.map((x, i) => {
      let keyword = typeof x === "string" ? x : x[0];
      let n = typeof x === "string" ? undefined : x[1];
      return (
      <>{i > 0 && " "}<span role="listitem">{
            n !== undefined && <samp class="number mute">{n}</samp>
          }{" "}<a href={`/blog/keywords/${keyword}`}>#<b itemprop="keywords">{
              keyword
            }</b></a></span></>
    );
    })
  }
</p>

<style>
  p {
    display: flex;
    justify-content: flex-end;
    flex-wrap: wrap;
    gap: calc(var(--size-0) * 1em);
    margin-block: calc(var(--size-0) * 1em);
    margin-inline: auto;
  }

  [role="listitem"] {
    border-radius: calc(infinity * 1px);
    background-color: color-mix(
      in srgb,
      var(--color-active) 10%,
      transparent
    );
    padding-inline: calc(var(--size-2) * 1em);
    display: flex;
    align-items: center;
    gap: calc(var(--size-4) * 1ch);

    & * {
      color: var(--color-active);
    }
  }

  .number {
    display: inline-block;
    min-width: 1rem;
    max-width: 1rem;
    border-radius: calc(infinity * 1px);
    background-color: var(--color-active);
    color: var(--color-background) !important;
    text-align: center;
    margin-block: calc(var(--size-0) * 1em);
  }
</style>