fix: stop seeding title during property init
This commit is contained in:
19
src/utils/initializeNoteProperties.test.ts
Normal file
19
src/utils/initializeNoteProperties.test.ts
Normal file
@@ -0,0 +1,19 @@
|
||||
import { describe, expect, it, vi } from 'vitest'
|
||||
|
||||
import { initializeNoteProperties } from './initializeNoteProperties'
|
||||
|
||||
describe('initializeNoteProperties', () => {
|
||||
it('seeds only the Note type without creating a title field', async () => {
|
||||
const updateFrontmatter = vi.fn().mockResolvedValue(undefined)
|
||||
|
||||
await initializeNoteProperties(updateFrontmatter, '/vault/plain-note.md')
|
||||
|
||||
expect(updateFrontmatter).toHaveBeenCalledTimes(1)
|
||||
expect(updateFrontmatter).toHaveBeenCalledWith(
|
||||
'/vault/plain-note.md',
|
||||
'type',
|
||||
'Note',
|
||||
{ silent: true },
|
||||
)
|
||||
})
|
||||
})
|
||||
13
src/utils/initializeNoteProperties.ts
Normal file
13
src/utils/initializeNoteProperties.ts
Normal file
@@ -0,0 +1,13 @@
|
||||
export type UpdateFrontmatter = (
|
||||
path: string,
|
||||
key: string,
|
||||
value: string,
|
||||
options?: { silent?: boolean },
|
||||
) => Promise<void>
|
||||
|
||||
export async function initializeNoteProperties(
|
||||
updateFrontmatter: UpdateFrontmatter,
|
||||
path: string,
|
||||
): Promise<void> {
|
||||
await updateFrontmatter(path, 'type', 'Note', { silent: true })
|
||||
}
|
||||
Reference in New Issue
Block a user