Skip to content

Commit

Permalink
fix slug and removed click to edit btn (#234)
Browse files Browse the repository at this point in the history
Fixes #211
  • Loading branch information
harshmangalam authored Nov 9, 2024
1 parent 0a42e63 commit ca3a9f7
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 22 deletions.
6 changes: 0 additions & 6 deletions src/lib/components/editors/CompositeMarkdownEditor.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -56,12 +56,6 @@
<button class="variant-filled badge" onclick={() => (markdownMode = !markdownMode)}
>{markdownMode ? 'Switch to Rich Text' : 'Switch to Markdown'}</button
>

{#if !markdownMode}
<button class="variant-filled badge" onclick={() => richEditorEl.focus()}
>Click to Edit!</button
>
{/if}
</div>
{#if !markdownMode}
<RichMarkdownEditor bind:this={richEditorEl} bind:content={contentProxy.value} />
Expand Down
9 changes: 1 addition & 8 deletions src/routes/(app)/[username]/[slug]/+page.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -79,10 +79,6 @@
{#if !editingState.editing}
{data.page.display_name}
{:else}
<button
class="variant-filled badge absolute right-[-4em] top-[-2em] z-10"
onclick={() => displayNameEditorEl.focus()}>Click to Edit!</button
>
<InlineTextEditor
bind:this={displayNameEditorEl}
bind:content={editingState.page.display_name as string}
Expand All @@ -109,14 +105,11 @@
<span class="basis-40">Page Slug</span>
<div class="flex flex-grow flex-col">
<input
class="input basis-auto"
class="input border-none bg-transparent"
placeholder="slug"
disabled={!data.profileMatchesUserSession}
bind:value={editingState.page.slug}
/>
<div class="ml-2 mt-1 text-sm">
<pre class="inline">&nbsp;{slugifiedSlug}</pre>
</div>
</div>
</label>
<div class="flex justify-end text-sm">
Expand Down
13 changes: 5 additions & 8 deletions src/routes/(app)/[username]/new/+page.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,10 @@
function handleSubmit(e: SubmitEvent) {
page.slug = slugifiedSlug;
}
$effect(() => {
page.slug = slugify(page.display_name || 'untitled', { strict: true, lower: true });
});
</script>

<svelte:head>
Expand All @@ -57,21 +61,14 @@
<div class="card m-4 mt-8 flex w-full max-w-[700px] flex-col gap-4 p-8 text-xl">
<h1 class="relative my-3 text-center text-4xl">
<div>
<button
class="variant-filled badge absolute right-[-4em] top-[-1em] z-10"
onclick={() => displayNameEditorEl.focus()}>Click to Edit!</button
>
<InlineTextEditor bind:this={displayNameEditorEl} bind:content={page.display_name} />
</div>
</h1>

<label class="flex flex-row items-center gap-2">
<span class="basis-40">Page Slug</span>
<div class="flex flex-grow flex-col">
<input class="input" placeholder="slug" bind:value={page.slug} />
<div class="ml-2 mt-1 text-sm">
<pre class="inline">&nbsp;{slugifiedSlug}</pre>
</div>
<input class="border-none bg-transparent" placeholder="slug" bind:value={page.slug} />
</div>
</label>
<div class="flex justify-end text-sm">
Expand Down

0 comments on commit ca3a9f7

Please sign in to comment.