merge branch 'main' of github.com:lite-note/lite-note
This commit is contained in:
13
src/modules/atproto/getAka.ts
Normal file
13
src/modules/atproto/getAka.ts
Normal file
@@ -0,0 +1,13 @@
|
|||||||
|
export const getAka = async (dids: Set<string>) => {
|
||||||
|
const correspondance = await Promise.all(
|
||||||
|
[...dids].map(async (did) => {
|
||||||
|
const response = await fetch(`https://plc.directory/${did}`)
|
||||||
|
const {
|
||||||
|
alsoKnownAs: [aka],
|
||||||
|
} = await response.json()
|
||||||
|
return [did, aka] as [string, string]
|
||||||
|
}),
|
||||||
|
)
|
||||||
|
|
||||||
|
return new Map(correspondance)
|
||||||
|
}
|
||||||
@@ -1,7 +1,19 @@
|
|||||||
import { DataType } from '@/data/DataType.enum'
|
import { DataType } from "@/data/DataType.enum"
|
||||||
import { Model } from '@/data/models/Model'
|
import { Model } from "@/data/models/Model"
|
||||||
|
|
||||||
export interface Note extends Model<DataType.Note> {
|
export interface Note extends Model<DataType.Note> {
|
||||||
content: string
|
content: string
|
||||||
editedSha?: string
|
editedSha?: string
|
||||||
}
|
}
|
||||||
|
|
||||||
|
export interface PublicNoteListItem {
|
||||||
|
did: string
|
||||||
|
rkey: string
|
||||||
|
title: string
|
||||||
|
publishedAt: string
|
||||||
|
createdAt: string
|
||||||
|
}
|
||||||
|
|
||||||
|
export interface PublicNote extends PublicNoteListItem {
|
||||||
|
content: string
|
||||||
|
}
|
||||||
|
|||||||
@@ -20,10 +20,14 @@ const routes: Array<RouteRecordRaw> = [
|
|||||||
component: () => import("@/views/FluxNoteView.vue"),
|
component: () => import("@/views/FluxNoteView.vue"),
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
path: "/:user/:repo/share/:note",
|
path: "/notes",
|
||||||
name: "ShareNotes",
|
name: "PublicNoteView",
|
||||||
props: true,
|
component: () => import("@/views/PublicNoteView.vue"),
|
||||||
component: () => import("@/views/ShareNotes.vue"),
|
},
|
||||||
|
{
|
||||||
|
path: "/tiboudenote",
|
||||||
|
name: "PublicNoteView",
|
||||||
|
component: () => import("@/views/PublicNoteView.vue"),
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
path: "/:user/:repo/inbox",
|
path: "/:user/:repo/inbox",
|
||||||
|
|||||||
40
src/views/PublicNoteView.vue
Normal file
40
src/views/PublicNoteView.vue
Normal file
@@ -0,0 +1,40 @@
|
|||||||
|
<script setup lang="ts">
|
||||||
|
import { getAka } from "@/modules/atproto/getAka"
|
||||||
|
import { PublicNoteListItem } from "@/modules/note/models/Note"
|
||||||
|
import { computedAsync, useAsyncState } from "@vueuse/core"
|
||||||
|
|
||||||
|
const { state, isLoading } = useAsyncState<{
|
||||||
|
notes: PublicNoteListItem[]
|
||||||
|
}>(
|
||||||
|
async () => {
|
||||||
|
const response = await fetch("https://api.litenote.li212.fr/notes")
|
||||||
|
return response.json()
|
||||||
|
},
|
||||||
|
{ notes: [] },
|
||||||
|
)
|
||||||
|
|
||||||
|
const aka = computedAsync<Map<string, string>>(async () => {
|
||||||
|
if (state.value.notes.length === 0) {
|
||||||
|
return new Map()
|
||||||
|
}
|
||||||
|
return getAka(new Set(state.value.notes.map((n) => n.did)))
|
||||||
|
}, new Map())
|
||||||
|
|
||||||
|
const getAlias = (did: string) => aka.value.get(did) ?? ""
|
||||||
|
</script>
|
||||||
|
|
||||||
|
<template>
|
||||||
|
<div v-if="isLoading"></div>
|
||||||
|
<div class="public-note-view" v-else>
|
||||||
|
<ul>
|
||||||
|
<li v-for="note in state.notes">
|
||||||
|
{{ getAlias(note.did) }}: {{ note.title }}
|
||||||
|
</li>
|
||||||
|
</ul>
|
||||||
|
</div>
|
||||||
|
</template>
|
||||||
|
|
||||||
|
<style scoped lang="scss">
|
||||||
|
.public-note-view {
|
||||||
|
}
|
||||||
|
</style>
|
||||||
@@ -1,51 +0,0 @@
|
|||||||
<script lang="ts" setup>
|
|
||||||
import { computed, defineAsyncComponent } from 'vue'
|
|
||||||
|
|
||||||
import { useFile } from '@/hooks/useFile.hook'
|
|
||||||
|
|
||||||
const FluxNote = defineAsyncComponent(() => import('@/components/FluxNote.vue'))
|
|
||||||
|
|
||||||
const props = defineProps<{ user: string; repo: string; note: string }>()
|
|
||||||
|
|
||||||
const note = computed(() => props.note)
|
|
||||||
const { content } = useFile(note)
|
|
||||||
</script>
|
|
||||||
|
|
||||||
<template>
|
|
||||||
<div class="share-notes">
|
|
||||||
<article class="message is-primary">
|
|
||||||
<div class="message-body">
|
|
||||||
You can print this page. It contains every stacked notes.
|
|
||||||
</div>
|
|
||||||
</article>
|
|
||||||
<flux-note
|
|
||||||
key="share-notes"
|
|
||||||
class="notes"
|
|
||||||
:user="user"
|
|
||||||
:repo="repo"
|
|
||||||
:content="content"
|
|
||||||
:with-header="false"
|
|
||||||
:parse-content="false"
|
|
||||||
/>
|
|
||||||
</div>
|
|
||||||
</template>
|
|
||||||
|
|
||||||
<style scoped lang="scss">
|
|
||||||
.share-notes {
|
|
||||||
min-width: 100vw;
|
|
||||||
margin: auto;
|
|
||||||
display: flex;
|
|
||||||
flex-direction: column;
|
|
||||||
align-items: center;
|
|
||||||
|
|
||||||
article {
|
|
||||||
margin: 1rem;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
@media print {
|
|
||||||
article {
|
|
||||||
display: none;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
</style>
|
|
||||||
Reference in New Issue
Block a user