2
0

refact web

This commit is contained in:
2026-03-25 05:58:41 +09:00
parent 9c47732511
commit 3103090c33
16 changed files with 1241 additions and 1365 deletions

View File

@@ -1,5 +1,6 @@
import { renderMarkdown } from '../lib/markdown'
import type { Post } from '../types'
import { escapeHtml, escapeAttr, formatDateJa } from '../lib/util'
// Note post has extra fields for member content
interface NotePost extends Post {
@@ -42,12 +43,10 @@ export function renderNoteListPage(posts: NotePost[], handle: string): string {
export function renderNoteDetailPage(
post: NotePost,
_handle: string,
localOnly: boolean
isOwner: boolean
): string {
const rkey = post.uri.split('/').pop() || ''
const date = new Date(post.value.publishedAt).toLocaleDateString('ja-JP', {
year: 'numeric', month: '2-digit', day: '2-digit'
})
const date = formatDateJa(post.value.publishedAt)
const freeText = post.value.content?.text || ''
const memberText = post.value.member?.text || ''
const bonusText = post.value.member?.bonus || ''
@@ -59,7 +58,7 @@ export function renderNoteDetailPage(
let html = ''
// Action buttons at top
if (localOnly) {
if (isOwner) {
html += `
<div class="note-actions">
<button type="button" class="note-copy-btn" id="note-copy-title">Copy Title</button>
@@ -103,7 +102,7 @@ export function renderNoteDetailPage(
html += `</div>`
// Edit form (below content)
if (localOnly) {
if (isOwner) {
html += `
<div class="note-edit" id="note-edit-form" style="display:none">
<input type="text" id="note-edit-title" class="note-edit-input" value="${escapeAttr(post.value.title)}" placeholder="Title">
@@ -223,10 +222,3 @@ export function setupNoteDetail(
})
}
function escapeHtml(s: string): string {
return s.replace(/&/g, '&amp;').replace(/</g, '&lt;').replace(/>/g, '&gt;').replace(/"/g, '&quot;')
}
function escapeAttr(s: string): string {
return s.replace(/&/g, '&amp;').replace(/"/g, '&quot;').replace(/</g, '&lt;').replace(/>/g, '&gt;')
}