chore: lint and fmt
This commit is contained in:
@@ -1,18 +1,18 @@
|
||||
import { watch } from 'vue'
|
||||
import { watch } from "vue"
|
||||
|
||||
import { backlinkEventBus } from '@/bus/backlinkEventBus'
|
||||
import { data } from '@/data/data'
|
||||
import { DataType } from '@/data/DataType.enum'
|
||||
import { useFile } from '@/hooks/useFile.hook'
|
||||
import { Backlink } from '@/modules/note/models/Backlink'
|
||||
import { BacklinkNote } from '@/modules/note/models/BacklinkNote'
|
||||
import { resolvePath } from '@/modules/repo/services/resolvePath'
|
||||
import { useUserRepoStore } from '@/modules/repo/store/userRepo.store'
|
||||
import { isExternalLink } from '@/utils/link'
|
||||
import { filenameToNoteTitle } from '@/utils/noteTitle'
|
||||
import { confirmMessage } from '@/utils/notif'
|
||||
import { backlinkEventBus } from "@/bus/backlinkEventBus"
|
||||
import { data } from "@/data/data"
|
||||
import { DataType } from "@/data/DataType.enum"
|
||||
import { useFile } from "@/hooks/useFile.hook"
|
||||
import { Backlink } from "@/modules/note/models/Backlink"
|
||||
import { BacklinkNote } from "@/modules/note/models/BacklinkNote"
|
||||
import { resolvePath } from "@/modules/repo/services/resolvePath"
|
||||
import { useUserRepoStore } from "@/modules/repo/store/userRepo.store"
|
||||
import { isExternalLink } from "@/utils/link"
|
||||
import { filenameToNoteTitle } from "@/utils/noteTitle"
|
||||
import { confirmMessage } from "@/utils/notif"
|
||||
|
||||
const isMarkdown = (filename?: string) => filename?.endsWith('.md') ?? false
|
||||
const isMarkdown = (filename?: string) => filename?.endsWith(".md") ?? false
|
||||
|
||||
export const useComputeBacklinks = () => {
|
||||
const store = useUserRepoStore()
|
||||
@@ -51,18 +51,18 @@ export const useComputeBacklinks = () => {
|
||||
}
|
||||
|
||||
const parser = new DOMParser()
|
||||
const htmlDoc = parser.parseFromString(note, 'text/html')
|
||||
const htmlDoc = parser.parseFromString(note, "text/html")
|
||||
|
||||
const links = htmlDoc.querySelectorAll('a')
|
||||
const links = htmlDoc.querySelectorAll("a")
|
||||
|
||||
for (const link of links) {
|
||||
const href = link.getAttribute('href') ?? ''
|
||||
const href = link.getAttribute("href") ?? ""
|
||||
|
||||
if (isExternalLink(href) || !isMarkdown(href)) {
|
||||
continue
|
||||
}
|
||||
|
||||
const path = resolvePath(file.path ?? '', href)
|
||||
const path = resolvePath(file.path ?? "", href)
|
||||
const backlinkFile = store.files.find((file) => file.path === path)
|
||||
|
||||
if (!backlinkFile?.sha || !backlinkFile?.path) {
|
||||
@@ -77,14 +77,14 @@ export const useComputeBacklinks = () => {
|
||||
|
||||
if (!notifiedForComputation) {
|
||||
notifiedForComputation = true
|
||||
confirmMessage('Updating backlinks...')
|
||||
confirmMessage("Updating backlinks...")
|
||||
}
|
||||
|
||||
backlinks.set(backlinkFile.sha, [
|
||||
...previousBacklinks,
|
||||
{
|
||||
sha: file.sha,
|
||||
title: filenameToNoteTitle(file.path ?? '')
|
||||
title: filenameToNoteTitle(file.path ?? "")
|
||||
}
|
||||
])
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user