${escapeHtml(post.title)}
- +${escapeHtml(post.title)}
+${escapeHtml(post.content)}
-
+ ${escapeHtml(post.content)}
diff --git a/src/components/posts.ts b/src/components/posts.ts index 817d146..b1f4c11 100644 --- a/src/components/posts.ts +++ b/src/components/posts.ts @@ -1,4 +1,5 @@ import type { BlogPost } from '../types.js' +import { putRecord } from '../lib/auth.js' function formatDate(dateStr: string): string { const date = new Date(dateStr) @@ -38,17 +39,77 @@ export function mountPostList(container: HTMLElement, posts: BlogPost[]): void { container.innerHTML = `
Post not found
' } diff --git a/src/styles/main.css b/src/styles/main.css index 9027347..311e1d1 100644 --- a/src/styles/main.css +++ b/src/styles/main.css @@ -288,6 +288,97 @@ body { color: #333; } +.edit-btn { + display: inline-flex; + align-items: center; + justify-content: center; + padding: 4px 8px; + background: #28a745; + color: #fff; + border: none; + border-radius: 4px; + text-decoration: none; + font-family: monospace; + font-size: 12px; + cursor: pointer; +} + +.edit-btn:hover { + background: #218838; +} + +/* Edit Form */ +.edit-form-container { + padding: 20px 0; +} + +.edit-form-container h3 { + font-size: 18px; + margin-bottom: 16px; +} + +.edit-form { + display: flex; + flex-direction: column; + gap: 12px; +} + +.edit-form-title { + padding: 10px 12px; + border: 1px solid #ddd; + border-radius: 6px; + font-size: 16px; +} + +.edit-form-body { + padding: 10px 12px; + border: 1px solid #ddd; + border-radius: 6px; + font-size: 14px; + resize: vertical; + min-height: 200px; + font-family: inherit; +} + +.edit-form-footer { + display: flex; + justify-content: flex-end; + gap: 8px; +} + +.edit-cancel-btn { + padding: 10px 24px; + background: #6c757d; + color: #fff; + border: none; + border-radius: 6px; + font-size: 14px; + cursor: pointer; +} + +.edit-cancel-btn:hover { + background: #5a6268; +} + +.edit-submit-btn { + padding: 10px 24px; + background: #28a745; + color: #fff; + border: none; + border-radius: 6px; + font-size: 14px; + cursor: pointer; +} + +.edit-submit-btn:hover { + background: #218838; +} + +.edit-submit-btn:disabled { + background: #ccc; + cursor: not-allowed; +} + .post-content { font-size: 16px; line-height: 1.8; @@ -549,6 +640,12 @@ body { background: #333; color: #e0e0e0; } + .edit-form-title, + .edit-form-body { + background: #1a1a1a; + border-color: #333; + color: #e0e0e0; + } .tab:hover { background: #333; }