fixed issues with app
This commit is contained in:
@@ -19,6 +19,46 @@ const sortValidator = v.union(
|
||||
v.literal('title')
|
||||
);
|
||||
|
||||
const markdownGuideBody = `# Markdown basics
|
||||
|
||||
Welcome to Journaley. This starter entry shows the markdown features you can use while journaling.
|
||||
|
||||
## Formatting
|
||||
|
||||
Use **bold** for emphasis, _italic_ for gentle notes, and \`inline code\` for short snippets.
|
||||
|
||||
## Lists
|
||||
|
||||
- Capture loose thoughts
|
||||
- Group ideas by theme
|
||||
- Keep reflections scannable
|
||||
|
||||
1. Start with what happened
|
||||
2. Add how it felt
|
||||
3. Close with one next step
|
||||
|
||||
## Tasks
|
||||
|
||||
- [ ] Try writing one short entry
|
||||
- [ ] Add a few tags
|
||||
- [ ] Search for this guide later
|
||||
|
||||
## Quotes
|
||||
|
||||
> A small daily note is still a thread you can return to.
|
||||
|
||||
## Links and tables
|
||||
|
||||
[Markdown guide](https://www.markdownguide.org/basic-syntax/)
|
||||
|
||||
| Syntax | Result |
|
||||
| --- | --- |
|
||||
| **bold** | bold text |
|
||||
| _italic_ | italic text |
|
||||
| # Heading | section title |
|
||||
|
||||
You can edit or delete this entry whenever you want.`;
|
||||
|
||||
type EntryWithTags = Doc<'entries'> & {
|
||||
tags: Doc<'tags'>[];
|
||||
};
|
||||
@@ -258,6 +298,65 @@ export const create = mutation({
|
||||
}
|
||||
});
|
||||
|
||||
export const ensureMarkdownGuideEntry = mutation({
|
||||
args: {},
|
||||
handler: async (ctx) => {
|
||||
const owner = await requireOwner(ctx);
|
||||
const existingState = await ctx.db
|
||||
.query('userState')
|
||||
.withIndex('by_owner', (q) => q.eq('owner', owner))
|
||||
.unique();
|
||||
|
||||
if (existingState?.markdownGuideSeeded) {
|
||||
return existingState.markdownGuideEntryId ?? null;
|
||||
}
|
||||
|
||||
const tags = await ensureTags(ctx, owner, ['markdown', 'guide']);
|
||||
const now = Date.now();
|
||||
const today = new Date().toISOString().slice(0, 10);
|
||||
const plainText = markdownToPlainText(markdownGuideBody);
|
||||
const entryId = await ctx.db.insert('entries', {
|
||||
owner,
|
||||
title: 'Markdown basics',
|
||||
body: markdownGuideBody,
|
||||
plainText,
|
||||
searchText: buildSearchText({
|
||||
title: 'Markdown basics',
|
||||
body: markdownGuideBody,
|
||||
mood: 'neutral',
|
||||
tagNames: tags.map((tag) => tag.name)
|
||||
}),
|
||||
mood: 'neutral',
|
||||
entryDate: today,
|
||||
tagNames: tags.map((tag) => tag.name),
|
||||
tagSlugs: tags.map((tag) => tag.slug),
|
||||
pinned: true,
|
||||
archived: false,
|
||||
createdAt: now,
|
||||
updatedAt: now
|
||||
});
|
||||
|
||||
await applyEntryTags(ctx, owner, entryId, tags);
|
||||
|
||||
if (existingState) {
|
||||
await ctx.db.patch(existingState._id, {
|
||||
markdownGuideSeeded: true,
|
||||
markdownGuideEntryId: entryId,
|
||||
updatedAt: now
|
||||
});
|
||||
} else {
|
||||
await ctx.db.insert('userState', {
|
||||
owner,
|
||||
markdownGuideSeeded: true,
|
||||
markdownGuideEntryId: entryId,
|
||||
updatedAt: now
|
||||
});
|
||||
}
|
||||
|
||||
return entryId;
|
||||
}
|
||||
});
|
||||
|
||||
export const update = mutation({
|
||||
args: {
|
||||
entryId: v.id('entries'),
|
||||
|
||||
Reference in New Issue
Block a user