fix: fix overflow for pages by making body background color the theme color; change default code to 'Hello World' rather than 'No Code Provided'

This commit is contained in:
DuroCodes
2024-08-19 08:35:17 -04:00
parent 42dcf49f85
commit b59f65f53d
3 changed files with 13 additions and 6 deletions

View File

@@ -31,7 +31,7 @@ export default function CodeBlock() {
spellCheck={false}
/>
<div
class="ml-4 overflow-x-hidden shiki pointer-events-none"
class="ml-4 shiki pointer-events-none"
dangerouslySetInnerHTML={{ __html }}
/>
</div>

View File

@@ -12,7 +12,7 @@ export default function SaveButton() {
const save = async () => {
setSaving(true);
const result = await unwrapOr(encode(code), "");
const result = await unwrapOr(encode(code), "Hello World");
const url = `${window.location.origin}/?l=${$langStore.get()}&t=${$themeStore.get()}&c=${result}`;
navigator.clipboard.writeText(url);

View File

@@ -2,19 +2,26 @@
import "../styles/global.css";
import { type BundledTheme } from "shiki";
import Editor from "../components/Editor";
import { $codeStore, $langStore, $themeStore, parseLang } from "../utils/theme";
import {
$codeStore,
$langStore,
$themeStore,
$themeColorsStore,
parseLang,
} from "../utils/theme";
import { decode } from "../utils/encode";
import { unwrapOr } from "../utils/result";
const langParam = Astro.url.searchParams.get("l") ?? "txt";
const themeParam = Astro.url.searchParams.get("t") ?? "github-dark-default";
const codeParam =
Astro.url.searchParams.get("c") ??
"H4sIAAAAAAAAE_PLV3DOT0lVCCjKL8tMSU0BAGFoYswQAAAA";
"H4sIAAAAAAAAE_NIzcnJVwjPL8pJAQBWsRdKCwAAAA";
const code = await unwrapOr(
decode(codeParam),
"H4sIAAAAAAAAE_PLV3DOT0lVCCjKL8tMSU0BAGFoYswQAAAA",
"H4sIAAAAAAAAE_NIzcnJVwjPL8pJAQBWsRdKCwAAAA",
);
$codeStore.set(code);
@@ -42,7 +49,7 @@ $themeStore.set(themeParam as BundledTheme);
<meta property="og:url" content={Astro.url} />
</head>
<body>
<body style={{ backgroundColor: $themeColorsStore.get().background }}>
<Editor client:load />
</body>
</html>