API reference
A Nuxt 3 module with composables and SEO helpers. Install with npm install @skyscribe-sdk/nuxt. See the Nuxt guide for walkthroughs.
// nuxt.config.ts
export default defineNuxtConfig({
modules: ['@skyscribe-sdk/nuxt'],
});
Once it's registered, useScribePublication, useScribeDocumentBySlug, useScribeDocument, useScribePublicationUri, useScribeDocumentUri, useSiteAnalytics, documentSeoMeta and publicationSeoMeta are available in every component and page without importing them.
Careful
Use version 1.3.0 or later. Earlier versions, including every @scribe-atp/nuxt release, left the composables out of the published package, so they were never auto-imported.
useScribePublicationfunction useScribePublication(
author: string,
publicationUrl: string,
options?: AsyncDataOptions
): Promise<AsyncData<StandardPublication | null, Error | null>>
Runs fetchPublication inside useAsyncData, so the Publication is fetched during server rendering and reused on the client.
| Parameter | Type | Description |
|---|---|---|
author | string | Author handle or DID |
publicationUrl | string | The Publication's canonical HTTPS URL, e.g. "https://alice.bsky.social" |
options | AsyncDataOptions | Optional. Passed on to useAsyncData (lazy, server, watch and so on) |
Returns Nuxt's standard AsyncData: { data, pending, error, refresh }, where data holds StandardPublication | null.
useScribeDocumentBySlugfunction useScribeDocumentBySlug(
author: string,
publicationUrl: string,
documentSlug: string,
options?: AsyncDataOptions
): Promise<AsyncData<StandardDocument | null, Error | null>>
Looks a Document up by its slug in the Publication at publicationUrl, inside useAsyncData. data holds the Document; data.value.uri is its AT URI.
| Parameter | Type | Description |
|---|---|---|
author | string | Author handle or DID |
publicationUrl | string | The Publication's canonical HTTPS URL |
documentSlug | string | The Document's slug, as in its URL |
options | AsyncDataOptions | Optional. Passed on to useAsyncData |
useScribeDocumentfunction useScribeDocument(
author: string,
rkey: string,
options?: AsyncDataOptions
): Promise<AsyncData<StandardDocument | null, Error | null>>
Runs fetchDocument inside useAsyncData, so it fetches by the Document's record key (rkey).
| Parameter | Type | Description |
|---|---|---|
author | string | Handle or DID of the account the Document is stored in |
rkey | string | The Document's record key |
options | AsyncDataOptions | Optional. Forwarded to useAsyncData |
Returns { data, pending, error, refresh }, where data holds StandardDocument | null. Don't pass a slug: it only finds very old Documents. With a slug, use useScribeDocumentBySlug.
useScribePublicationUri / useScribeDocumentUrifunction useScribePublicationUri(author: string, publicationUrl: string, options?: AsyncDataOptions)
function useScribeDocumentUri(author: string, publicationUrl: string, documentSlug: string, options?: AsyncDataOptions)
Resolve just the AT URI of a Publication or (by slug) a Document, inside useAsyncData. data holds the URI string.
useSiteAnalyticsfunction useSiteAnalytics(options?: { disabled?: boolean }): void
Puts the Site Analytics beacon in the page <head> through useHead, so it's in the server-rendered HTML. Call it once, in app.vue. Auto-imported. disabled leaves the beacon out.
documentSeoMetafunction documentSeoMeta(document: StandardDocument, publication: StandardPublication): UseSeoMetaInput
Returns an object for Nuxt's useSeoMeta(): title, ogType, ogTitle, ogUrl, ogSiteName, ogDescription, ogImage (the cover image), twitterCard, twitterTitle, twitterDescription and twitterImage. useSeoMeta can't set a canonical link, the site.standard link tags or structured data: add those with useHead, using buildCanonicalUrl, standardSiteLinks and generateDocumentJsonLd, which this package re-exports.
| Parameter | Type | Description |
|---|---|---|
document | StandardDocument | The full Document |
publication | StandardPublication | The Publication |
<script setup lang="ts">
import { documentSeoMeta, standardSiteLinks } from '@skyscribe-sdk/nuxt';
import { fetchDocumentBySlug, fetchPublication } from '@skyscribe-sdk/core';
const route = useRoute();
const [document, publication] = await Promise.all([
fetchDocumentBySlug('alice.bsky.social', 'https://alice.bsky.social', route.params.slug as string),
fetchPublication('alice.bsky.social', 'https://alice.bsky.social'),
]);
useSeoMeta(documentSeoMeta(document, publication));
useHead({
link: standardSiteLinks(publication, document).map(({ rel, href }) => ({ rel, href })),
});
</script>
Import it from @skyscribe-sdk/nuxt.
publicationSeoMetafunction publicationSeoMeta(publication: StandardPublication): UseSeoMetaInput
Returns useSeoMeta() input for a Publication's home or Category page. The package also re-exports buildPublicationUrl and generatePublicationJsonLd for the canonical link and structured data.
| Parameter | Type | Description |
|---|---|---|
publication | StandardPublication | The Publication |
The main types from @skyscribe-sdk/core are re-exported:
import type { StandardPublication, StandardDocument, DocumentRef, Category } from '@skyscribe-sdk/nuxt';
See the core reference for type definitions.
useScribeSite, useScribeArticle, useScribeArticleBySlug (whose data is still { article, uri }), siteSeoMeta and articleSeoMeta still work, marked @deprecated, until the next major. The composables stay auto-imported. See Upgrading to 5.0.