aboutsummaryrefslogtreecommitdiff
path: root/src/layouts/ContactPageLayout.astro
blob: c09969faeaeb457c885d06b0a6968f396a1cf2a2 (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
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
---
import { useTranslations } from "../i18n";
import Layout from "./Layout.astro";

const t = useTranslations(Astro.currentLocale);

const schema = {
  "@context": "https://schema.org",
  "@type": "ContactPage",
  url: "https://www.costas.dev/contact",
  headline: t.contactPage.headline,
};
---

<Layout title={t.contactPage.title} description={t.contactPage.description}>
  <script
    is:inline
    type="application/ld+json"
    slot="head-jsonld"
    set:html={JSON.stringify(schema)}
  />

  <h1>{t.contactPage.headline}</h1>

  <noscript>
    <div role="alert" class="warning">
      {t.contactPage.enableJs}
    </div>
  </noscript>

  <p set:html={t.contactPage.intro} />

  <p>{t.contactPage.socialMedia}</p>

  <dl>
    <dt>GitHub</dt>
    <dd><a href="https://github.com/arielcostas">@arielcostas</a></dd>
    <dt>LinkedIn</dt>
    <dd>
      <a href="https://www.linkedin.com/in/ariel-costas/">/in/ariel-costas</a>
    </dd>
    <dt>BlueSky</dt>
    <dd><a href="https://bsky.app/profile/costas.dev">@costas.dev</a></dd>
  </dl>
</Layout>

<script>
  const encryptedEmail = "LygNLiMmFRo/GlQZaFIWBA==";
  const encryptedPhoneNumber = "ZWlQfX1QT0Z+XgVd";
  const key = "NZdKOfvuLn5jF6sryF0Q";

  const emailAddrLink = document.getElementById(
    "email-addr",
  ) as HTMLAnchorElement;
  const phoneNumberLink = document.getElementById(
    "phone-number",
  ) as HTMLAnchorElement;

  (() => {
    if (emailAddrLink == null || phoneNumberLink == null) {
      return;
    }

    const emailAddress = xorData(encryptedEmail, key);
    const phoneNumber = xorData(encryptedPhoneNumber, key);

    emailAddrLink.href = `mailto:${emailAddress}`;
    emailAddrLink.textContent = emailAddress;

    phoneNumberLink.href = `tel:${phoneNumber}`;
    phoneNumberLink.textContent = phoneNumber;
  })();

  function xorData(data: string, key: string): string {
    let actualData = atob(data);
    let actualKey = key;
    const keyLength = key.length;
    const dataLength = actualData.length;
    const result = new Array(dataLength);

    // If the key is 12 characters but the data is 30 characters, the key should be repeated 3 times and truncated to 30 characters
    if (keyLength < dataLength) {
      actualKey = key
        .repeat(Math.ceil(dataLength / keyLength))
        .substring(0, dataLength);
    } else if (keyLength > dataLength) {
      actualKey = key.substring(0, dataLength);
    }

    for (let i = 0; i < dataLength; i++) {
      result[i] = String.fromCharCode(
        actualData.charCodeAt(i) ^ actualKey.charCodeAt(i),
      );
    }

    return result.join("");
  }
</script>