(backlinks) implement backlinks in notes

This commit is contained in:
Julien Calixte
2021-06-06 11:11:15 +02:00
parent c6dec8769f
commit bff90e6ef5
7 changed files with 117 additions and 103 deletions

View File

@@ -58,7 +58,6 @@ import { useMarkdown } from '@/hooks/useMarkdown.hook'
import { useLinks } from '@/hooks/useLinks.hook'
import { useUserRepoStore } from '@/modules/repo/store/userRepo.store'
import { useUserSettings } from '@/modules/user/hooks/useUserSettings.hook'
import { useFocus } from '@/hooks/useFocus.hook'
const StackedNote = defineAsyncComponent(
() => import('@/components/StackedNote.vue')
@@ -84,7 +83,7 @@ export default defineComponent({
const { renderString } = useMarkdown()
const { listenToClick } = useLinks('note-display')
const { stackedNotes, resetStackedNotes } = useQueryStackedNotes()
const { scrollToFocusedNote } = useFocus()
const { scrollToFocusedNote } = useQueryStackedNotes()
const { titles } = useNote('note-container')

View File

@@ -4,7 +4,9 @@
<h4 class="subtitle is-4">🔗 Links to this note</h4>
<ul>
<li v-for="link in backlink?.links" :key="link.sha">
{{ link.title }}
<a @click.prevent="emitNote(link.sha)">
{{ link.title }}
</a>
</li>
</ul>
</div>
@@ -12,6 +14,7 @@
<script lang="ts">
import { useBacklinks } from '@/hooks/useBacklinks.hook'
import { useQueryStackedNotes } from '@/hooks/useQueryStackedNotes.hook'
import { defineComponent } from 'vue'
export default defineComponent({
@@ -21,8 +24,15 @@ export default defineComponent({
},
setup(props) {
const { backlink } = useBacklinks(props.sha)
const { addStackedNote } = useQueryStackedNotes()
const emitNote = (sha: string) => {
addStackedNote(props.sha, sha)
}
return {
backlink: backlink.state
backlink: backlink.state,
emitNote
}
}
})

View File

@@ -32,10 +32,10 @@ import { computed, defineComponent, nextTick, watch } from 'vue'
import { useFile } from '@/hooks/useFile.hook'
import { useLinks } from '@/hooks/useLinks.hook'
import { useNoteOverlay } from '@/hooks/useNoteOverlay.hook'
import { useFocus } from '@/hooks/useFocus.hook'
import { useImages } from '@/hooks/useImages.hook'
import LinkedNotes from '@/components/LinkedNotes.vue'
import { filenameToNoteTitle } from '@/utils/noteTitle'
import { useQueryStackedNotes } from '@/hooks/useQueryStackedNotes.hook'
export default defineComponent({
name: 'StackedNote',
@@ -50,7 +50,7 @@ export default defineComponent({
sha: { type: String, required: true }
},
setup(props) {
const { scrollToFocusedNote } = useFocus()
const { scrollToFocusedNote } = useQueryStackedNotes()
const { content, fromCache } = useFile(props.sha)
const { listenToClick } = useLinks('stacked-note', props.sha)
const className = computed(() => `stacked-note-${props.index}`)