Frameworks
@skyscribe-sdk/vue provides useScribePublication, useScribeDocumentBySlug and useScribeDocument composables for Vue 3. Each returns reactive refs for publication / document, loading and error, and aborts the in-flight request when the component unmounts.
Note
For Nuxt 3, use @skyscribe-sdk/nuxt instead: its composables use useAsyncData, so content is fetched during server rendering, and they're auto-imported.
npm install @skyscribe-sdk/vue
Requires Vue 3 or later.
useScribePublication<script setup lang="ts">
import { useScribePublication } from '@skyscribe-sdk/vue';
const { publication, loading, error } = useScribePublication('alice.bsky.social', 'https://alice.bsky.social');
</script>
<template>
<p v-if="loading">Loading…</p>
<p v-else-if="error">Error: {{ error.message }}</p>
<main v-else-if="publication">
<h1>{{ publication.name }}</h1>
<section v-for="category in publication.categories" :key="category.slug">
<h2>{{ category.title }}</h2>
<ul>
<li v-for="ref in category.documents" :key="ref.uri">
<a :href="`/${category.slug}/${ref.slug}`">{{ ref.title }}</a>
</li>
</ul>
</section>
</main>
</template>
useScribeDocumentBySlugDocument pages usually have the Document's slug from the URL. useScribeDocumentBySlug looks it up in the Publication and returns the Document (its uri is its AT URI):
<script setup lang="ts">
import { useScribeDocumentBySlug } from '@skyscribe-sdk/vue';
const props = defineProps<{ slug: string }>();
const { document, loading, error } = useScribeDocumentBySlug(
'alice.bsky.social',
'https://alice.bsky.social',
props.slug,
);
</script>
<template>
<p v-if="loading">Loading…</p>
<p v-else-if="error">Error: {{ error.message }}</p>
<article v-else-if="document">
<h1>{{ document.title }}</h1>
<p v-if="document.description">{{ document.description }}</p>
<div class="scribe-content" v-html="document.content" />
</article>
</template>
If you render Documents from accounts you don't control, sanitise content before passing it to v-html (see Rendering the HTML).
useScribeDocumentIf you already have a DocumentRef, useScribeDocument skips the Publication lookup. It takes the Document's account and record key (rkey), both found in DocumentRef.uri (at://{did}/site.standard.document/{rkey}). Take the account from there: a Document credited to a contributor can live in their account.
import { useScribeDocument } from '@skyscribe-sdk/vue';
import { slugFromUri } from '@skyscribe-sdk/core';
const did = documentRef.uri.split('/')[2];
const { document } = useScribeDocument(did, slugFromUri(documentRef.uri));
Don't pass a slug to useScribeDocument: Documents published with current tooling have opaque rkeys, so a slug only finds very old Documents.
useScribePublicationUri / useScribeDocumentUri@skyscribe-sdk/social's buttons are React components, so you can't use them in a Vue template. If you're building your own like or subscribe UI, useScribePublicationUri and useScribeDocumentUri resolve just the AT URI you need. useScribeDocumentUri takes the Document's slug:
<script setup lang="ts">
import { useScribeDocumentUri } from '@skyscribe-sdk/vue';
const props = defineProps<{ author: string; publicationUrl: string; slug: string }>();
const { uri } = useScribeDocumentUri(props.author, props.publicationUrl, props.slug);
</script>
<template>
<p v-if="uri">AT URI: {{ uri }}</p>
</template>
Show the Publication's owner visit figures on its Insights tab in SkyScribe (free, cookie-free):
<!-- Once, in App.vue -->
<script setup lang="ts">
import { SiteAnalytics } from '@skyscribe-sdk/vue';
</script>
<template>
<RouterView />
<SiteAnalytics />
</template>
Figures only appear once your website serves the Publication verification file. See the Site Analytics guide for that, privacy, and CSP.
The main types from @skyscribe-sdk/core are re-exported:
import type { StandardPublication, StandardDocument, DocumentRef, Category } from '@skyscribe-sdk/vue';