Something went wrong. Try again.
🌿 Collaborative wiki on ATProto forked from juprodh.me/lichen.wiki
Something went wrong. Try again.
12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879import { escapeHtml } from "../lib/html.ts";import { t } from "../lib/i18n/index.ts";import { noteUrl } from "../lib/urls.ts";import type { WikiIdentity } from "../lib/wiki-identity.ts";import { type LayoutOptions, layout } from "./layout.ts";import { dangerSmallButtonClass, THEME } from "./theme/index.ts";
export function notePage( wiki: WikiIdentity, noteTitle: string, renderedHtml: string, options?: LayoutOptions, wikiLanguage?: string,): string { const langAttr = wikiLanguage ? ` lang="${escapeHtml(wikiLanguage)}"` : ""; const content = ` <article class="prose max-w-none"${langAttr}> ${renderedHtml} </article> `; return layout(noteTitle, content, { ...options, wikiName: wiki.name, wikiSlug: wiki.slug, ownerHandle: wiki.handle, pageTitle: noteTitle, enableSearchShortcut: true, });}
// Shown when a note row exists but its current_note (content) doesn't — a// half-synced "ghost". Instead of a dead 404, surface a notice and, for editors,// a delete affordance so the orphan can be cleaned up. Editing is blocked// elsewhere so a blank save can't clobber content that may still be syncing.export function missingNotePage( wiki: WikiIdentity, noteSlug: string, noteTitle: string, canDelete: boolean, options?: LayoutOptions,): string { const locale = options?.locale ?? "en"; const msg = t(locale);
const deleteHtml = canDelete ? ` <div class="mt-4"> <button type="button" class="${dangerSmallButtonClass} cursor-pointer" data-action="confirm-then-submit" data-form="delete-note-form" data-confirm="${escapeHtml(msg.editor.confirmDeleteNote)}" >${escapeHtml(msg.editor.deleteNote)}</button> <form id="delete-note-form" method="POST" action="${noteUrl(wiki.handle, wiki.slug, noteSlug)}/delete" class="hidden"></form> </div>` : "";
const content = ` <div class="max-w-2xl"> <h1 class="text-2xl font-bold ${THEME.text} mb-4">${escapeHtml(noteTitle)}</h1> <div class="p-4 ${THEME.errorBg} border ${THEME.errorBorder} rounded"> <p class="${THEME.text} font-medium">${escapeHtml(msg.error.noteUnavailableHeading)}</p> <p class="${THEME.textMuted} text-sm mt-1">${escapeHtml(msg.error.noteUnavailableBody)}</p> ${deleteHtml} </div> </div> `;
return layout(noteTitle, content, { ...options, wikiName: wiki.name, wikiSlug: wiki.slug, ownerHandle: wiki.handle, pageTitle: noteTitle, noindex: true, });}