Skip to content

Commit

Permalink
Customizable title and description
Browse files Browse the repository at this point in the history
  • Loading branch information
Loudbooks committed Dec 6, 2024
1 parent 83e3b52 commit a027f74
Show file tree
Hide file tree
Showing 6 changed files with 26 additions and 1,188 deletions.
3 changes: 2 additions & 1 deletion frontend/src/components/Toolbar.svelte
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
<script lang="ts">
import { onMount } from "svelte";
import { title } from "$lib/stores";
onMount(() => {
const toolbar = document.querySelector("toolbar") as HTMLElement;
Expand All @@ -22,7 +23,7 @@
</script>

<toolbar>
<button id="main" on:click={home}>PASTEBOOK</button>
<button id="main" on:click={home}>{$title.toUpperCase()}</button>
<buttons>
<button on:click={settings}>SETTINGS</button>
<button on:click={newPaste}>NEW</button>
Expand Down
3 changes: 3 additions & 0 deletions frontend/src/lib/stores.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,3 +15,6 @@ export const pasteURL = writable("");

export const wrap = writable(false);
export const expire = writable(86400000);

export const title = writable("");
export const description = writable("");
8 changes: 8 additions & 0 deletions frontend/src/routes/+layout.server.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
import type { PageServerLoad } from './$types';

export const load: PageServerLoad = async ({ params }) => {
return {
title: process.env.TITLE,
description: process.env.DESCRIPTION
};
};
10 changes: 9 additions & 1 deletion frontend/src/routes/+layout.svelte
Original file line number Diff line number Diff line change
@@ -1,5 +1,13 @@
<script>
<script lang="ts">
import Toolbar from "../components/Toolbar.svelte";
import { title, description } from "$lib/stores";
let { data }: { data: PageData } = $props();
const newTitle = data.title || 'PasteBook';
const newDescription = data.description || 'PasteBook is an aesthetic, effortless way to share your blocks of text, and respects your privacy by automatically deleting your pastes. ';
title.set(newTitle);
description.set(newDescription);
</script>

<main>
Expand Down
10 changes: 4 additions & 6 deletions frontend/src/routes/+page.svelte
Original file line number Diff line number Diff line change
@@ -1,13 +1,12 @@
<script>
<script lang="ts">
import Mode from "../components/Mode.svelte";
import { onMount } from "svelte";
import { title, description } from "$lib/stores";
export const commitHash = import.meta.env.VITE_COMMIT_HASH || 'unknown';
let width = 0;
onMount(() => {
width = window.innerWidth;
window.onresize = () => {
Expand All @@ -17,10 +16,9 @@
</script>

<about>
<h1>PasteBook</h1>
<h1>{$title}</h1>
<p class="description">
PasteBook is an aesthetic, effortless way to share your blocks of text, and
respects your privacy by automatically deleting your pastes.
{$description}
</p>

<p class="footer">
Expand Down
Loading

0 comments on commit a027f74

Please sign in to comment.