(folders) folders can start with a _

This commit is contained in:
2021-04-05 10:34:49 +02:00
parent 8370c678b9
commit 6347edd82e
3 changed files with 13 additions and 8 deletions

View File

@@ -1,22 +1,27 @@
import { useUserRepoStore } from '@/modules/repo/store/userRepo.store'
import { computed } from 'vue'
export const useFolderNotes = (folder: string) => {
export const useFolderNotes = (folders: string[]) => {
const store = useUserRepoStore()
const fleetingNotes = computed(() =>
store.files.filter(
(file) => file.path?.startsWith(folder) && file.path?.endsWith('.md')
(file) =>
folders.some((folder) => file.path?.startsWith(folder)) &&
file.path?.endsWith('.md')
)
)
const content = computed(() =>
fleetingNotes.value?.length > 0
? fleetingNotes.value
.map(
(note) =>
`- [${note.path?.replace(`${folder}/`, '')}](${note.path})`
)
.map((note) => {
const firstFolder = note.path?.split('/').shift()
return `- [${note.path?.replace(`${firstFolder}/`, '')}](${
note.path
})`
})
.join('\n')
: ''
)