(fleeting notes) init fleeting notes

This commit is contained in:
2021-03-20 22:00:37 +01:00
parent a8cc196508
commit 11d25e25af
9 changed files with 112 additions and 37 deletions

View 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
}
}