From 9e78a778c0bcdd0930d0156f586c8bb99ec48572 Mon Sep 17 00:00:00 2001
From: Sam Therapy <sam@samtherapy.net>
Date: Mon, 24 Oct 2022 23:05:00 +0200
Subject: [PATCH] chore: settle with something

---
 .vscode/settings.json                       |   2 +-
 _config.ts                                  |  22 ++++++++-----
 custom/toml/toml.ts                         |   6 ++++
 deno.json                                   |  12 -------
 deno.jsonc                                  |  22 +++++++++++++
 import_map.json                             |   5 +--
 server.ts                                   |   2 +-
 src/404.md                                  |  11 +++----
 src/_data.toml                              |  12 +++++++
 src/_includes/layouts/about.tsx             |  23 +++++++++++++
 src/_includes/layouts/head.njk              |  13 --------
 src/_includes/layouts/head.tsx              |  34 ++++++++++++++++++++
 src/_includes/styles/base.scss              |  24 ++++++++------
 src/_includes/types.ts                      |   0
 src/about.md                                |  29 +++++++++++++++++
 src/index.md                                |  11 +++++++
 src/index.tsx                               |  19 -----------
 src/{ => static}/.well-known/host-meta.json |   0
 src/{ => static}/img/favicon.png            | Bin
 static/img/favicon.png                      | Bin 0 -> 16762 bytes
 velociraptor.yaml                           |   8 +++++
 21 files changed, 183 insertions(+), 72 deletions(-)
 create mode 100644 custom/toml/toml.ts
 delete mode 100644 deno.json
 create mode 100644 deno.jsonc
 create mode 100644 src/_data.toml
 create mode 100644 src/_includes/layouts/about.tsx
 delete mode 100644 src/_includes/layouts/head.njk
 create mode 100644 src/_includes/layouts/head.tsx
 create mode 100644 src/_includes/types.ts
 create mode 100644 src/about.md
 create mode 100644 src/index.md
 delete mode 100644 src/index.tsx
 rename src/{ => static}/.well-known/host-meta.json (100%)
 rename src/{ => static}/img/favicon.png (100%)
 create mode 100644 static/img/favicon.png
 create mode 100644 velociraptor.yaml

