leblog

add a blog (or changelog) to any SvelteKit site

leblog is made to quickly add a blog (or blogs) to new and existing SvelteKit sites.

Its raison d'être is that I (Nick) wanted to keep changelogs for my SvelteKit projects without the fanfare of signing up for something or adding boilerplate.

It is not:

  • A fully-featured CMS like Strapi, Ghost or Tina.
  • A replacement for Substack.

quick start

npm install leblog

1. write

In src/posts write markdown files with yyyy-mm-dd-{slug}.md-formatted filenames.

---
title: my epic post
---

the title says it all

2. load

In +page.server.js:

export { load } from 'leblog'

3. render

In its sibling +page.svelte:

<script>
  import { Entry } from 'leblog'

  /** @type {import('./$types').PageData} */
  export let data
</script>

<ul>
  {#each data.posts as entry}
    <li>
      <h2>{entry.title}</h2>

      <Entry {entry} />
    </li>
  {/each}
</ul>

Et voila! Full documentation is on github, and you can see it in action on the demo page. Single-file changelogs also work, like this one (source):

changelog

  • 0.5.0 wed mar 08 2023

    Added

    • You can now create Atom and RSS feeds! To do so, export a GET request handler from a page's +server.js:
    import { loadFeed } from 'leblog'
    
    export const GET = loadFeed('posts')
    
    • Entries now contain an html field with — you guessed it! — the entry's HTML.
  • 0.4.3 tue mar 07 2023

    Fixed

    • @sveltejs/kit and svelte dependencies are now set correctly.
  • 0.4.2 fri feb 24 2023

    Changed

    • Entry is now exported from leblog instead of leblog/entry (conditional exports ftw).
  • 0.3.1 thu feb 23 2023

    Changed

    • loadCollection, loadEntry and load now run on the server in +page.server.js endpoints, removing the need for a handle hook.
    • The Entry component is now exported from leblog/entry.

    Fixed

    • Only markdown files (.md) are now considered entries.

    Removed

    • The leblog hook, which is replaced by the aforementioned load functions.
  • 0.2.0 thu feb 23 2023

    Added

    • A load function to infer a collection/entry, assuming there's only one defined collection.
    • Added an optional second slug parameter to loadEntry, so you can override the default params.slug.
    • An exported handle alias of leblog, so in hooks.server.js you can simply: export { handle } from 'leblog/hooks'.
  • 0.1.0 wed feb 22 2023

    The first release!

Made with ❤️ by nbgoodall