feat: parse hashtags from content instead of dedicated tag input
Tags are now automatically extracted from #hashtags in content text. Removed TagInput from entry editing, keeping it only in FilterBar. Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
This commit is contained in:
@@ -8,6 +8,7 @@ import {
|
||||
deleteImage as deleteImageFile
|
||||
} from '$lib/server/images/storage';
|
||||
import { generateThumbnail } from '$lib/server/images/thumbnails';
|
||||
import { parseHashtags } from '$lib/utils/parseHashtags';
|
||||
|
||||
export const load: PageServerLoad = async ({ url }) => {
|
||||
const showCompleted = url.searchParams.get('showCompleted') === 'true';
|
||||
@@ -53,6 +54,12 @@ export const actions: Actions = {
|
||||
type: type || 'thought'
|
||||
});
|
||||
|
||||
// Parse hashtags from content and save them
|
||||
const hashtags = parseHashtags(content);
|
||||
if (hashtags.length > 0) {
|
||||
tagRepository.updateEntryTags(entry.id, hashtags);
|
||||
}
|
||||
|
||||
return { success: true, entryId: entry.id };
|
||||
},
|
||||
|
||||
@@ -77,6 +84,7 @@ export const actions: Actions = {
|
||||
updates.title = title.toString().trim() || null;
|
||||
}
|
||||
|
||||
let contentChanged = false;
|
||||
const content = formData.get('content');
|
||||
if (content !== null) {
|
||||
const contentStr = content.toString().trim();
|
||||
@@ -84,6 +92,7 @@ export const actions: Actions = {
|
||||
return fail(400, { error: 'Content cannot be empty' });
|
||||
}
|
||||
updates.content = contentStr;
|
||||
contentChanged = true;
|
||||
}
|
||||
|
||||
const type = formData.get('type');
|
||||
@@ -106,6 +115,12 @@ export const actions: Actions = {
|
||||
|
||||
entryRepository.update(id, updates);
|
||||
|
||||
// Re-parse hashtags if content changed
|
||||
if (contentChanged && updates.content) {
|
||||
const hashtags = parseHashtags(updates.content as string);
|
||||
tagRepository.updateEntryTags(id, hashtags);
|
||||
}
|
||||
|
||||
return { success: true };
|
||||
},
|
||||
|
||||
|
||||
Reference in New Issue
Block a user