-
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Refactor components to improve organization
- Loading branch information
1 parent
b2a95fd
commit 00de119
Showing
12 changed files
with
520 additions
and
540 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,11 +1,15 @@ | ||
"use client"; | ||
|
||
import ReactMarkdown from "react-markdown"; | ||
import remarkGfm from "remark-gfm"; | ||
|
||
export const MarkdownView = ({ content }: { content: string }) => { | ||
return ( | ||
<ReactMarkdown className="prose max-w-5xl dark:prose-invert"> | ||
{content} | ||
</ReactMarkdown> | ||
); | ||
return ( | ||
<ReactMarkdown | ||
remarkPlugins={[remarkGfm]} | ||
className="prose max-w-5xl dark:prose-invert" | ||
> | ||
{content} | ||
</ReactMarkdown> | ||
); | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,47 @@ | ||
import Database from "better-sqlite3"; | ||
|
||
export class CacheStore { | ||
#db; | ||
|
||
constructor() { | ||
this.#db = this.#openDatabase(); | ||
} | ||
|
||
#openDatabase() { | ||
const db = new Database("sqlite/cache.db"); | ||
|
||
db.prepare(` | ||
CREATE TABLE IF NOT EXISTS key_value ( | ||
key TEXT NOT NULL PRIMARY KEY, | ||
value, | ||
UNIQUE(key) | ||
); | ||
`).run(); | ||
|
||
return db; | ||
} | ||
|
||
get<T>(key: string) { | ||
const result = this.#db | ||
.prepare("SELECT value FROM key_value WHERE key = ?;") | ||
.get(key); | ||
|
||
const value = (result as { value: string })?.value; | ||
if (!value) return undefined; | ||
return JSON.parse(value as string) as T; | ||
} | ||
|
||
set(key: string, value: string | number) { | ||
const result = this.#db | ||
.prepare( | ||
"INSERT OR REPLACE INTO key_value (key, value) VALUES (?, ?) RETURNING *;", | ||
) | ||
.run(key, JSON.stringify(value)); | ||
|
||
return result; | ||
} | ||
|
||
delete(key: string) { | ||
this.#db.prepare("DELETE FROM key_value WHERE key = ?;").run(key); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.