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:
npm install leblog
In vite.config.js
:
... import leblog from 'leblog' export default defineConfig({ plugins: [leblog(), ...] })
In the posts
directory at the root of your project write markdown files with
yyyy-mm-dd-{slug}.md
-formatted filenames.
--- title: my epic post --- the title says it all
On any page or in any component:
<script> import { load } from 'leblog' const posts = load('posts') </script> <ul> {#each posts as post} <li> <h2>{post.title}</h2> {@html post.html} </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):
leblog
plugin would hang indefinitely; no longer!export default {
collections: {
posts: {
path: 'posts',
feed: 'blog.atom'
},
changelog: 'CHANGELOG.md'
}
}
And as if by magic, a /blog.atom
route will exist on your website with an Atom feed of all your posts (RSS and JSON also work; just change the file extension).
2023-06-03.md
).path
property which you can use for linking pages, which will be the date combined with the slug if there is one. Using the slug
property alone still works, in case you don't want the date displayed in the URL.GET
request handler from a page's +server.js
:import { loadFeed } from 'leblog'
export const GET = loadFeed('posts')
html
field with — you guessed it! — the entry's HTML.@sveltejs/kit
and svelte
dependencies are now set correctly.Entry
is now exported from leblog
instead of leblog/entry
(conditional exports ftw).loadCollection
, loadEntry
and load
now run on the server in +page.server.js
endpoints, removing the need for a handle hook.Entry
component is now exported from leblog/entry
..md
) are now considered entries.leblog
hook, which is replaced by the aforementioned load functions.load
function to infer a collection/entry, assuming there's only one defined collection.slug
parameter to loadEntry
, so you can override the default params.slug
.handle
alias of leblog
, so in hooks.server.js
you can simply: export { handle } from 'leblog/hooks'
.The first release!
Made with ❤️ by nbgoodall