summaryrefslogtreecommitdiff
path: root/src/components/templates/signature/Downloads.astro
diff options
context:
space:
mode:
authorJoão Augusto Costa Branco Marado Torres <torres.dev@disroot.org>2025-08-05 18:50:37 +0100
committerJoão Augusto Costa Branco Marado Torres <torres.dev@disroot.org>2025-08-05 18:50:37 +0100
commit0af094770c4ebabc56ff761a8bd215bc397c0f7e (patch)
treea9ad669c8b84b4d13897732ed93ccfcbbeb2cb25 /src/components/templates/signature/Downloads.astro
parent84eef3f848c4efa18985a776021a58720744523a (diff)
refactor: reading page review
Signed-off-by: João Augusto Costa Branco Marado Torres <torres.dev@disroot.org>
Diffstat (limited to 'src/components/templates/signature/Downloads.astro')
-rw-r--r--src/components/templates/signature/Downloads.astro63
1 files changed, 63 insertions, 0 deletions
diff --git a/src/components/templates/signature/Downloads.astro b/src/components/templates/signature/Downloads.astro
new file mode 100644
index 0000000..3497b37
--- /dev/null
+++ b/src/components/templates/signature/Downloads.astro
@@ -0,0 +1,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>