diff --git a/src/components/FluxNote.vue b/src/components/FluxNote.vue
index 877abd2..dc9702e 100644
--- a/src/components/FluxNote.vue
+++ b/src/components/FluxNote.vue
@@ -11,7 +11,7 @@ import {
import StackedNote from "@/components/StackedNote.vue"
import { useLinks } from "@/hooks/useLinks.hook"
-import { useMarkdown } from "@/hooks/useMarkdown.hook"
+import { markdownBuilder } from "@/hooks/useMarkdown.hook"
import { useNoteView } from "@/hooks/useNoteView.hook"
import { useRouteQueryStackedNotes } from "@/hooks/useRouteQueryStackedNotes.hook"
import { useVisitRepo } from "@/modules/history/hooks/useVisitRepo.hook"
@@ -48,7 +48,7 @@ const refProps = toRefs(props)
const store = useUserRepoStore()
useUserSettings()
const { visitRepo } = useVisitRepo({ user: user, repo: repo })
-const { toHTML } = useMarkdown(repo)
+const { toHTML } = markdownBuilder(repo)
const { listenToClick } = useLinks("note-display")
const { stackedNotes, scrollToFocusedNote } = useRouteQueryStackedNotes()
diff --git a/src/components/StackedNote.vue b/src/components/StackedNote.vue
index 715b559..6aab83a 100644
--- a/src/components/StackedNote.vue
+++ b/src/components/StackedNote.vue
@@ -188,34 +188,6 @@ watch(mode, async (newMode) => {
-
-
-
diff --git a/src/hooks/useFile.hook.ts b/src/hooks/useFile.hook.ts
index 9d42f18..51b7fa3 100644
--- a/src/hooks/useFile.hook.ts
+++ b/src/hooks/useFile.hook.ts
@@ -1,6 +1,6 @@
import { computed, Ref, ref, toValue } from "vue"
-import { useMarkdown } from "@/hooks/useMarkdown.hook"
+import { markdownBuilder } from "@/hooks/useMarkdown.hook"
import { prepareNoteCache } from "@/modules/note/cache/prepareNoteCache"
import { queryFileContent } from "@/modules/repo/services/repo"
import { useUserRepoStore } from "@/modules/repo/store/userRepo.store"
@@ -18,7 +18,7 @@ export const useFile = (sha: Ref
| string, retrieveContent = true) => {
render,
renderFromUTF8,
getRawContent: getRawContentFromFile,
- } = useMarkdown(shaValue)
+ } = markdownBuilder(shaValue)
const { getCachedNote, saveCacheNote } = prepareNoteCache(
shaValue,
diff --git a/src/hooks/useMarkdown.hook.ts b/src/hooks/useMarkdown.hook.ts
index 1641d32..a4d6fe2 100644
--- a/src/hooks/useMarkdown.hook.ts
+++ b/src/hooks/useMarkdown.hook.ts
@@ -116,7 +116,7 @@ const rules: Renderer.RenderRuleRecord = {
md.renderer.rules = { ...md.renderer.rules, ...rules }
-export const useMarkdown = (defaultPrefix?: Ref | string) => {
+export const markdownBuilder = (defaultPrefix?: Ref | string) => {
const getRawContent = (content: string) => decodeBase64ToUTF8(content)
const renderFromUTF8 = (content: string, prefix?: string) =>
content
diff --git a/src/modules/atproto/getAka.ts b/src/modules/atproto/getAka.ts
index a1ef5bd..233940b 100644
--- a/src/modules/atproto/getAka.ts
+++ b/src/modules/atproto/getAka.ts
@@ -1,5 +1,22 @@
const correspondanceCache = new Map()
+export const getUniqueAka = async (did: string) => {
+ if (correspondanceCache.has(did)) {
+ return correspondanceCache.get(did) as string
+ }
+
+ const response = await fetch(`https://plc.directory/${did}`)
+ const {
+ alsoKnownAs: [aka],
+ } = await response.json()
+
+ const alias = aka.replace("at://", "")
+
+ correspondanceCache.set(did, alias)
+
+ return alias
+}
+
export const getAka = async (dids: Set) => {
const correspondance = await Promise.all(
[...dids].map(async (did) => {
diff --git a/src/modules/atproto/getUrl.ts b/src/modules/atproto/getUrl.ts
index 71aa15e..5a8a282 100644
--- a/src/modules/atproto/getUrl.ts
+++ b/src/modules/atproto/getUrl.ts
@@ -1,10 +1,24 @@
-export const getUrl = async ({ did, rkey }: { did: string; rkey: string }) => {
+const endpointCache = new Map()
+
+const getEndpoint = async (did: string) => {
+ if (endpointCache.has(did)) {
+ return endpointCache.get(did)
+ }
const response = await fetch(`https://plc.directory/${did}`)
const {
service: [{ serviceEndpoint }],
} = await response.json()
- const url = new URL("/xrpc/com.atproto.repo.getRecord", serviceEndpoint)
+ endpointCache.set(did, serviceEndpoint)
+
+ return serviceEndpoint as string
+}
+
+export const getUrl = async ({ did, rkey }: { did: string; rkey: string }) => {
+ const url = new URL(
+ "/xrpc/com.atproto.repo.getRecord",
+ await getEndpoint(did),
+ )
url.searchParams.set("repo", did)
url.searchParams.set("collection", "space.litenote.note")
url.searchParams.set("rkey", rkey)
diff --git a/src/modules/card/hooks/useSpacedRepetitionCards.ts b/src/modules/card/hooks/useSpacedRepetitionCards.ts
index 727b93e..6ce6acd 100644
--- a/src/modules/card/hooks/useSpacedRepetitionCards.ts
+++ b/src/modules/card/hooks/useSpacedRepetitionCards.ts
@@ -1,18 +1,18 @@
// https://npm.io/package/supermemo
-import { useAsyncState } from '@vueuse/core'
-import { addDays, isAfter } from 'date-fns'
-import { computed, nextTick, watch } from 'vue'
+import { useAsyncState } from "@vueuse/core"
+import { addDays, isAfter } from "date-fns"
+import { computed, nextTick, watch } from "vue"
-import { data } from '@/data/data'
-import { DataType } from '@/data/DataType.enum'
-import { useFile } from '@/hooks/useFile.hook'
-import { useLinks } from '@/hooks/useLinks.hook'
-import { useMarkdown } from '@/hooks/useMarkdown.hook'
-import { Card } from '@/modules/card/models/Card'
-import { RepetitionCard } from '@/modules/card/models/RepetitionCard'
-import { useUserRepoStore } from '@/modules/repo/store/userRepo.store'
-import { decodeBase64ToUTF8 } from '@/utils/decodeBase64ToUTF8'
+import { data } from "@/data/data"
+import { DataType } from "@/data/DataType.enum"
+import { useFile } from "@/hooks/useFile.hook"
+import { useLinks } from "@/hooks/useLinks.hook"
+import { markdownBuilder } from "@/hooks/useMarkdown.hook"
+import { Card } from "@/modules/card/models/Card"
+import { RepetitionCard } from "@/modules/card/models/RepetitionCard"
+import { useUserRepoStore } from "@/modules/repo/store/userRepo.store"
+import { decodeBase64ToUTF8 } from "@/utils/decodeBase64ToUTF8"
const MAX_LEVEL = 8
@@ -22,23 +22,23 @@ export interface Repetition {
}
export const useSpacedRepetitionCards = () => {
- const { toHTML } = useMarkdown()
+ const { toHTML } = markdownBuilder()
const store = useUserRepoStore()
- const { listenToClick } = useLinks('flip-card')
+ const { listenToClick } = useLinks("flip-card")
const cardFiles = computed(() =>
store.files.filter(
(file) =>
file.path !== undefined &&
- file.path.startsWith('_cards') &&
- file.path.endsWith('.md')
- )
+ file.path.startsWith("_cards") &&
+ file.path.endsWith(".md"),
+ ),
)
const {
state: cards,
isReady,
- execute
+ execute,
} = useAsyncState(
async () => {
const cards: Repetition[] = []
@@ -55,7 +55,7 @@ export const useSpacedRepetitionCards = () => {
$type: DataType.RepetitionCard,
level: 1,
repeatDate: new Date(),
- needsReview: false
+ needsReview: false,
})
if (
@@ -67,30 +67,30 @@ export const useSpacedRepetitionCards = () => {
}
const { getContent } = useFile(cardFile.sha, false)
- const content = (await getContent()) ?? ''
+ const content = (await getContent()) ?? ""
const [front, back, references] =
- decodeBase64ToUTF8(content).split('___') ?? []
+ decodeBase64ToUTF8(content).split("___") ?? []
cards.push({
repetition,
card: {
front: toHTML(front),
back: toHTML(back),
- references: toHTML(references)
- }
+ references: toHTML(references),
+ },
})
}
return cards
},
[],
- { immediate: false }
+ { immediate: false },
)
const successRepetition = async (cardId: string) => {
const repetition = await data.get(
- cardId
+ cardId,
)
if (!repetition) {
return
@@ -100,13 +100,13 @@ export const useSpacedRepetitionCards = () => {
...repetition,
needsReview: false,
level: Math.min(repetition.level + 1, MAX_LEVEL),
- repeatDate: addDays(new Date(), 2 ** repetition.level)
+ repeatDate: addDays(new Date(), 2 ** repetition.level),
})
}
const failRepetition = async (cardId: string) => {
const repetition = await data.get(
- cardId
+ cardId,
)
if (!repetition) {
return
@@ -118,13 +118,13 @@ export const useSpacedRepetitionCards = () => {
...repetition,
level,
needsReview: false,
- repeatDate: addDays(new Date(), level)
+ repeatDate: addDays(new Date(), level),
})
}
const needsReview = async (cardId: string) => {
const repetition = await data.get(
- cardId
+ cardId,
)
if (!repetition) {
return
@@ -132,7 +132,7 @@ export const useSpacedRepetitionCards = () => {
await data.update({
...repetition,
- needsReview: true
+ needsReview: true,
})
}
@@ -142,7 +142,7 @@ export const useSpacedRepetitionCards = () => {
nextTick(() => {
listenToClick()
}),
- { immediate: true }
+ { immediate: true },
)
watch(cardFiles, () => execute())
@@ -152,6 +152,6 @@ export const useSpacedRepetitionCards = () => {
successRepetition,
failRepetition,
needsReview,
- isLoading: !isReady
+ isLoading: !isReady,
}
}
diff --git a/src/modules/repo/services/repo.ts b/src/modules/repo/services/repo.ts
index 008aed7..b844918 100644
--- a/src/modules/repo/services/repo.ts
+++ b/src/modules/repo/services/repo.ts
@@ -1,4 +1,4 @@
-import { useMarkdown } from "@/hooks/useMarkdown.hook"
+import { markdownBuilder } from "@/hooks/useMarkdown.hook"
import { prepareNoteCache } from "@/modules/note/cache/prepareNoteCache"
import { RepoFile } from "@/modules/repo/interfaces/RepoFile"
import { UserSettings } from "@/modules/repo/interfaces/UserSettings"
@@ -41,7 +41,7 @@ export const getCachedMainReadme = async (owner: string, repo: string) => {
if (!owner || !repo) {
return null
}
- const { render } = useMarkdown()
+ const { render } = markdownBuilder()
const { getCachedNote } = prepareNoteCache(`${owner}-${repo}-README`)
const { note: cachedReadme } = await getCachedNote()
@@ -58,7 +58,7 @@ export const getMainReadme = async (owner: string, repo: string) => {
return null
}
- const { render } = useMarkdown()
+ const { render } = markdownBuilder()
const { getCachedNote, saveCacheNote } = prepareNoteCache(
`${owner}-${repo}-README`,
)
diff --git a/src/views/PublicNoteView.vue b/src/views/PublicNoteView.vue
index 7d8bc06..07bc5cf 100644
--- a/src/views/PublicNoteView.vue
+++ b/src/views/PublicNoteView.vue
@@ -1,24 +1,66 @@
- {{ did }}/{{ rkey }}@{{ url }}
-
{{ content }}
+
{{ alias }}
+
diff --git a/src/views/TodoNotes.vue b/src/views/TodoNotes.vue
index 5fdaa75..dd6f79a 100644
--- a/src/views/TodoNotes.vue
+++ b/src/views/TodoNotes.vue
@@ -2,7 +2,7 @@
import { computed, defineAsyncComponent, nextTick, ref, watch } from "vue"
import { useUserRepoStore } from "@/modules/repo/store/userRepo.store"
import { useCheckboxCommit } from "@/hooks/useCheckboxCommit.hook"
-import { useMarkdown } from "@/hooks/useMarkdown.hook"
+import { markdownBuilder } from "@/hooks/useMarkdown.hook"
import { queryFileContent } from "@/modules/repo/services/repo"
import { decodeBase64ToUTF8 } from "@/utils/decodeBase64ToUTF8"
@@ -20,23 +20,19 @@ const todoNote = computed(() =>
const sha = computed(() => todoNote.value?.sha ?? "")
const path = computed(() => todoNote.value?.path)
-const { toHTML } = useMarkdown(repo)
+const { toHTML } = markdownBuilder(repo)
// Setup checkbox commit handler
-const {
- pendingContent,
- syncContent,
- listenToCheckboxes,
- hasPendingChanges,
-} = useCheckboxCommit({
- user: props.user,
- repo: props.repo,
- path,
- initialContent: "",
- initialSha: sha,
- containerSelector: ".todo-notes .note-display",
- debounceMs: 1000,
-})
+const { pendingContent, syncContent, listenToCheckboxes, hasPendingChanges } =
+ useCheckboxCommit({
+ user: props.user,
+ repo: props.repo,
+ path,
+ initialContent: "",
+ initialSha: sha,
+ containerSelector: ".todo-notes .note-display",
+ debounceMs: 1000,
+ })
// Render pending content to HTML for display
const renderedContent = computed(() => {