Instructions heavily based on this article.
- Create project:
npm init svelte@next app-name
- Choose
Skeleton App
- Default: say no to the options (or not)
- Type checking: None
- ESLint: No
- Prettier: No
- Playwright: No
- Choose
- Install the things:
npm install
- Create global page template (SK layout):
src/routes/__layout.svelte
. - Add global stylesheet(s) to project:
src/lib/styles/main.css
- Styles can go anywhere?
- Import
main.css
into__layout.svelte
<!-- __layout.svelte --> <script> import '$lib/styles/style.css' </script>
- Create routes. Examples:
src/routes/index.svelte
src/routes/about.svelte
src/routes/[whatevs]/index.svelte
Best option I can find: mdsvex
.
- Install
$ npm i -D mdsvex svelte-preprocess
- Configure
import sveltePreprocess from 'svelte-preprocess' import { mdsvex } from 'mdsvex' const config = { kit: { /* Kit options here */ }, extensions: ['.svelte', '.md'], preprocess: [ sveltePreprocess(), mdsvex({ extensions: ['.md'] }) ] }
-
Add a custom layout that auto adds the date as a level one heading to a blog entry.
- Create
routes/blog/_post.svelte
// svelte.config.js /* Imports here */ const config = { /* ...Other config properties here */ preprocess: [ sveltePreprocess(), mdsvex({ extensions: ['.md'], layout: { journal: 'src/routes/blog/_post.svelte' } }) ] }
- Create
-
To add layout content
<!-- _post.svelte --> <script> export let date </script> <h1>{date}</h1> <slot />