🐛 (backlinks) no reset for backlinks
This commit is contained in:
@@ -29,6 +29,7 @@ export const useComputeBacklinks = () => {
|
|||||||
if (!isMarkdown(file.path) || !file.sha) {
|
if (!isMarkdown(file.path) || !file.sha) {
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
|
|
||||||
const fileBacklinkId = data.generateId(DataType.BacklinkNote, file.sha)
|
const fileBacklinkId = data.generateId(DataType.BacklinkNote, file.sha)
|
||||||
const fileBacklink = await data.get<DataType.BacklinkNote, BacklinkNote>(
|
const fileBacklink = await data.get<DataType.BacklinkNote, BacklinkNote>(
|
||||||
fileBacklinkId
|
fileBacklinkId
|
||||||
@@ -36,7 +37,11 @@ export const useComputeBacklinks = () => {
|
|||||||
if (fileBacklink) {
|
if (fileBacklink) {
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (!backlinks.has(file.sha)) {
|
||||||
backlinks.set(file.sha, [])
|
backlinks.set(file.sha, [])
|
||||||
|
}
|
||||||
|
|
||||||
const { getContent } = useFile(file.sha, false)
|
const { getContent } = useFile(file.sha, false)
|
||||||
const note = await getContent()
|
const note = await getContent()
|
||||||
|
|
||||||
@@ -64,6 +69,7 @@ export const useComputeBacklinks = () => {
|
|||||||
}
|
}
|
||||||
|
|
||||||
const previousBacklinks = backlinks.get(backlinkFile.sha) ?? []
|
const previousBacklinks = backlinks.get(backlinkFile.sha) ?? []
|
||||||
|
|
||||||
if (previousBacklinks.find((bl) => bl.sha === file.sha)) {
|
if (previousBacklinks.find((bl) => bl.sha === file.sha)) {
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
|
|||||||
82
src/modules/card/components/FlipCard.vue
Normal file
82
src/modules/card/components/FlipCard.vue
Normal file
@@ -0,0 +1,82 @@
|
|||||||
|
<template>
|
||||||
|
<div class="flip-card" :class="{ flipped }" @click="flip">
|
||||||
|
<div class="flip-card-inner">
|
||||||
|
<div class="flip-card-front flip-card-content" v-html="card.front"></div>
|
||||||
|
<div class="flip-card-back flip-card-content">
|
||||||
|
<div class="back" v-html="card.back"></div>
|
||||||
|
<hr />
|
||||||
|
<div class="references" v-html="card.references"></div>
|
||||||
|
<hr />
|
||||||
|
<div class="buttons is-centered">
|
||||||
|
<div class="button is-danger" @click.stop="action">failed</div>
|
||||||
|
<div class="button is-success" @click.stop="action">got it</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</template>
|
||||||
|
|
||||||
|
<script lang="ts">
|
||||||
|
import { defineComponent, PropType, ref } from 'vue'
|
||||||
|
import { Card } from '../models/Card'
|
||||||
|
|
||||||
|
export default defineComponent({
|
||||||
|
name: 'FlipCard',
|
||||||
|
props: {
|
||||||
|
card: { type: Object as PropType<Card>, required: true }
|
||||||
|
},
|
||||||
|
setup() {
|
||||||
|
const flipped = ref(false)
|
||||||
|
|
||||||
|
const flip = () => (flipped.value = !flipped.value)
|
||||||
|
const action = () => {
|
||||||
|
console.log('action')
|
||||||
|
}
|
||||||
|
|
||||||
|
return { flip, flipped, action }
|
||||||
|
}
|
||||||
|
})
|
||||||
|
</script>
|
||||||
|
|
||||||
|
<style scoped lang="scss">
|
||||||
|
.flip-card {
|
||||||
|
display: flex;
|
||||||
|
background-color: transparent;
|
||||||
|
padding: 0 1rem;
|
||||||
|
margin: auto;
|
||||||
|
|
||||||
|
&:hover {
|
||||||
|
cursor: pointer;
|
||||||
|
}
|
||||||
|
|
||||||
|
.flip-card-inner {
|
||||||
|
flex: 1;
|
||||||
|
position: relative;
|
||||||
|
transition: cubic-bezier(0.39, 0.575, 0.565, 1) 0.4s;
|
||||||
|
transform-style: preserve-3d;
|
||||||
|
border-radius: 1rem;
|
||||||
|
}
|
||||||
|
|
||||||
|
&.flipped .flip-card-inner {
|
||||||
|
transform: rotateY(180deg);
|
||||||
|
}
|
||||||
|
|
||||||
|
.flip-card-front,
|
||||||
|
.flip-card-back {
|
||||||
|
position: absolute;
|
||||||
|
backface-visibility: hidden;
|
||||||
|
}
|
||||||
|
|
||||||
|
.flip-card-content {
|
||||||
|
width: 100%;
|
||||||
|
background-color: #ebebeb;
|
||||||
|
color: var(--font-color);
|
||||||
|
padding: 1rem;
|
||||||
|
border-radius: 1rem;
|
||||||
|
}
|
||||||
|
|
||||||
|
.flip-card-back {
|
||||||
|
transform: rotateY(180deg);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
</style>
|
||||||
@@ -19,10 +19,12 @@ export const useSpacedRepetitionCards = () => {
|
|||||||
|
|
||||||
const cards = asyncComputed(async () => {
|
const cards = asyncComputed(async () => {
|
||||||
const cards: Card[] = []
|
const cards: Card[] = []
|
||||||
|
|
||||||
for (const cardFile of cardFiles.value) {
|
for (const cardFile of cardFiles.value) {
|
||||||
if (!cardFile.sha) {
|
if (!cardFile.sha) {
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
|
|
||||||
const { getRawContent } = useFile(cardFile.sha, false)
|
const { getRawContent } = useFile(cardFile.sha, false)
|
||||||
const content = await getRawContent()
|
const content = await getRawContent()
|
||||||
|
|
||||||
@@ -35,6 +37,7 @@ export const useSpacedRepetitionCards = () => {
|
|||||||
references: renderString(references)
|
references: renderString(references)
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
return cards
|
return cards
|
||||||
}, [])
|
}, [])
|
||||||
|
|
||||||
|
|||||||
@@ -6,38 +6,23 @@
|
|||||||
:repo="repo"
|
:repo="repo"
|
||||||
:with-content="false"
|
:with-content="false"
|
||||||
>
|
>
|
||||||
<div
|
<flip-card v-if="firstCard" :card="firstCard" />
|
||||||
v-for="(card, i) in cards"
|
<section v-else>No cards to review!</section>
|
||||||
:key="i"
|
|
||||||
class="flip-card"
|
|
||||||
:class="{ flipped }"
|
|
||||||
@click="flip"
|
|
||||||
>
|
|
||||||
<div class="flip-card-inner">
|
|
||||||
<div
|
|
||||||
class="flip-card-front flip-card-content"
|
|
||||||
v-html="card.front"
|
|
||||||
></div>
|
|
||||||
<div class="flip-card-back flip-card-content">
|
|
||||||
<div class="back" v-html="card.back"></div>
|
|
||||||
<hr />
|
|
||||||
<div class="references" v-html="card.references"></div>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
</flux-note>
|
</flux-note>
|
||||||
</div>
|
</div>
|
||||||
</template>
|
</template>
|
||||||
|
|
||||||
<script lang="ts">
|
<script lang="ts">
|
||||||
import { useSpacedRepetitionCards } from '@/modules/card/hooks/useSpacedRepetitionCards'
|
import { useSpacedRepetitionCards } from '@/modules/card/hooks/useSpacedRepetitionCards'
|
||||||
import { defineComponent, ref } from 'vue'
|
import { computed, defineComponent } from 'vue'
|
||||||
import FluxNote from '@/components/FluxNote.vue'
|
import FluxNote from '@/components/FluxNote.vue'
|
||||||
|
import FlipCard from '@/modules/card/components/FlipCard.vue'
|
||||||
|
|
||||||
export default defineComponent({
|
export default defineComponent({
|
||||||
name: 'SpacedRepetitionCard',
|
name: 'SpacedRepetitionCard',
|
||||||
components: {
|
components: {
|
||||||
FluxNote
|
FluxNote,
|
||||||
|
FlipCard
|
||||||
},
|
},
|
||||||
props: {
|
props: {
|
||||||
user: { type: String, required: true },
|
user: { type: String, required: true },
|
||||||
@@ -45,14 +30,13 @@ export default defineComponent({
|
|||||||
},
|
},
|
||||||
setup() {
|
setup() {
|
||||||
const { cards } = useSpacedRepetitionCards()
|
const { cards } = useSpacedRepetitionCards()
|
||||||
const flipped = ref(false)
|
const firstCard = computed(() => {
|
||||||
|
const [firstCard] = cards.value
|
||||||
const flip = () => (flipped.value = !flipped.value)
|
return firstCard
|
||||||
|
})
|
||||||
|
|
||||||
return {
|
return {
|
||||||
cards,
|
firstCard
|
||||||
flipped,
|
|
||||||
flip
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
@@ -62,46 +46,5 @@ export default defineComponent({
|
|||||||
.spaced-repetition-card {
|
.spaced-repetition-card {
|
||||||
display: flex;
|
display: flex;
|
||||||
flex: 1;
|
flex: 1;
|
||||||
|
|
||||||
.flip-card {
|
|
||||||
display: flex;
|
|
||||||
background-color: transparent;
|
|
||||||
padding: 0 1rem;
|
|
||||||
margin: auto;
|
|
||||||
|
|
||||||
&:hover {
|
|
||||||
cursor: pointer;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
.flip-card-inner {
|
|
||||||
flex: 1;
|
|
||||||
position: relative;
|
|
||||||
transition: cubic-bezier(0.39, 0.575, 0.565, 1) 0.4s;
|
|
||||||
transform-style: preserve-3d;
|
|
||||||
border-radius: 1rem;
|
|
||||||
}
|
|
||||||
|
|
||||||
.flip-card.flipped .flip-card-inner {
|
|
||||||
transform: rotateY(180deg);
|
|
||||||
}
|
|
||||||
|
|
||||||
.flip-card-front,
|
|
||||||
.flip-card-back {
|
|
||||||
position: absolute;
|
|
||||||
backface-visibility: hidden;
|
|
||||||
}
|
|
||||||
|
|
||||||
.flip-card-content {
|
|
||||||
width: 100%;
|
|
||||||
background-color: #ebebeb;
|
|
||||||
color: var(--font-color);
|
|
||||||
padding: 1rem;
|
|
||||||
border-radius: 1rem;
|
|
||||||
}
|
|
||||||
|
|
||||||
.flip-card-back {
|
|
||||||
transform: rotateY(180deg);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
</style>
|
</style>
|
||||||
|
|||||||
Reference in New Issue
Block a user