fix post generate

This commit is contained in:
2026-01-15 19:46:01 +09:00
parent 162072d980
commit 9980e596ca
13 changed files with 1834 additions and 120 deletions

View File

@@ -1,5 +1,6 @@
import type { BlogPost } from '../types.js'
import { putRecord } from '../lib/auth.js'
import { renderMarkdown } from '../lib/markdown.js'
function formatDate(dateStr: string): string {
const date = new Date(dateStr)
@@ -28,7 +29,7 @@ export function mountPostList(container: HTMLElement, posts: BlogPost[]): void {
const rkey = post.uri.split('/').pop()
return `
<li class="post-item">
<a href="?rkey=${rkey}" class="post-link">
<a href="/post/${rkey}" class="post-link">
<span class="post-title">${escapeHtml(post.title)}</span>
<span class="post-date">${formatDate(post.createdAt)}</span>
</a>
@@ -41,7 +42,7 @@ export function mountPostList(container: HTMLElement, posts: BlogPost[]): void {
export function mountPostDetail(container: HTMLElement, post: BlogPost, handle: string, collection: string, canEdit: boolean = false): void {
const rkey = post.uri.split('/').pop() || ''
const jsonUrl = `?mode=browser&handle=${handle}&collection=${encodeURIComponent(collection)}&rkey=${rkey}`
const jsonUrl = `/at/${handle}/${collection}/${rkey}`
const editBtn = canEdit ? `<button class="edit-btn" id="edit-btn">edit</button>` : ''
@@ -55,7 +56,7 @@ export function mountPostDetail(container: HTMLElement, post: BlogPost, handle:
${editBtn}
</div>
</header>
<div class="post-content" id="post-content">${escapeHtml(post.content)}</div>
<div class="post-content" id="post-content">${renderMarkdown(post.content)}</div>
</article>
<div class="edit-form-container" id="edit-form-container" style="display: none;">