compute note backlinks

This commit is contained in:
Julien Calixte
2021-06-06 09:57:17 +02:00
parent 203db4c00a
commit 4f13c18573
11 changed files with 122 additions and 24 deletions

View File

@@ -1,9 +1,8 @@
import { noteEventBus } from '@/bus/noteEventBus'
import { useUserRepoStore } from '@/modules/repo/store/userRepo.store'
import { isExternalLink } from '@/utils/link'
import { onUnmounted } from '@vue/runtime-core'
const LINKS = ['http://', 'https://']
export const useLinks = (className: string, sha?: string) => {
const store = useUserRepoStore()
@@ -16,7 +15,7 @@ export const useLinks = (className: string, sha?: string) => {
return
}
if (LINKS.some((link) => href.startsWith(link))) {
if (isExternalLink(href)) {
window.open(href, '_blank')
return
}
@@ -50,9 +49,7 @@ export const useLinks = (className: string, sha?: string) => {
return
}
const isExternalLink = LINKS.some((link) => href.startsWith(link))
if (isExternalLink) {
if (isExternalLink(href)) {
element.classList.add('external-link')
}
})