merge branch 'main' of github.com:lite-note/lite-note
This commit is contained in:
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