✨ (fleeting notes) init fleeting notes
This commit is contained in:
24
src/modules/note/hooks/useFleetingNotes.ts
Normal file
24
src/modules/note/hooks/useFleetingNotes.ts
Normal file
@@ -0,0 +1,24 @@
|
||||
import { useRepo } from '@/hooks/useRepo.hook'
|
||||
import { computed, Ref } from 'vue'
|
||||
|
||||
const FLEETING_NOTES_FOLDER = 'fleeting-notes'
|
||||
|
||||
export const useFleetingNotes = (owner: Ref<string>, repo: Ref<string>) => {
|
||||
const { tree } = useRepo(owner, repo)
|
||||
|
||||
const fleetingNotes = computed(() =>
|
||||
tree.value.filter((file) => file.path?.startsWith(FLEETING_NOTES_FOLDER))
|
||||
)
|
||||
|
||||
const content = computed(() =>
|
||||
fleetingNotes.value.length
|
||||
? fleetingNotes.value
|
||||
.map((note) => `- [${note.path}](${note.path})`)
|
||||
.join('\n')
|
||||
: ''
|
||||
)
|
||||
|
||||
return {
|
||||
content
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user