aboutsummaryrefslogtreecommitdiff
path: root/src/layouts/ContactPageLayout.astro
blob: 3a0229321c76aae9b45908275e30ee5ddf5ddefd (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
99
100
101
102
103
104
105
---
import Layout from "./Layout.astro";

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

<Layout
  title="Contacto"
  description="Las formas de ponerte en contacto conmigo, ya sea por correo electrónico, teléfono o redes sociales."
>
  <script
    is:inline
    type="application/ld+json"
    slot="head-jsonld"
    set:html={JSON.stringify(schema)}
  />

  <h1>"Contacta conmigo"</h1>

  <noscript>
    <div role="alert" class="warning">
      Es necesario activar JavaScript para ver la dirección de correo
      electrónico y el número de teléfono. Esto se hace para evitar scrapers y
      spam.
    </div>
  </noscript>

  <p>
    La forma más sencilla de contactar conmigo es a través de mi dirección de
    correo electrónico: <a href="#" id="email-addr">Activa JS</a>. También
    puedes usar <a href="https://wa.me/message/W7T7L4EZAELQI1">WhatsApp</a> con el
    número de teléfono <a href="#" id="phone-number">Activa JS</a>.
  </p>

  <p>También puedes encontrarme en algunas redes sociales:</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>