Browse Source

Merge remote-tracking branch 'onedev/master' into Issue#11

master
buttercat1791 11 months ago
parent
commit
665a7df771
  1. 2
      src/app.css
  2. 21
      src/lib/components/Preview.svelte
  3. 15
      src/lib/parser.ts
  4. 14
      src/routes/[...catchall]/+page.svelte
  5. 24
      src/styles/publications.css

2
src/app.css

@ -74,7 +74,7 @@ @@ -74,7 +74,7 @@
@apply hover:bg-primary-100 dark:hover:bg-primary-800;
}
/* Heading */
/* Section headers */
h1.h-leather,
h2.h-leather,
h3.h-leather,

21
src/lib/components/Preview.svelte

@ -150,6 +150,27 @@ @@ -150,6 +150,27 @@
}
</script>
{#snippet sectionHeading(title: string, depth: number)}
{@const headingLevel = Math.min(depth + 1, 6)}
{@const className = $pharosInstance.isFloatingTitle(rootId) ? 'discrete' : 'h-leather'}
<svelte:element this={`h${headingLevel}`} class={className}>
{title}
</svelte:element>
{/snippet}
{#snippet contentParagraph(content: string, publicationType: string)}
{#if publicationType === 'novel'}
<P class='whitespace-normal' firstupper={isSectionStart}>
{@html content}
</P>
{:else}
<P class='whitespace-normal' firstupper={false}>
{@html content}
</P>
{/if}
{/snippet}
<!-- This component is recursively structured. The base case is single block of content. -->
<section
id={rootId}

15
src/lib/parser.ts

@ -273,6 +273,21 @@ export default class Pharos { @@ -273,6 +273,21 @@ export default class Pharos {
return block.convert();
}
/**
* Checks if the node with the given ID is a floating title (discrete header).
* @param id The ID of the node to check.
* @returns True if the node is a floating title, false otherwise.
*/
isFloatingTitle(id: string): boolean {
const normalizedId = this.normalizeId(id);
if (!normalizedId || !this.nodes.has(normalizedId)) {
return false;
}
const context = this.eventToContextMap.get(normalizedId);
return context === 'floating_title';
}
/**
* Updates the `content` field of a Nostr event in-place.
* @param dTag The d tag of the event to update.

14
src/routes/[...catchall]/+page.svelte

@ -0,0 +1,14 @@ @@ -0,0 +1,14 @@
<script lang="ts">
import { page } from '$app/stores';
import { goto } from '$app/navigation';
import { Button, P } from 'flowbite-svelte';
</script>
<div class="leather flex flex-col items-center justify-center min-h-screen text-center px-4">
<h1 class="h-leather mb-4">404 - Page Not Found</h1>
<P class="note-leather mb-6">The page you are looking for does not exist or has been moved.</P>
<div class="flex space-x-4">
<Button class="btn-leather !w-fit" on:click={() => goto('/')}>Return to Home</Button>
<Button class="btn-leather !w-fit" outline on:click={() => window.history.back()}>Go Back</Button>
</div>
</div>

24
src/styles/publications.css

@ -229,4 +229,28 @@ @@ -229,4 +229,28 @@
.audioblock .content audio {
@apply w-full;
}
/* Discrete headers */
h3.discrete,
h4.discrete,
h5.discrete,
h6.discrete {
@apply text-gray-800 dark:text-gray-300;
}
h3.discrete {
@apply text-2xl font-bold;
}
h4.discrete {
@apply text-xl font-bold;
}
h5.discrete {
@apply text-lg font-semibold;
}
h6.discrete {
@apply text-base font-semibold;
}
}
Loading…
Cancel
Save