npm.io
0.2.3 • Published 6h ago

@rankveo/sveltekit

Licence
MIT
Version
0.2.3
Deps
1
Size
30 kB
Vulns
0
Weekly
0

@rankveo/sveltekit

Run your rankveo blog on a SvelteKit site.

npm install @rankveo/sveltekit

Keep the client in a .server.ts module. SvelteKit refuses to bundle $env/dynamic/private into anything reachable from the browser, and separating it is what keeps that guard satisfied:

// src/lib/rankveo.server.ts
import { BlogClient } from '@rankveo/sveltekit';
import { env } from '$env/dynamic/private';

export const blog = new BlogClient({ apiKey: env.RANKVEO_BLOG_API_KEY });

Client-safe constants (base path, page size) belong in a separate rankveo.ts that components can import.

Starter

cp -r node_modules/@rankveo/sveltekit/starter/src/* src/

Routes: /blog/[[page]], /blog/[slug], /blog/tag/[slug]/[[page]], /blog/sitemap.xml, /blog/rss.xml.

Add the sitemap to your prerender entries, since nothing links to it:

// svelte.config.js
kit: { prerender: { entries: ['/blog', '/blog/sitemap.xml'] } }

Two things that will bite you otherwise

Pagination is path-based, not ?page=. A prerendered page cannot read url.searchParams — SvelteKit throws, because a static file cannot vary by query string.

entries is required for dynamic routes. SvelteKit only prerenders what it can crawl to, and a paginated blog hides most articles behind later pages. articleEntries(blog) declares them all.

Keeping it fresh

A prerendered blog has no runtime cache — point rankveo at your host's deploy hook so publishing triggers a rebuild.

Rendering on demand instead? Copy the revalidate endpoint from starter/server/. It is not in the default starter because a POST route cannot be prerendered, and adapter-static fails with Encountered dynamic routes.


Docs and setup guide · All integrations

MIT.

Keywords