summaryrefslogtreecommitdiff
path: root/src/components/Citations.astro
blob: cc82eda183457ec86bffceb7fdb6b2162148e05b (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
---
import type { CollectionEntry } from "astro:content";
import { getEntries } from "astro:content";

type Props = { citations: CollectionEntry<"blog">["data"]["relatedPosts"] };
const citations = await getEntries(Astro.props.citations ?? []);
---
{
  citations.length > 0 &&
    (
    <aside>
      <p>O autor recomenda ler também:</p>
      <ul>
        {
          citations.map(({ collection, id, data }) => (
            <li
              itemprop="citation"
              itemscope
              itemtype="http://schema.org/BlogPosting"
              itemid={Astro.url.href.replace(/[^\/]*\/?$/, id)}
            >
              <a href={`/${collection}/read/${id}`}>
                <cite itemprop="headline">{data.title}</cite>
              </a>
            </li>
          ))
        }
      </ul>
    </aside>
  )
}

<style>
  @media print {
    aside {
      display: none;
    }
  }
</style>