diff --git a/.vscode/settings.json b/.vscode/settings.json
index 856accc..f256621 100644
--- a/.vscode/settings.json
+++ b/.vscode/settings.json
@@ -1,8 +1,8 @@
 {
+  "deno.config": "./deno.jsonc",
   "deno.enable": true,
   "deno.lint": true,
   "deno.unstable": true,
-  "deno.config": "./deno.json",
   "[typescript]": {
     "editor.defaultFormatter": "denoland.vscode-deno"
   },
diff --git a/_config.ts b/_config.ts
index 3b3fd7a..223271d 100644
--- a/_config.ts
+++ b/_config.ts
@@ -3,10 +3,10 @@ import lume from "lume/mod.ts";
 // Stable plugins
 import attributes from "lume/plugins/attributes.ts";
 import codeHighlight from "lume/plugins/code_highlight.ts";
-import date from "lume/plugins/date.ts";
 import esbuild from "lume/plugins/esbuild.ts";
 import jsx from "lume/plugins/jsx_preact.ts";
 import lightningcss from "lume/plugins/lightningcss.ts";
+import metas from "lume/plugins/metas.ts";
 import minifyHTML from "lume/plugins/minify_html.ts";
 import remark from "lume/plugins/remark.ts";
 import sass from "lume/plugins/sass.ts";
@@ -14,9 +14,12 @@ import sourceMaps from "lume/plugins/source_maps.ts";
 import svgo from "lume/plugins/svgo.ts";
 
 // Experimental plugins
-import mdx from "experimental/mdx/mod.ts";
+// import mdx from "experimental/mdx/mod.ts";
 import sitemap from "experimental/sitemap/sitemap.ts";
 
+// Custom plugins
+import toml from "./custom/toml/toml.ts";
+
 const site = lume({
   src: "./src",
   dest: "./dist",
@@ -24,14 +27,15 @@ const site = lume({
 });
 
 site
-  .copy("img")
+  .copy("static", ".")
+  .copy("static/.well-known", ".well-known")
   .copy(".domains")
-  .copy(".well-known")
+  .loadData([".toml"], toml)
   .use(attributes())
   .use(codeHighlight())
-  .use(date())
   .use(jsx())
-  .use(mdx())
+  .use(metas())
+  // .use(mdx())
   .use(remark())
   .use(sitemap())
   .use(svgo())
@@ -41,8 +45,10 @@ site
   )
   .use(esbuild())
   .use(lightningcss())
-  .use(sass({ extensions: [".scss"] }))
+  .use(sass())
   .use(minifyHTML())
-  .use(sourceMaps());
+  .use(sourceMaps({
+    sourceContent: true,
+  }));
 
 export default site;
diff --git a/custom/toml/toml.ts b/custom/toml/toml.ts
new file mode 100644
index 0000000..beae18f
--- /dev/null
+++ b/custom/toml/toml.ts
@@ -0,0 +1,6 @@
+import { parse } from "std/encoding/toml.ts";
+
+export default async function toml(path: string | URL) {
+  const content = await Deno.readTextFile(path);
+  return parse(content);
+}
diff --git a/deno.json b/deno.json
deleted file mode 100644
index fb51ade..0000000
--- a/deno.json
+++ /dev/null
@@ -1,12 +0,0 @@
-{
-  "importMap": "import_map.json",
-  "tasks": {
-    "lume": "deno eval \"import 'lume/task.ts'\" --",
-    "build": "deno task lume",
-    "serve": "deno task lume -s"
-  },
-  "compilerOptions": {
-    "jsx": "react-jsx",
-    "jsxImportSource": "npm:preact"
-  }
-}
diff --git a/deno.jsonc b/deno.jsonc
new file mode 100644
index 0000000..2e3c58c
--- /dev/null
+++ b/deno.jsonc
@@ -0,0 +1,22 @@
+{
+  "importMap": "import_map.json",
+  "tasks": {
+    "lume": "echo \"import 'lume/cli.ts'\" | deno run --unstable -A -",
+    "build": "deno task lume",
+    "serve": "deno task lume -s"
+  },
+  "compilerOptions": {
+    "jsx": "react-jsx",
+    "jsxImportSource": "npm:preact"
+  },
+  "lint": {
+    "files": {
+      "exclude": ["src/_includes/styles/external/"]
+    }
+  },
+  "fmt": {
+    "files": {
+      "exclude": ["src/_includes/styles/external/"]
+    }
+  }
+}
diff --git a/import_map.json b/import_map.json
index 15de893..a4940a0 100644
--- a/import_map.json
+++ b/import_map.json
@@ -1,7 +1,8 @@
 {
   "imports": {
     "lume/": "https://deno.land/x/lume@v1.12.1/",
-    "preact/jsx-runtime": "https://deno.land/x/lume@v1.11.4/deps/preact_runtime.ts",
-    "experimental/": "https://raw.githubusercontent.com/lumeland/experimental-plugins/main/"
+    "experimental/": "https://raw.githubusercontent.com/lumeland/experimental-plugins/main/",
+    "std/": "https://deno.land/std/",
+    "#types": "./src/_includes/types.ts"
   }
 }
diff --git a/server.ts b/server.ts
index ed81b70..7c3a07a 100644
--- a/server.ts
+++ b/server.ts
@@ -15,7 +15,7 @@ app.use(async (ctx, next) => {
     index: "index.html",
     hidden: true,
   }).catch(async () => {
-    ctx.response.status = 404
+    ctx.response.status = 404;
     ctx.response.body = await Deno.readTextFile(`${Deno.cwd()}/dist/404.html`);
     await next();
   });
diff --git a/src/404.md b/src/404.md
index 8ffc2b2..98d87df 100644
--- a/src/404.md
+++ b/src/404.md
@@ -1,13 +1,12 @@
 ---
-title: 404 - There's Nothing Here
-layout: layouts/head.njk
+title: Well, how did I get here?
+subtitle: 404 - Not found
+layout: layouts/head.tsx
 url: /404.html
 ---
 
-# Well, how did I get here?
+#### Where does that [highway](/) go to?
 
-Would you like to [return](/)?
-
-```ts
+```js
 window.location.replace("/");
 ```
diff --git a/src/_data.toml b/src/_data.toml
new file mode 100644
index 0000000..0caf1df
--- /dev/null
+++ b/src/_data.toml
@@ -0,0 +1,12 @@
+# Site metas from Lume metas plugin
+[metas]
+site = "Sam's site"
+lang = "en"
+description = "The website of a random fishe"
+icon = "img/favicon.png"
+keywords = ["nothing"]
+robots = true
+generator = true
+
+[mergedKeys]
+metas = "object"
diff --git a/src/_includes/layouts/about.tsx b/src/_includes/layouts/about.tsx
new file mode 100644
index 0000000..69e1945
--- /dev/null
+++ b/src/_includes/layouts/about.tsx
@@ -0,0 +1,23 @@
+import { PageData } from "lume/core.ts";
+
+export const title = "Sam Site 2.0";
+export const layout = "layouts/head.tsx";
+
+export default ({ children }: PageData) => (
+  <div class="grid">
+    <div>
+      {children}
+    </div>
+    <div>
+      <iframe
+        title="Powered by Fedifeed"
+        allowfullscreen
+        sandbox="allow-top-navigation allow-scripts"
+        width="400"
+        height="500"
+        src="https://fedifeed.com/api/v1/feed?user=sam&instance=https%3A%2F%2Ffroth.zone&instance_type=&theme=pleroma&size=75&header=true&replies=true&boosts=true"
+      >
+      </iframe>
+    </div>
+  </div>
+);
diff --git a/src/_includes/layouts/head.njk b/src/_includes/layouts/head.njk
deleted file mode 100644
index a911e65..0000000
--- a/src/_includes/layouts/head.njk
+++ /dev/null
@@ -1,13 +0,0 @@
-<!DOCTYPE html>
-<html lang="{{ language }}">
-	<head>
-		<meta charSet="utf-8"/>
-		<meta name="viewport" content="width=device-width, initial-scale=1.0"/>
-		<link rel="shortcut icon" href="img/favicon.png"/>
-		<link rel="stylesheet" href="styles/style.css"/>
-		<title>{{ title }}</title>
-	</head>
-	<body>
-		{{ content | safe }}
-	</body>
-</html>
\ No newline at end of file
diff --git a/src/_includes/layouts/head.tsx b/src/_includes/layouts/head.tsx
new file mode 100644
index 0000000..5825370
--- /dev/null
+++ b/src/_includes/layouts/head.tsx
@@ -0,0 +1,34 @@
+import { PageData } from "lume/core.ts";
+
+export default ({ metas, children, title, subtitle }: PageData) => (
+  <html lang={metas?.lang}>
+    <head>
+      <title>{title}</title>
+      <meta charSet="utf-8" />
+      <meta name="viewport" content="width=device-width, initial-scale=1.0" />
+      <link rel="shortcut icon" href="/img/favicon.png" />
+      <link rel="stylesheet" href="/styles/style.css" />
+    </head>
+    <body>
+      <header class="container">
+        <hgroup>
+          <h1>{title}</h1>
+          <h2>{subtitle}</h2>
+        </hgroup>
+      </header>
+      <main class="container">
+        {children}
+      </main>
+      <footer class="container">
+        <small>
+          Built with <a href="https://lume.land">Lume</a> • Hosted on{" "}
+          <a href="https://deno.com/deploy">Deno Deploy</a> from{" "}
+          <a href="https://samtherapy.net">here</a> <em>and</em>{" "}
+          <a href="https://freecumextremist.finance">Froth Pages</a> from{" "}
+          <a href="https://samtherapy.xyz">here</a> •{"  "}
+          <a href="https://git.froth.zone/sam/site">Source</a>
+        </small>
+      </footer>
+    </body>
+  </html>
+);
diff --git a/src/_includes/styles/base.scss b/src/_includes/styles/base.scss
index 4a91f07..a6ba56a 100644
--- a/src/_includes/styles/base.scss
+++ b/src/_includes/styles/base.scss
@@ -10,15 +10,19 @@
 @use "styles/external/nord.min";
 
 // // Font
-@import url("https://rsms.me/inter/inter.css");
+// @import url("https://rsms.me/inter/inter.css");
+
+// /* CSS */
+// :root {
+//   font-family: "Inter", sans-serif;
+// }
+
+// @supports (font-variation-settings: normal) {
+//   :root {
+//     font-family: "Inter var", sans-serif;
+//   }
+// }
 
-/* CSS */
 :root {
-  font-family: "Inter", sans-serif;
-}
-
-@supports (font-variation-settings: normal) {
-  :root {
-    font-family: "Inter var", sans-serif;
-  }
-}
+  font-family: -apple-system, BlinkMacSystemFont, "Avenir Next", Avenir, "Nimbus Sans L", Roboto, Noto, "Segoe UI", Arial, Helvetica, "Helvetica Neue", sans-serif;
+}
\ No newline at end of file
diff --git a/src/_includes/types.ts b/src/_includes/types.ts
new file mode 100644
index 0000000..e69de29
diff --git a/src/about.md b/src/about.md
new file mode 100644
index 0000000..a41b552
--- /dev/null
+++ b/src/about.md
@@ -0,0 +1,29 @@
+---
+title: About me
+subtitle: This is actually just a list of things I host because I have the personality of a ham sandwich
+layout: layouts/about.tsx
+---
+
+### An inexhaustible list of everything I host :)
+
+- [Status page](https://status.froth.zone)
+
+#### Federated stuff :)
+
+- [Pleroma](https://froth.zone)
+- [Gitea](https://git.froth.zone)
+- [Writefreely](https://blog.froth.zone)
+- [PeerTube](https://tube.froth.zone)
+- [Funkwhale](https://funkwhale.samtherapy.net)
+- [Fedifeed (pictured either to the right or below)](https://fedifeed.com)
+
+#### Private frontends
+
+- [Invidious for YouTube](https://invidious.froth.zone)
+- [Nitter for Twitter](https://nitter.bird.froth.zone)
+- [Teddit for Reddit](https://teddit.froth.zone)
+- [Scribe for Medium](https://scribe.froth.zone)
+
+##### DNS
+
+I also self-host [all of my DNS](https://dns.froth.zone).
diff --git a/src/index.md b/src/index.md
new file mode 100644
index 0000000..1e03d16
--- /dev/null
+++ b/src/index.md
@@ -0,0 +1,11 @@
+---
+title: Sam's Website, 2.0
+subtitle: Under construction since October 2022
+layout: layouts/head.tsx
+---
+
+### Hello there.
+
+Website!
+
+[Information, I guess](/about)
diff --git a/src/index.tsx b/src/index.tsx
deleted file mode 100644
index 273adc7..0000000
--- a/src/index.tsx
+++ /dev/null
@@ -1,19 +0,0 @@
-import { PageData } from "lume/core.ts";
-
-export const title = "Sam Site 2.0";
-export const layout = "layouts/head.njk";
-
-export default ({ data }: PageData) => (
-  <>
-    <header class="container">
-      <hgroup>
-        <h1>{title}</h1>
-        <h2>Stuff</h2>
-      </hgroup>
-    </header>
-    <main class="container">
-      <p>There was a website here. There isn't anymore.</p>
-      <p>There will be, eventually.</p>
-    </main>
-  </>
-);
diff --git a/src/.well-known/host-meta.json b/src/static/.well-known/host-meta.json
similarity index 100%
rename from src/.well-known/host-meta.json
rename to src/static/.well-known/host-meta.json
diff --git a/src/img/favicon.png b/src/static/img/favicon.png
similarity index 100%
rename from src/img/favicon.png
rename to src/static/img/favicon.png
diff --git a/static/img/favicon.png b/static/img/favicon.png
new file mode 100644
index 0000000000000000000000000000000000000000..6e027bf76f3a7c10ebe63a199d0e3dd2651db212
GIT binary patch
diff --git a/velociraptor.yaml b/velociraptor.yaml
new file mode 100644
index 0000000..ec4bb86
--- /dev/null
+++ b/velociraptor.yaml
@@ -0,0 +1,8 @@
+scripts:
+  lint: deno lint
+  format: deno fmt
+  pre-commit:
+    cmd:
+      - vr lint
+      - vr format
+    gitHook: pre-commit
\ No newline at end of file
