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
63
|
---
import { gitDir } from "@lib/git";
import { get } from "@utils/anonymous";
interface Props {
lang: string;
}
const { lang } = Astro.props;
let source = new URL(
`${Astro.url.href.replace(/\/$/, "")}.md`,
);
const dir = await gitDir();
const format: Intl.NumberFormatOptions = {
notation: "compact",
style: "unit",
unit: "byte",
unitDisplay: "narrow",
};
const formatter = new Intl.NumberFormat(lang, format);
const sourceSize = formatter.format(
await Deno.stat(
new URL("public" + source.pathname, dir),
).then(get("size")),
);
const sig = await Deno.stat(
new URL("public" + source.pathname + ".sig", dir),
).then(get("size")).catch(() => undefined);
const sigSize = formatter.format(sig);
---
<section>
<p>Ficheiros para descarregar:</p>
<dl>
<dt>Blog post</dt>
<dd>
<a
id="message"
href={source}
download
type="text/markdown; charset=utf-8"
><samp>text/markdown</samp>, <samp>{sourceSize}</samp></a>
</dd>
{
sig && (
<dt>Assinatura digital</dt>
<dd>
<a
id="signature"
href={`${source}.sig`}
download
type="application/pgp-signature"
><samp>application/pgp-signature</samp>, <samp>{sigSize}</samp></a>
</dd>
)
}
</dl>
</section>
|