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).
Core — @ghostwritr/svelte
Section titled “Core — @ghostwritr/svelte”Functions
Section titled “Functions”| Export | Signature | Notes |
|---|---|---|
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) => ArticleHeadData | Pure 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. |
Components
Section titled “Components”| Export | Kind | Notes |
|---|---|---|
ArticleHead | Svelte component | Renders articleHead output into <svelte:head>. Props { article, url?, siteName?, twitterSite? }. See SEO meta. |
Values
Section titled “Values”| Export | Type | Notes |
|---|---|---|
DEFAULT_STATIC_BASE_URL | string | The default feed origin (feeds.ghostwritr.io). Override via FeedFetchOptions.staticBaseUrl. Re-exported from @ghostwritr/feed. |
FEED_SIGNATURE_HEADER | string | The header name carrying the feed.updated signature. Re-exported from @ghostwritr/feed. |
GhostwritrError | class extends Error | The single thrown error type — status: number, code: GhostwritrErrorCode | null, details?: unknown. See Error handling. |
| Export | Notes |
|---|---|
FeedFetchOptions | { siteId, staticBaseUrl?, order?, ... } — the fetcher input. |
Article | The published-article shape. See The article shape. |
ArticleImage | The cover image (url, alt, width, height, srcset), or null on the article. |
ArticleOrder | "published-desc" (default) | "feed". |
Author | The byline — kind: "real" | "persona" drives Person vs Organization JSON-LD. |
FeedUpdatedPayload | The verified feed.updated webhook body. |
GhostwritrErrorCode | The code union — CONFIG, NETWORK_ERROR, NOT_FOUND, RATE_LIMITED, SERVER_ERROR, INVALID_RESPONSE, … |
ArticleHeadData | The 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.
| Export | Kind | Notes |
|---|---|---|
ArticleContent | Svelte component | Renders markdown to sanitized HTML via {@html}. See Rendering articles. |
renderMarkdown | (markdown: string, opts?) => string | The underlying synchronous Markdown → sanitized-HTML function. |
<ArticleContent> props:
| Prop | Type | Default |
|---|---|---|
markdown | string | — (required) |
class | string | undefined |
remarkPlugins | PluggableList | undefined (appended after remark-gfm) |
rehypePlugins | PluggableList | undefined (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";