merge branch 'main' of github.com:lite-note/lite-note
This commit is contained in:
Julien Calixte
2026-02-10 20:48:45 +01:00
5 changed files with 75 additions and 57 deletions

View 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)
}

View File

@@ -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
}

View File

@@ -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",

View 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>

View File

@@ -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>