From 3e4695131751e308410ac8da7ce42f883c278348 Mon Sep 17 00:00:00 2001 From: Orion Reed Date: Sat, 12 Aug 2023 16:48:38 +0100 Subject: [PATCH] improved stream --- index.html | 4 +- package-lock.json | 237 ++++++++++++++++++++++++++++++++++++++++++- package.json | 4 +- public/stream.jsonl | 6 +- public/stream/1.md | 5 + public/stream/2.md | 6 ++ public/stream/3.md | 4 + public/stream/4.md | 58 +++++++++++ scripts/prebuild.mjs | 27 ++++- src/pages/Posts.tsx | 44 +++----- src/pages/Stream.tsx | 80 +++++++++------ src/style.ts | 3 +- src/utils.ts | 6 +- vite.config.ts | 9 +- 14 files changed, 416 insertions(+), 77 deletions(-) create mode 100644 public/stream/1.md create mode 100644 public/stream/2.md create mode 100644 public/stream/3.md create mode 100644 public/stream/4.md diff --git a/index.html b/index.html index f480131..3fbcd9a 100644 --- a/index.html +++ b/index.html @@ -6,10 +6,8 @@ - Orion Reed diff --git a/package-lock.json b/package-lock.json index 7dffdd8..cfadea8 100644 --- a/package-lock.json +++ b/package-lock.json @@ -26,7 +26,8 @@ "glob": "^10.3.3", "markdown-to-jsx": "^7.3.2", "typescript": "^5.1.6", - "vite": "^4.4.9" + "vite": "^4.4.9", + "vite-plugin-top-level-await": "^1.3.1" } }, "deps/gray-matter": { @@ -1305,6 +1306,23 @@ "react": "^16.8 || ^17.0 || ^18.0" } }, + "node_modules/@rollup/plugin-virtual": { + "version": "3.0.1", + "resolved": "https://registry.npmjs.org/@rollup/plugin-virtual/-/plugin-virtual-3.0.1.tgz", + "integrity": "sha512-fK8O0IL5+q+GrsMLuACVNk2x21g3yaw+sG2qn16SnUd3IlBsQyvWxLMGHmCmXRMecPjGRSZ/1LmZB4rjQm68og==", + "dev": true, + "engines": { + "node": ">=14.0.0" + }, + "peerDependencies": { + "rollup": "^1.20.0||^2.0.0||^3.0.0" + }, + "peerDependenciesMeta": { + "rollup": { + "optional": true + } + } + }, "node_modules/@rollup/pluginutils": { "version": "4.2.1", "resolved": "https://registry.npmjs.org/@rollup/pluginutils/-/pluginutils-4.2.1.tgz", @@ -1318,6 +1336,200 @@ "node": ">= 8.0.0" } }, + "node_modules/@swc/core": { + "version": "1.3.76", + "resolved": "https://registry.npmjs.org/@swc/core/-/core-1.3.76.tgz", + "integrity": "sha512-aYYTA2aVYkwJAZepQXtPnkUthhOfn8qd6rsh+lrJxonFrjmpI7RHt2tMDVTXP6XDX7fvnvrVtT1bwZfmBFPh0Q==", + "dev": true, + "hasInstallScript": true, + "engines": { + "node": ">=10" + }, + "funding": { + "type": "opencollective", + "url": "https://opencollective.com/swc" + }, + "optionalDependencies": { + "@swc/core-darwin-arm64": "1.3.76", + "@swc/core-darwin-x64": "1.3.76", + "@swc/core-linux-arm-gnueabihf": "1.3.76", + "@swc/core-linux-arm64-gnu": "1.3.76", + "@swc/core-linux-arm64-musl": "1.3.76", + "@swc/core-linux-x64-gnu": "1.3.76", + "@swc/core-linux-x64-musl": "1.3.76", + "@swc/core-win32-arm64-msvc": "1.3.76", + "@swc/core-win32-ia32-msvc": "1.3.76", + "@swc/core-win32-x64-msvc": "1.3.76" + }, + "peerDependencies": { + "@swc/helpers": "^0.5.0" + }, + "peerDependenciesMeta": { + "@swc/helpers": { + "optional": true + } + } + }, + "node_modules/@swc/core-darwin-arm64": { + "version": "1.3.76", + "resolved": "https://registry.npmjs.org/@swc/core-darwin-arm64/-/core-darwin-arm64-1.3.76.tgz", + "integrity": "sha512-ovviEhZ/1E81Z9OGrO0ivLWk4VCa3I3ZzM+cd3gugglRRwVwtlIaoIYqY5S3KiCAupDd1+UCl5X7Vbio7a/V8g==", + "cpu": [ + "arm64" + ], + "dev": true, + "optional": true, + "os": [ + "darwin" + ], + "engines": { + "node": ">=10" + } + }, + "node_modules/@swc/core-darwin-x64": { + "version": "1.3.76", + "resolved": "https://registry.npmjs.org/@swc/core-darwin-x64/-/core-darwin-x64-1.3.76.tgz", + "integrity": "sha512-tcySTDqs0SHCebtW35sCdcLWsmTEo7bEwx0gNL/spetqVT9fpFi6qU8qcnt7i2KaZHbeNl9g1aadu+Yrni+GzA==", + "cpu": [ + "x64" + ], + "dev": true, + "optional": true, + "os": [ + "darwin" + ], + "engines": { + "node": ">=10" + } + }, + "node_modules/@swc/core-linux-arm-gnueabihf": { + "version": "1.3.76", + "resolved": "https://registry.npmjs.org/@swc/core-linux-arm-gnueabihf/-/core-linux-arm-gnueabihf-1.3.76.tgz", + "integrity": "sha512-apgzpGWy1AwoMF4urAAASsAjE7rEzZFIF+p6utuxhS7cNHzE0AyEVDYJbo+pzBdlZ8orBdzzsHtFwoEgKOjebA==", + "cpu": [ + "arm" + ], + "dev": true, + "optional": true, + "os": [ + "linux" + ], + "engines": { + "node": ">=10" + } + }, + "node_modules/@swc/core-linux-arm64-gnu": { + "version": "1.3.76", + "resolved": "https://registry.npmjs.org/@swc/core-linux-arm64-gnu/-/core-linux-arm64-gnu-1.3.76.tgz", + "integrity": "sha512-c3c0zz6S0eludqidDpuqbadE0WT3OZczyQxe9Vw8lFFXES85mvNGtwYzyGK2o7TICpsuHrndwDIoYpmpWk879g==", + "cpu": [ + "arm64" + ], + "dev": true, + "optional": true, + "os": [ + "linux" + ], + "engines": { + "node": ">=10" + } + }, + "node_modules/@swc/core-linux-arm64-musl": { + "version": "1.3.76", + "resolved": "https://registry.npmjs.org/@swc/core-linux-arm64-musl/-/core-linux-arm64-musl-1.3.76.tgz", + "integrity": "sha512-Is3bpq7F2qtlnkzEeOD6HIZJPpOmu3q6c82lKww90Q0NnrlSluVMozTHJgwVoFZyizH7uLnk0LuNcEAWLnmJIw==", + "cpu": [ + "arm64" + ], + "dev": true, + "optional": true, + "os": [ + "linux" + ], + "engines": { + "node": ">=10" + } + }, + "node_modules/@swc/core-linux-x64-gnu": { + "version": "1.3.76", + "resolved": "https://registry.npmjs.org/@swc/core-linux-x64-gnu/-/core-linux-x64-gnu-1.3.76.tgz", + "integrity": "sha512-iwCeRzd9oSvUzqt7nU6p/ztceAWfnO9XVxBn502R5gs6QCBbE1HCKrWHDO77aKPK7ss+0NcIGHvXTd9L8/wRzw==", + "cpu": [ + "x64" + ], + "dev": true, + "optional": true, + "os": [ + "linux" + ], + "engines": { + "node": ">=10" + } + }, + "node_modules/@swc/core-linux-x64-musl": { + "version": "1.3.76", + "resolved": "https://registry.npmjs.org/@swc/core-linux-x64-musl/-/core-linux-x64-musl-1.3.76.tgz", + "integrity": "sha512-a671g4tW8kyFeuICsgq4uB9ukQfiIyXJT4V6YSnmqhCTz5mazWuDxZ5wKnx/1g5nXTl+U5cWH2TZaCJatp4GKA==", + "cpu": [ + "x64" + ], + "dev": true, + "optional": true, + "os": [ + "linux" + ], + "engines": { + "node": ">=10" + } + }, + "node_modules/@swc/core-win32-arm64-msvc": { + "version": "1.3.76", + "resolved": "https://registry.npmjs.org/@swc/core-win32-arm64-msvc/-/core-win32-arm64-msvc-1.3.76.tgz", + "integrity": "sha512-+swEFtjdMezS0vKUhJC3psdSDtOJGY5pEOt4e8XOPvn7aQpKQ9LfF49XVtIwDSk5SGuWtVoLFzkSY3reWUJCyg==", + "cpu": [ + "arm64" + ], + "dev": true, + "optional": true, + "os": [ + "win32" + ], + "engines": { + "node": ">=10" + } + }, + "node_modules/@swc/core-win32-ia32-msvc": { + "version": "1.3.76", + "resolved": "https://registry.npmjs.org/@swc/core-win32-ia32-msvc/-/core-win32-ia32-msvc-1.3.76.tgz", + "integrity": "sha512-5CqwAykpGBJ3PqGLOlWGLGIPpBAG1IwWVDUfro3hhjQ7XJxV5Z1aQf5V5OJ90HJVtrEAVx2xx59UV/Dh081LOg==", + "cpu": [ + "ia32" + ], + "dev": true, + "optional": true, + "os": [ + "win32" + ], + "engines": { + "node": ">=10" + } + }, + "node_modules/@swc/core-win32-x64-msvc": { + "version": "1.3.76", + "resolved": "https://registry.npmjs.org/@swc/core-win32-x64-msvc/-/core-win32-x64-msvc-1.3.76.tgz", + "integrity": "sha512-CiMpWLLlR3Cew9067E7XxaLBwYYJ90r9EhGSO6V1pvYSWj7ET/Ppmtj1ZhzPJMqRXAP6xflfl5R5o4ee1m4WLA==", + "cpu": [ + "x64" + ], + "dev": true, + "optional": true, + "os": [ + "win32" + ], + "engines": { + "node": ">=10" + } + }, "node_modules/@types/node": { "version": "20.4.9", "resolved": "https://registry.npmjs.org/@types/node/-/node-20.4.9.tgz", @@ -7875,6 +8087,15 @@ "integrity": "sha512-EPD5q1uXyFxJpCrLnCc1nHnq3gOa6DZBocAIiI2TaSCA7VCJ1UJDMagCzIkXNsUYfD1daK//LTEQ8xiIbrHtcw==", "dev": true }, + "node_modules/uuid": { + "version": "9.0.0", + "resolved": "https://registry.npmjs.org/uuid/-/uuid-9.0.0.tgz", + "integrity": "sha512-MXcSTerfPa4uqyzStbRoTgt5XIe3x5+42+q1sDuy3R5MDk66URdLMOZe5aPX/SQd+kuYAh0FdP/pO28IkQyTeg==", + "dev": true, + "bin": { + "uuid": "dist/bin/uuid" + } + }, "node_modules/vinyl": { "version": "2.2.1", "resolved": "https://registry.npmjs.org/vinyl/-/vinyl-2.2.1.tgz", @@ -7947,6 +8168,20 @@ } } }, + "node_modules/vite-plugin-top-level-await": { + "version": "1.3.1", + "resolved": "https://registry.npmjs.org/vite-plugin-top-level-await/-/vite-plugin-top-level-await-1.3.1.tgz", + "integrity": "sha512-55M1h4NAwkrpxPNOJIBzKZFihqLUzIgnElLSmPNPMR2Fn9+JHKaNg3sVX1Fq+VgvuBksQYxiD3OnwQAUu7kaPQ==", + "dev": true, + "dependencies": { + "@rollup/plugin-virtual": "^3.0.1", + "@swc/core": "^1.3.10", + "uuid": "^9.0.0" + }, + "peerDependencies": { + "vite": ">=2.8" + } + }, "node_modules/warning-symbol": { "version": "0.1.0", "resolved": "https://registry.npmjs.org/warning-symbol/-/warning-symbol-0.1.0.tgz", diff --git a/package.json b/package.json index 37651f0..efea247 100644 --- a/package.json +++ b/package.json @@ -4,6 +4,7 @@ "type": "module", "scripts": { "dev": "vite", + "prebuild": "node scripts/prebuild.mjs", "build": "node scripts/prebuild.mjs && vite build", "preview": "vite preview" }, @@ -28,6 +29,7 @@ "glob": "^10.3.3", "markdown-to-jsx": "^7.3.2", "typescript": "^5.1.6", - "vite": "^4.4.9" + "vite": "^4.4.9", + "vite-plugin-top-level-await": "^1.3.1" } } diff --git a/public/stream.jsonl b/public/stream.jsonl index 8227027..ac1ca9e 100644 --- a/public/stream.jsonl +++ b/public/stream.jsonl @@ -1,2 +1,4 @@ -{"id":0, "date":"2023-01-11","text":">When asked, “How could you possibly have done the first interactive graphics program, the first non-procedural programming language, the first object oriented software system, all in one year?” Ivan replied: “Well, I didnt know it was hard.”\n\n— via Alan Kay, Doing with Images Makes Symbols, 1987"} -{"id":1, "date":"2023-05-21","text":"**Little excerpt**\n\nAn approach to interfaces in which a network of transformations, constraints, preferences, and other relations connect object(s) of interest to an interface surrogate. The system as a whole is responsible for resolving the arbitrary and complex relationship between an object and surrogate and bridging that surrogate representation to a representation which is observable to users."} \ No newline at end of file +{"date":"2019-01-01T00:00:00.000Z","text":"# This is a test\nhere is some text... I think once I can author posts and thoughts in here, I'll be able to get a lot more done.\n","id":0} +{"date":"2020-01-01T00:00:00.000Z","text":"Lorum ipsum dolor sit amet, conse.\n- This is a task\n- This is another task\n","id":1} +{"date":"2023-05-11T00:00:00.000Z","text":"multiple file formats\n\n\n- heterogenous decentralisation\n- cats is about objects which are processes, making them deployable as infrastructure\n- processes are blocks. cats, like blocks, do not care what the objects being processed are\n- RIDs for CARs? (is this RIDs for identity too?)\n\t- how to represent and deploy inter-systemic (Identity) relations\n- are relations the same as blocks? are they a superset? subset?\n- to Z: how would a non-process relation be represented as a block? i.e. relations\n\t- symmetric blocks? \n- content-addressed files form a network of acyclical reference\n\nportable relations & (RIDs for) content-addressed relations\n```\nRID[CID] -> {\n\trelation: RID (Identity)\n\trelata: set | (set, set)\n}\n```\n\n```\nAdd -> {\n\trelation: AddBlock\n\trelata: [\n\t\tspace_1,\n\t\tspace_2\n\t]\n}\n\nReduceDimensions -> {\n\trelation: ReduceDimensionsProcess\n\trelata: {...}\n}\n\nIsomorphic -> {\n\trelation: Isomorphism\n\trelata: {...}\n}\n```\n\n```\nIdentity -> {\n\trelation: Identity\n\trelata: {O1, O2, ..., On}\n}\n```\n\nIdentity and symmetric functions\n\n$C(S, D) \\land \\forall O_1, O_2 \\in \\text{Identity}: S(O_1, O_2) \\land (O_1 \\neq O_2 \\rightarrow D(O_1, O_2))$\n\n- $S(f, g) \\equiv \\forall x \\in \\text{Domain}(f) \\cap \\text{Domain}(g): f(x) = g(x)$\n\n$S((f_1, g_1), (f_2, g_2)) \\equiv \\forall a \\in \\text{Domain}(f_1) \\cap \\text{Domain}(f_2): g_1(f_1(a)) = a = g_2(f_2(a))$ and $\\forall b \\in \\text{Domain}(g_1) \\cap \\text{Domain}(g_2): f_1(g_1(b)) = b = f_2(g_2(b))$.\n","id":2} +{"date":"2023-05-11T00:00:00.000Z","text":"I need to try and catch this system out with some `special characters` and unescaped bit's of stuff... What about links? [like this](https://www.google.com)","id":3} \ No newline at end of file diff --git a/public/stream/1.md b/public/stream/1.md new file mode 100644 index 0000000..e10d6e1 --- /dev/null +++ b/public/stream/1.md @@ -0,0 +1,5 @@ +--- +date: 2019-01-01 00:00:00 +--- +# This is a test +here is some text... I think once I can author posts and thoughts in here, I'll be able to get a lot more done. diff --git a/public/stream/2.md b/public/stream/2.md new file mode 100644 index 0000000..68aeeaa --- /dev/null +++ b/public/stream/2.md @@ -0,0 +1,6 @@ +--- +date: 2020-01-01 00:00:00 +--- +Lorum ipsum dolor sit amet, conse. +- This is a task +- This is another task diff --git a/public/stream/3.md b/public/stream/3.md new file mode 100644 index 0000000..eb9b9f2 --- /dev/null +++ b/public/stream/3.md @@ -0,0 +1,4 @@ +--- +date: 2023-05-11 00:00:00 +--- +I need to try and catch this system out with some `special characters` and unescaped bit's of stuff... What about links? [like this](https://www.google.com) \ No newline at end of file diff --git a/public/stream/4.md b/public/stream/4.md new file mode 100644 index 0000000..3946131 --- /dev/null +++ b/public/stream/4.md @@ -0,0 +1,58 @@ +--- +date: 2023-05-11 00:00:00 +--- +multiple file formats + + +- heterogenous decentralisation +- cats is about objects which are processes, making them deployable as infrastructure +- processes are blocks. cats, like blocks, do not care what the objects being processed are +- RIDs for CARs? (is this RIDs for identity too?) + - how to represent and deploy inter-systemic (Identity) relations +- are relations the same as blocks? are they a superset? subset? +- to Z: how would a non-process relation be represented as a block? i.e. relations + - symmetric blocks? +- content-addressed files form a network of acyclical reference + +portable relations & (RIDs for) content-addressed relations +``` +RID[CID] -> { + relation: RID (Identity) + relata: set | (set, set) +} +``` + +``` +Add -> { + relation: AddBlock + relata: [ + space_1, + space_2 + ] +} + +ReduceDimensions -> { + relation: ReduceDimensionsProcess + relata: {...} +} + +Isomorphic -> { + relation: Isomorphism + relata: {...} +} +``` + +``` +Identity -> { + relation: Identity + relata: {O1, O2, ..., On} +} +``` + +Identity and symmetric functions + +$C(S, D) \land \forall O_1, O_2 \in \text{Identity}: S(O_1, O_2) \land (O_1 \neq O_2 \rightarrow D(O_1, O_2))$ + +- $S(f, g) \equiv \forall x \in \text{Domain}(f) \cap \text{Domain}(g): f(x) = g(x)$ + +$S((f_1, g_1), (f_2, g_2)) \equiv \forall a \in \text{Domain}(f_1) \cap \text{Domain}(f_2): g_1(f_1(a)) = a = g_2(f_2(a))$ and $\forall b \in \text{Domain}(g_1) \cap \text{Domain}(g_2): f_1(g_1(b)) = b = f_2(g_2(b))$. diff --git a/scripts/prebuild.mjs b/scripts/prebuild.mjs index ab19e8f..c566f98 100755 --- a/scripts/prebuild.mjs +++ b/scripts/prebuild.mjs @@ -2,9 +2,9 @@ import {glob} from 'glob'; import fs from 'fs'; import fm from 'front-matter'; -const posts_dir = 'public/posts/'; -function loadStrings() { +function loadPosts() { + const posts_dir = 'public/posts/'; const posts = glob.sync(`${posts_dir}*.md`).map((file) => { const content = fs.readFileSync(file, 'utf8'); const slug = file.replace(`${posts_dir}`, '').replace('.md', ''); @@ -14,8 +14,25 @@ function loadStrings() { return posts.sort((a, b) => new Date(a.date) - new Date(b.date)); } -function saveStrings(posts) { - fs.writeFileSync('public/posts.jsonl', posts.map((post) => JSON.stringify(post)).join('\n')); +function loadStream() { + const streams_dir = 'public/stream/'; + const posts = glob.sync(`${streams_dir}*.md`).map((file) => { + const content = fs.readFileSync(file, 'utf8'); + const md = fm(content) + const { date } = md.attributes; + const text = md.body; + return { date, text }; + }); + posts.sort((a, b) => new Date(a.date) - new Date(b.date)) + posts.forEach((post, i) => { + post.id = i; + }) + return posts } -saveStrings(loadStrings()); \ No newline at end of file +function saveJsonl(entries, file) { + fs.writeFileSync(file, entries.map((e) => JSON.stringify(e)).join('\n')); +} + +saveJsonl(loadPosts(), 'public/posts.jsonl'); +saveJsonl(loadStream(), 'public/stream.jsonl'); \ No newline at end of file diff --git a/src/pages/Posts.tsx b/src/pages/Posts.tsx index 2b8bd56..ed5c939 100644 --- a/src/pages/Posts.tsx +++ b/src/pages/Posts.tsx @@ -9,7 +9,8 @@ import { createStyles, } from '@mantine/core' import { friendlyDate, getJsonl } from '@/utils' -import { useEffect, useState } from 'preact/hooks' + +const posts = await getJsonl('posts.jsonl') type Post = { slug: string @@ -54,31 +55,18 @@ function Frame({ children }) { } export function Posts() { - const [posts, setPost] = useState>(null) - useEffect(() => { - getJsonl('posts.jsonl').then(setPost) - }, []) - - if (!posts) { - return ( - - Loading posts... - - ) - } else { - return ( - - {posts.map((post, index, array) => { - return ( - - ) - })} - - ) - } + return ( + + {posts.map((post, index, array) => { + return ( + + ) + })} + + ) } diff --git a/src/pages/Stream.tsx b/src/pages/Stream.tsx index 37eedea..09b3aab 100644 --- a/src/pages/Stream.tsx +++ b/src/pages/Stream.tsx @@ -7,6 +7,7 @@ import { createStyles, Title, TextInput, + Anchor, } from '@mantine/core' import { Header } from '@/components/Header' import Markdown from 'markdown-to-jsx' @@ -16,7 +17,6 @@ import { friendlyDate, getJsonl } from '@/utils' const search = signal('') -const margin = '0.3em' const streamItems = await getJsonl('stream.jsonl') const miniSearch = new MiniSearch({ fields: ['text'], // fields to index for full-text search @@ -28,31 +28,22 @@ const miniSearch = new MiniSearch({ }) miniSearch.addAll(streamItems) +const heading = { fontSize: '1.2em', marginBottom: 0 } +const margin = '0.3em' +const marginY = { marginTop: margin, marginBottom: margin } const useStyles = createStyles((theme) => ({ - group: { - color: theme.black, - lineHeight: '1.4em', - fontFamily: theme.headings.fontFamily, - }, + group: {}, item: { + color: theme.black, + fontFamily: theme.headings.fontFamily, + lineHeight: '1.2em', flexWrap: 'nowrap', + fontSize: '0.85em', '& :first-of-type': { marginTop: 0, }, - '& p': { - marginTop: margin, - marginBottom: margin, - }, - '& pre': { - marginTop: margin, - marginBottom: margin, - }, - '& ul': { - marginTop: margin, - marginBottom: margin, - paddingLeft: '1.4em', - }, - + '& p': marginY, + '& ul': { ...marginY, marginLeft: '0em', paddingLeft: '1em' }, '& blockquote': { marginTop: '0.8em', marginBottom: '0.8em', @@ -60,32 +51,57 @@ const useStyles = createStyles((theme) => ({ paddingLeft: '1em', borderLeft: `0.25em solid ${theme.colors.gray[3]}`, }, + '& h1': heading, + '& h2': heading, + '& h3': heading, + '& h4': heading, + '& h5': heading, + '& h6': heading, + '& code': { + fontFamily: theme.fontFamilyMonospace, + background: theme.colors.gray[1], + borderRadius: theme.radius.sm, + paddingLeft: '0.2em', + paddingRight: '0.2em', + fontSize: '0.8em', + }, + '& pre': { + background: theme.colors.gray[1], + padding: theme.spacing.sm, + borderRadius: theme.radius.sm, + }, }, date: { - fontFamily: theme.headings.fontFamily, - + fontFamily: theme.fontFamilyMonospace, + fontSize: '0.8em', marginRight: '0.2em', whiteSpace: 'nowrap', }, search: { - fontFamily: theme.headings.fontFamily, - // border: `1px solid red`, - fontSize: '4em', - '& :focus': { - border: `1px solid ${theme.black}`, + '& input': { + ':focus': { + border: `1px solid ${theme.colors.gray[4]}`, + }, + fontFamily: theme.headings.fontFamily, + fontWeight: 500, }, }, })) +const markdownOptions = { + overrides: { + a: Anchor, + }, +} function StreamItem({ date, markdown }) { const { classes } = useStyles() return ( - {friendlyDate(date)} + {friendlyDate(date, 'dd/MMM/yyyy')} - {markdown} + {markdown} ) @@ -104,17 +120,17 @@ function Search() { search.value = event.target.value }} my="sm" + size="md" + variant="filled" + placeholder="Search..." className={classes.search} - placeholder="Search" /> ) } export default function Stream() { const { classes } = useStyles() - console.log(search.value) const results = !search.value ? streamItems : miniSearch.search(search.value) - console.log(results) return ( <> diff --git a/src/style.ts b/src/style.ts index 6e0922a..5ae0d34 100644 --- a/src/style.ts +++ b/src/style.ts @@ -1,7 +1,8 @@ export const style = { fontFamily: 'Alegreya, serif', + fontFamilyMonospace: 'IBM Plex Mono, monospace', headings: { - fontFamily: ['Alegreya Sans'], + fontFamily: ['Alegreya Sans, sans-serif'], fontWeight: 700, }, lineHeight: 1.5, diff --git a/src/utils.ts b/src/utils.ts index ffe097c..c717fc9 100644 --- a/src/utils.ts +++ b/src/utils.ts @@ -1,12 +1,12 @@ import { format } from 'date-fns' -export function friendlyDate(dateString: string): string { +export function friendlyDate(dateString: string, format_str?: string): string { const inputDate = new Date(dateString) - return format(inputDate, 'do MMM yyyy') + return format(inputDate, format_str || 'do MMM yyyy') } export async function getJsonl(file: string) { - const response = await fetch('stream.jsonl') + const response = await fetch(file) return await (await response.text()).split('\n').map((post) => { return JSON.parse(post) }) diff --git a/vite.config.ts b/vite.config.ts index 04247ad..7880842 100644 --- a/vite.config.ts +++ b/vite.config.ts @@ -2,9 +2,16 @@ import { defineConfig } from 'vite' import preact from '@preact/preset-vite' import { NodeGlobalsPolyfillPlugin } from '@esbuild-plugins/node-globals-polyfill' import path from 'path' +import topLevelAwait from 'vite-plugin-top-level-await' export default defineConfig({ - plugins: [preact()], + plugins: [ + preact(), + topLevelAwait({ + promiseExportName: '__tla', + promiseImportName: (i) => `__tla_${i}`, + }), + ], assetsInclude: ['**/*.md'], resolve: { alias: {