From c8b5f726572aa2fd17070b01e72b5137ebbe45b4 Mon Sep 17 00:00:00 2001 From: Dave Smith-Hayes Date: Tue, 22 Oct 2024 20:44:00 -0400 Subject: [PATCH] Add a Site TOML, the TOML parser, Feed generator, and a small test for parsing the site TOML. --- bun.lockb | Bin 29014 -> 30384 bytes config/site.toml | 12 ++++++++++++ package.json | 2 ++ src/config.ts | 1 + src/services/config.test.ts | 9 +++++++++ src/services/config.ts | 10 ++++++++++ src/services/feed-generator.ts | 14 ++++++++++++++ 7 files changed, 48 insertions(+) create mode 100644 config/site.toml create mode 100644 src/services/config.test.ts create mode 100644 src/services/config.ts create mode 100644 src/services/feed-generator.ts diff --git a/bun.lockb b/bun.lockb index de1a3d2070d0b0fdd2cf22b67f7589de94b66604..9f740604e14fee9bfe52edb3b6174d5350b8dc2a 100755 GIT binary patch delta 5942 zcmbtY3s_Xu7Cw6foB>BvAm%U(%m{*rGsA!gihyYG8c@u~2!=O&At>Sl70ZN7y_y=* z>fs|lGgGsx-_5w%!&}Bpi>}wqzI(l)X)oDSw4~+TO)0fay9fLB_BVWA6EJe-puIbq3xsE(b)KY@ zyhcxC(AHd)wEyNbu88dZq>v{k7a|`h{51Nl2liph)P#gS0TCoDTOCV^(#@~fi+&~ zf#h&anml1{IpSG0M-BF~P{iRoM0vW{{3(+sPvZ94s_FJhjF?kas|Aktuhn?HF|uOpOTp|r+)%WG_cF#g159bUw`0N?oc`o(HKf$AsM=NL#YI!n~By#j55*jkb!l0()>0`crp0xR3xIW6qdX? zVyu)OlWa1gAR!C+<0Rqr;cthcClZq9TLCUs<@Y98r!;W~540)lX2}Yp0VKB6*W1sM z+noR#?gDszBESaq_wp1-E*&M0O9gn|KuKMnzZ8msG_M@w9gqRZg(WK<0&tXu0jy{^ zfK1|aQTiuAa{FX}4aBRc6qejx0r0}pys`>k2;O|8`v5L1d15`l3oh}>$o#uY;9x1&i+GfpIN$mlKM1REG9Y`?iL1$vv}w|i;-4a+#-Nl z!InoDDLuk1jI<)c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VHk=b9h z(rnx4okm%U+^&Cwr;c0;zn*!{XAr!2`BJl_`=X^RiF)pk@$rb}^z3LNRi{-4JocMs zh^Ven&cAsWH_u={Jq>q*T-PUAE9xM}e2;&4{o{JgN0lEO+4b`HK>S;2&wSaSB~$FB z&zod1L>K1Y$|LM9|VE*{=VA&|31v?9x+zdMn_cnha4z z2b<&=?SBXSPtlbb?vpl*1gwISW!L|vc=H+K;L_W+9}AfEQ#Qi?bztjKs$=)}2tbeBKcbzaOa^<_+IgHq)$ diff --git a/config/site.toml b/config/site.toml new file mode 100644 index 0000000..f8b225d --- /dev/null +++ b/config/site.toml @@ -0,0 +1,12 @@ +title = "davesmithhayes.com" + +[owner] +name = "Dave Smith-Hayes" +email = "me@davesmithhayes.com" + +[site] +description = "Personal website of Dave Smith-Hayes - a father, developer, and musician." +url = "https://davesmithhayes.com" +repo = "https://git.davesmithhayes.com/dsh/blog" +language = "en" +copyright = "All rights reserved, Dave Smith-Hayes" diff --git a/package.json b/package.json index 062425e..cec3596 100644 --- a/package.json +++ b/package.json @@ -5,11 +5,13 @@ }, "dependencies": { "@types/yaml-front-matter": "^4.1.3", + "feed": "^4.2.2", "highlight.js": "^11.10.0", "hono": "^4.4.13", "marked": "^13.0.2", "marked-highlight": "^2.1.3", "remark": "^15.0.1", + "smol-toml": "^1.3.0", "yaml-front-matter": "^4.1.1" }, "devDependencies": { diff --git a/src/config.ts b/src/config.ts index 8d62b5f..168469b 100644 --- a/src/config.ts +++ b/src/config.ts @@ -1,3 +1,4 @@ export const POST_PATH: string = __dirname + '/../posts'; +export const CONFIG_PATH: string = __dirname + '/../config'; export const STATIC_PATH: string = __dirname + '/assets'; export const POST_ROUTE_PREFIX: string = '/posts' diff --git a/src/services/config.test.ts b/src/services/config.test.ts new file mode 100644 index 0000000..2a76e1b --- /dev/null +++ b/src/services/config.test.ts @@ -0,0 +1,9 @@ +import { describe, expect, test } from 'bun:test' +import { getSiteConfig } from '@blog/services/config'; + +describe("Test the global config for the site", () => { + test("Parses the Owner", async () => { + const siteConfig = await getSiteConfig(); + expect(siteConfig.owner.email).toBe("me@davesmithhayes.com"); + }) +}) diff --git a/src/services/config.ts b/src/services/config.ts new file mode 100644 index 0000000..6065132 --- /dev/null +++ b/src/services/config.ts @@ -0,0 +1,10 @@ +import TOML from 'smol-toml'; +import { CONFIG_PATH } from '@blog/config'; + +export async function getSiteConfig() { + const siteConfig = CONFIG_PATH + '/site.toml'; + const file = Bun.file(siteConfig); + const data = await file.text(); + + return TOML.parse(data); +} diff --git a/src/services/feed-generator.ts b/src/services/feed-generator.ts new file mode 100644 index 0000000..47d0493 --- /dev/null +++ b/src/services/feed-generator.ts @@ -0,0 +1,14 @@ +// generate the feed +// + +import { Feed, FeedOptions } from 'feed'; + +export async function feedFactory(): Feed { + +} + +export async function generateFeed(posts: PostService, feed: Feed): Feed { + const feed = new Feed({}); + + return feed; +}