commit ce6ba992ffea6c06818501eca66e7cc930f1c493 Author: DuroCodes Date: Sun Aug 18 21:03:46 2024 -0400 feat: initial commit diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..16d54bb --- /dev/null +++ b/.gitignore @@ -0,0 +1,24 @@ +# build output +dist/ +# generated types +.astro/ + +# dependencies +node_modules/ + +# logs +npm-debug.log* +yarn-debug.log* +yarn-error.log* +pnpm-debug.log* + + +# environment variables +.env +.env.production + +# macOS-specific files +.DS_Store + +# jetbrains setting folder +.idea/ diff --git a/.vscode/extensions.json b/.vscode/extensions.json new file mode 100644 index 0000000..22a1505 --- /dev/null +++ b/.vscode/extensions.json @@ -0,0 +1,4 @@ +{ + "recommendations": ["astro-build.astro-vscode"], + "unwantedRecommendations": [] +} diff --git a/.vscode/launch.json b/.vscode/launch.json new file mode 100644 index 0000000..d642209 --- /dev/null +++ b/.vscode/launch.json @@ -0,0 +1,11 @@ +{ + "version": "0.2.0", + "configurations": [ + { + "command": "./node_modules/.bin/astro dev", + "name": "Development server", + "request": "launch", + "type": "node-terminal" + } + ] +} diff --git a/README.md b/README.md new file mode 100644 index 0000000..9b1454d --- /dev/null +++ b/README.md @@ -0,0 +1,3 @@ +# sponge bin + +a pastebin for code snippets; rendered with shiki diff --git a/astro.config.mjs b/astro.config.mjs new file mode 100644 index 0000000..e84c84f --- /dev/null +++ b/astro.config.mjs @@ -0,0 +1,9 @@ +import { defineConfig } from 'astro/config'; +import tailwind from "@astrojs/tailwind"; +import preact from "@astrojs/preact"; + +// https://astro.build/config +export default defineConfig({ + integrations: [tailwind(), preact()], + output: 'server' +}); diff --git a/bun.lockb b/bun.lockb new file mode 100755 index 0000000..f7cf86e Binary files /dev/null and b/bun.lockb differ diff --git a/package.json b/package.json new file mode 100644 index 0000000..5a41a9b --- /dev/null +++ b/package.json @@ -0,0 +1,26 @@ +{ + "name": "pastebin", + "version": "0.0.1", + "dependencies": { + "@astrojs/check": "^0.9.2", + "@astrojs/preact": "^3.5.1", + "@astrojs/tailwind": "^5.1.0", + "@nanostores/preact": "^0.5.2", + "astro": "^4.14.2", + "nanostores": "^0.11.2", + "preact": "^10.23.2", + "tailwindcss": "^3.4.10", + "typescript": "^5.5.4" + }, + "scripts": { + "dev": "astro dev", + "start": "astro dev", + "build": "astro check && astro build", + "preview": "astro preview", + "astro": "astro" + }, + "type": "module", + "devDependencies": { + "prettier-plugin-astro": "^0.14.1" + } +} diff --git a/public/favicon.svg b/public/favicon.svg new file mode 100644 index 0000000..e328549 --- /dev/null +++ b/public/favicon.svg @@ -0,0 +1,120 @@ + + + + diff --git a/public/sponge.png b/public/sponge.png new file mode 100644 index 0000000..4e72b8e Binary files /dev/null and b/public/sponge.png differ diff --git a/src/components/CodeBlock.tsx b/src/components/CodeBlock.tsx new file mode 100644 index 0000000..12d41e6 --- /dev/null +++ b/src/components/CodeBlock.tsx @@ -0,0 +1,47 @@ +import { useStore } from "@nanostores/preact"; +import { + $codeStore, + $langStore, + $themeStore, + highlighter, +} from "../utils/theme"; + +export default function CodeBlock() { + const lang = useStore($langStore); + const theme = useStore($themeStore); + const code = useStore($codeStore); + + const handleCodeChange = (event: Event) => { + const newCode = (event.target as HTMLTextAreaElement).value; + $codeStore.set(newCode); + }; + + const __html = highlighter.codeToHtml($codeStore.get(), { + lang, + theme, + }); + + return ( +
+