💄 (backlinks)

This commit is contained in:
Julien Calixte
2021-06-06 15:58:12 +02:00
parent 86e5d934a5
commit 54bce75122
2 changed files with 19 additions and 5 deletions

View File

@@ -1,8 +1,7 @@
<template>
<div v-if="(backlink?.links.length ?? 0) > 0" class="linked-notes">
<hr />
<h4 class="subtitle is-4">🔗 Links to this note</h4>
<ul>
<div v-if="hasBacklinks" class="linked-notes">
<h5 class="subtitle is-5">🔗</h5>
<ul class="links">
<li v-for="link in backlink?.links" :key="link.sha">
<a @click.prevent="emitNote(link.sha)">
{{ link.title }}
@@ -15,7 +14,7 @@
<script lang="ts">
import { useBacklinks } from '@/hooks/useBacklinks.hook'
import { useQueryStackedNotes } from '@/hooks/useQueryStackedNotes.hook'
import { defineComponent } from 'vue'
import { computed, defineComponent } from 'vue'
export default defineComponent({
name: 'LinkedNotes',
@@ -25,6 +24,9 @@ export default defineComponent({
setup(props) {
const { backlink } = useBacklinks(props.sha)
const { addStackedNote } = useQueryStackedNotes()
const hasBacklinks = computed(
() => (backlink.state.value?.links.length ?? 0) > 0
)
const emitNote = (sha: string) => {
addStackedNote(props.sha, sha)
@@ -32,6 +34,7 @@ export default defineComponent({
return {
backlink: backlink.state,
hasBacklinks,
emitNote
}
}
@@ -40,8 +43,17 @@ export default defineComponent({
<style scoped lang="scss">
.linked-notes {
padding: 1rem;
background-color: var(--light-link);
.subtitle {
font-style: italic;
padding-top: 1rem;
text-align: center;
}
ul {
list-style-type: square;
}
}
</style>