💄 (backlinks)
This commit is contained in:
@@ -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>
|
||||
|
||||
Reference in New Issue
Block a user