Skip to content

API reference

@ghostwritr/svelte has two entries. The core @ghostwritr/svelte is data + SEO (no Markdown dependency); the @ghostwritr/svelte/article-content subpath is the opt-in Markdown renderer. The fetchers and types are re-exported from the shared @ghostwritr/feed core, so the contract is identical across the Next / Astro / React Router / Vue / Svelte SDKs. Peer: svelte >= 5 (Svelte 5 runes; works in SvelteKit and plain Svelte).

ExportSignatureNotes
fetchArticles(opts: FeedFetchOptions) => Promise<Article[]>Keyless list read. Newest-first; never null (a feedless site throws NOT_FOUND). Call in a server load. Re-exported from @ghostwritr/feed.
fetchArticle(opts: FeedFetchOptions & { slug: string }) => Promise<Article | null>Keyless single read. Returns null when the feed exists but the slug doesn’t. Re-exported from @ghostwritr/feed.
articleHead(article: Article, opts?: ArticleHeadOptions) => ArticleHeadDataPure function → head data (title, meta, canonical link, JSON-LD) for a custom <svelte:head>. See SEO meta.
verifyFeedSignature(opts) => Promise<boolean>Verify a signed feed.updated webhook before acting on it. See Instant updates. Re-exported from @ghostwritr/feed.
ExportKindNotes
ArticleHeadSvelte componentRenders articleHead output into <svelte:head>. Props { article, url?, siteName?, twitterSite? }. See SEO meta.
ExportTypeNotes
DEFAULT_STATIC_BASE_URLstringThe default feed origin (feeds.ghostwritr.io). Override via FeedFetchOptions.staticBaseUrl. Re-exported from @ghostwritr/feed.
FEED_SIGNATURE_HEADERstringThe header name carrying the feed.updated signature. Re-exported from @ghostwritr/feed.
GhostwritrErrorclass extends ErrorThe single thrown error type — status: number, code: GhostwritrErrorCode | null, details?: unknown. See Error handling.
ExportNotes
FeedFetchOptions{ siteId, staticBaseUrl?, order?, ... } — the fetcher input.
ArticleThe published-article shape. See The article shape.
ArticleImageThe cover image (url, alt, width, height, srcset), or null on the article.
ArticleOrder"published-desc" (default) | "feed".
AuthorThe byline — kind: "real" | "persona" drives Person vs Organization JSON-LD.
FeedUpdatedPayloadThe verified feed.updated webhook body.
GhostwritrErrorCodeThe code union — CONFIG, NETWORK_ERROR, NOT_FOUND, RATE_LIMITED, SERVER_ERROR, INVALID_RESPONSE, …
ArticleHeadDataThe articleHead return value ({ title?, meta?, link?, script? }). Local to @ghostwritr/svelte.
ArticleHeadOptions{ url?, siteName?, twitterSite? } — the articleHead / <ArticleHead> options. Local to @ghostwritr/svelte.
import {
fetchArticles,
fetchArticle,
articleHead,
ArticleHead,
verifyFeedSignature,
DEFAULT_STATIC_BASE_URL,
FEED_SIGNATURE_HEADER,
GhostwritrError,
} from "@ghostwritr/svelte";
import type {
FeedFetchOptions,
Article,
ArticleImage,
ArticleOrder,
Author,
FeedUpdatedPayload,
GhostwritrErrorCode,
ArticleHeadData,
ArticleHeadOptions,
} from "@ghostwritr/svelte";

Renderer — @ghostwritr/svelte/article-content

Section titled “Renderer — @ghostwritr/svelte/article-content”

A separate, opt-in entry that keeps the Markdown dependencies out of data-only consumers.

ExportKindNotes
ArticleContentSvelte componentRenders markdown to sanitized HTML via {@html}. See Rendering articles.
renderMarkdown(markdown: string, opts?) => stringThe underlying synchronous Markdown → sanitized-HTML function.

<ArticleContent> props:

PropTypeDefault
markdownstring— (required)
classstringundefined
remarkPluginsPluggableListundefined (appended after remark-gfm)
rehypePluginsPluggableListundefined (appended after rehype-sanitize — trusted)

renderMarkdown(markdown, opts?) takes the same { remarkPlugins?, rehypePlugins? } and returns the sanitized HTML string.

import { ArticleContent, renderMarkdown } from "@ghostwritr/svelte/article-content";