✨ (path) create a resolve path service to manage …
resolve path like ../..
This commit is contained in:
@@ -3,11 +3,11 @@ import markdownItClass from '@toycode/markdown-it-class'
|
||||
|
||||
const md = new MarkdownIt().use(markdownItClass, {
|
||||
h1: ['title', 'is-1'],
|
||||
h2: ['subtitle', 'is-2'],
|
||||
h3: ['subtitle', 'is-3'],
|
||||
h4: ['subtitle', 'is-4'],
|
||||
h5: ['subtitle', 'is-5'],
|
||||
h6: ['subtitle', 'is-6'],
|
||||
h2: ['title', 'is-2'],
|
||||
h3: ['title', 'is-3'],
|
||||
h4: ['title', 'is-4'],
|
||||
h5: ['title', 'is-5'],
|
||||
h6: ['title', 'is-6'],
|
||||
table: ['table', 'is-striped', 'is-hoverable', 'is-fullwidth']
|
||||
})
|
||||
|
||||
|
||||
@@ -15,13 +15,7 @@ import { useOverlay } from '@/hooks/useOverlay.hook'
|
||||
import { useQueryStackedNotes } from '@/hooks/useQueryStackedNotes.hook'
|
||||
import { useRepo } from '@/hooks/useRepo.hook'
|
||||
import { useRouter } from 'vue-router'
|
||||
|
||||
const sanitizePath = (path: string) => {
|
||||
if (path.startsWith('./')) {
|
||||
return decodeURIComponent(path.replace('./', ''))
|
||||
}
|
||||
return decodeURIComponent(path)
|
||||
}
|
||||
import { resolvePath } from '@/modules/repo/services/resolvePath'
|
||||
|
||||
export const useNote = (
|
||||
containerClass: string,
|
||||
@@ -59,19 +53,9 @@ export const useNote = (
|
||||
({ path, currentNoteSHA }) => {
|
||||
const currentFile = tree.value.find((file) => file.sha === currentNoteSHA)
|
||||
|
||||
const absolutePathArray = currentFile?.path?.split('/') ?? []
|
||||
absolutePathArray?.pop()
|
||||
const absolutePath = absolutePathArray.join('/')
|
||||
const finalPath = resolvePath(currentFile?.path ?? '', path)
|
||||
|
||||
const finalPath = absolutePath
|
||||
? `${sanitizePath(absolutePath)}/${sanitizePath(path)}`
|
||||
: sanitizePath(path)
|
||||
|
||||
const relativePath = sanitizePath(path)
|
||||
|
||||
const file = tree.value.find(
|
||||
(file) => file.path === finalPath || file.path === relativePath
|
||||
)
|
||||
const file = tree.value.find((file) => file.path === finalPath)
|
||||
|
||||
if (!file?.sha || stackedNotes.value.includes(file.sha)) {
|
||||
scrollToFocusedNote(file?.sha)
|
||||
|
||||
Reference in New Issue
Block a user