Library sidebar: folders, pinned-top, per-page menus, and an all-pages view
- Page.isFolder (migration 027): folders are content-less pages reusing parentId; folder delete reparents children one level up - Sidebar: Pages group becomes Library; Pinned at top; folder tree; page menu (duplicate/pin/copy link/rename/move/trash); folder menu - /pages index: filterable Library table (all/recent/pinned/untagged) with folder path + last edit (components/library-index.tsx) - Docs: API.md isFolder + folder-delete semantics
This commit is contained in:
@@ -13,9 +13,10 @@ import { Popover, PopoverContent, PopoverTrigger } from '@/components/ui/popover
|
||||
import { cn } from '@/lib/utils'
|
||||
import { PageAutosave, PageConflictError, type PageSaveState } from '@/lib/page-autosave'
|
||||
import {
|
||||
PAGES_CHANGED, collectionEmbedMarkdown, descendantPageIds, nextUntitledTitle,
|
||||
PAGES_CHANGED, collectionEmbedMarkdown, descendantPageIds,
|
||||
notifyActivePage, notifyPagesChanged, pageLinkMarkdown, type PageSummary,
|
||||
} from '@/lib/pages'
|
||||
import { LibraryIndex } from '@/components/library-index'
|
||||
import { PageEditor, type PageEditorHandle } from '@/components/page-editor'
|
||||
import { type PageEmbed, type LinkedBookmark } from '@/components/page-embed-card'
|
||||
import { LinkPreviewCard } from '@/components/link-preview-card'
|
||||
@@ -218,16 +219,6 @@ export function PagesClient({ initialId }: { initialId: string | null }) {
|
||||
return res
|
||||
}
|
||||
|
||||
const createPage = async () => {
|
||||
if (activePage.current && !await autosave.flush(activePage.current)) return
|
||||
const res = await fetch('/api/pages', { method: 'POST', headers: { 'Content-Type': 'application/json' }, body: JSON.stringify({ title: nextUntitledTitle(pages.map((p) => p.title)) }) })
|
||||
if (!res.ok) { toast.error('Could not create page'); return }
|
||||
const p = await res.json()
|
||||
await loadPages()
|
||||
notify()
|
||||
select(p.id)
|
||||
}
|
||||
|
||||
const onContentChange = (v: string) => {
|
||||
if (!page || page.id !== activeId) return
|
||||
setContent(v)
|
||||
@@ -468,12 +459,7 @@ export function PagesClient({ initialId }: { initialId: string | null }) {
|
||||
return (
|
||||
<div className="flex h-full flex-col">
|
||||
{!page || page.id !== activeId ? (
|
||||
<div className="flex flex-1 flex-col items-center justify-center gap-3 p-10 text-center">
|
||||
<FileText className="h-10 w-10 text-muted-foreground" />
|
||||
<h2 className="font-display text-xl font-semibold">{pages.length ? 'Select a page' : 'No pages yet'}</h2>
|
||||
<p className="max-w-sm text-sm text-muted-foreground">Pages are Markdown notes that collect links into a workspace. A bookmark can live on many pages.</p>
|
||||
<Button onClick={createPage}><Plus className="mr-1 h-4 w-4" />Create a page</Button>
|
||||
</div>
|
||||
<LibraryIndex />
|
||||
) : (
|
||||
<div className="mx-auto w-full max-w-4xl flex-1 overflow-y-auto px-3 py-4 sm:px-6 sm:py-8">
|
||||
<div className="mb-6 flex flex-wrap items-center gap-2">
|
||||
|
||||
Reference in New Issue
Block a user