If you don't want to install Wordpress, or build your own admin backend. If you don't want to handle user records or authentication, and the database would only be used for content anyway, we've got you.
api_key
2 files
and a folderYour /src/routes/
folder should end up looking like this:
[...slug]
folderAdd a magic Svelte folder titled [...slug]
to catch all urls you want to content enable, and place a blank +page.svelte (yes, completely empty) file in it to trigger the Svelte router.
Alternatively place the folder under e.g. /blog/
if you only want a sub-directory powered by Pullnote.
Note: anything with a specific route will still work - only pages not already in your repo will look to the CMS.
+layout.server.js
This file gets run server-side by SvelteKit and pulls the content for whatever page has been routed to from the Pullnote API
export async function load({url, params}) {
const PULLNOTE_KEY = "PUT_YOUR_API_KEY_HERE";
var res = await fetch("https://pullnote.com/pull/note" + url.pathname, {
headers: {
"Content-Type": "application/json; charset=utf-8",
"pn_authorization": "Bearer " + PULLNOTE_KEY
}
});
return await res.json();
}
+layout.svelte
Or if you already have one, add to it. This places the HTML and header data into the page. Add some styling too!
<script>
import "../app.css";
export let data;
$: note = data;
</script>
<svelte:head>
{@html note.head_html}
</svelte:head>
<img src={note.img.src} alt={note.img.alt} class="rounded-xl" />
{#if note._id}
{@html note.content_html}
{:else}
<!-- This keeps non-pullnote folders working -->
<slot />
{/if}
<!-- Basic menu for other notes in the same folder -->
<ul>
{#each note.links as subnote}
<li><a href={subnote.href}>{subnote.title}</a></li>
{/each}
</ul>
npm run dev
should give you a url to kick off in your browser. Visit any pages you've set up on the CMS side and rejoice.