diff --git a/src/components/TorNotice.astro b/src/components/TorNotice.astro index f4499b5..231062a 100644 --- a/src/components/TorNotice.astro +++ b/src/components/TorNotice.astro @@ -1,12 +1,25 @@ --- +interface Props { + torUrl: string; +} +const { torUrl } = Astro.props; + +const headerText = "This site is accessible via Tor!"; +const maxLine = torUrl.length > headerText.length ? torUrl.length : headerText.length; + +// Account for padding and borders: +2 for borders, +2 for padding spaces +const tableWidth = maxLine + 4; + +const borderTop = "+" + "-".repeat(tableWidth) + "+"; +const borderBottom = "+" + "-".repeat(tableWidth) + "+"; ---
-+----------------------------------------------------------------+
-|                This site is accessible via Tor!                |
-| frzndev32nhnla77oozhxhz5yzo4abldr6zbc4qkdh5hcyanizlxs2ad.onion |
-+----------------------------------------------------------------+
+{borderTop}
+|{" ".repeat(Math.floor((tableWidth - headerText.length) / 2))}{headerText}{" ".repeat(Math.ceil((tableWidth - headerText.length) / 2))}|
+|{" ".repeat(Math.floor((tableWidth - torUrl.length) / 2))}{torUrl}{" ".repeat(Math.ceil((tableWidth - torUrl.length) / 2))}|
+{borderBottom}
   
diff --git a/src/pages/index.astro b/src/pages/index.astro index b13a3fd..e260ccd 100644 --- a/src/pages/index.astro +++ b/src/pages/index.astro @@ -69,7 +69,7 @@ const currentYear = new Date().getFullYear();
- +