├── src
├── global.d.ts
├── routes
│ ├── contact.md
│ └── index.md
├── metadata.js
├── layouts
│ └── default.svelte
└── app.html
├── .gitignore
├── static
├── favicon.png
└── admin
│ ├── index.html
│ └── config.yml
├── netlify.toml
├── jsconfig.json
├── mdsvex.config.js
├── package.json
├── svelte.config.js
└── README.md
/src/global.d.ts:
--------------------------------------------------------------------------------
1 | ///
2 |
--------------------------------------------------------------------------------
/.gitignore:
--------------------------------------------------------------------------------
1 | .DS_Store
2 | node_modules
3 | /build
4 | /.svelte-kit
5 | /package
6 |
--------------------------------------------------------------------------------
/static/favicon.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/buhrmi/sveltekit-netlify-cms/HEAD/static/favicon.png
--------------------------------------------------------------------------------
/src/routes/contact.md:
--------------------------------------------------------------------------------
1 | ---
2 | label: Contact
3 | title: Contact Us
4 | ---
5 |
6 | This is where the contact form will go
--------------------------------------------------------------------------------
/netlify.toml:
--------------------------------------------------------------------------------
1 | [build]
2 | command = "npm run build"
3 | publish = "build"
4 |
5 | [dev]
6 | command = "svelte-kit dev"
7 |
8 | [functions]
9 | directory = "netlify/functions"
10 | node_bundler = "esbuild"
--------------------------------------------------------------------------------
/jsconfig.json:
--------------------------------------------------------------------------------
1 | {
2 | "compilerOptions": {
3 | "baseUrl": ".",
4 | "paths": {
5 | "$lib": ["src/lib"],
6 | "$lib/*": ["src/lib/*"]
7 | }
8 | },
9 | "include": ["src/**/*.d.ts", "src/**/*.js", "src/**/*.svelte"]
10 | }
11 |
--------------------------------------------------------------------------------
/mdsvex.config.js:
--------------------------------------------------------------------------------
1 | const config = {
2 | "extensions": [".svelte.md", ".md", ".svx"],
3 |
4 | "smartypants": {
5 | "dashes": "oldschool"
6 | },
7 | "layout": {
8 | _: "./src/layouts/default.svelte"
9 | },
10 | "remarkPlugins": [],
11 | "rehypePlugins": []
12 | };
13 |
14 | export default config;
--------------------------------------------------------------------------------
/package.json:
--------------------------------------------------------------------------------
1 | {
2 | "name": "~TODO~",
3 | "version": "0.0.1",
4 | "scripts": {
5 | "dev": "svelte-kit dev",
6 | "build": "svelte-kit build",
7 | "preview": "svelte-kit preview"
8 | },
9 | "devDependencies": {
10 | "@sveltejs/adapter-netlify": "^1.0.0-next.29",
11 | "@sveltejs/kit": "next",
12 | "mdsvex": "^0.9.8",
13 | "svelte": "^3.34.0"
14 | },
15 | "type": "module"
16 | }
17 |
--------------------------------------------------------------------------------
/src/metadata.js:
--------------------------------------------------------------------------------
1 | const modules = Object.entries(import.meta.globEager("./routes/**/*.md"));
2 |
3 | const getRoutes = () => {
4 | return modules.map(([file, module]) => {
5 | const path = file
6 | .replace("./routes/", "/")
7 | .replace("index", "")
8 | .replace(".md", "");
9 |
10 | return {
11 | path,
12 | ...module.metadata,
13 | };
14 | });
15 | };
16 |
17 | export { getRoutes };
18 |
--------------------------------------------------------------------------------
/src/layouts/default.svelte:
--------------------------------------------------------------------------------
1 |
8 |
9 |
10 | {title}
11 |
12 |
13 |
14 |
15 | {#each routes as route}
16 |
17 | {route.title}
18 |
19 | {/each}
20 |
21 |
22 |
23 |
24 |
--------------------------------------------------------------------------------
/static/admin/index.html:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 | Content Manager
7 |
8 |
9 |
10 |
11 |
12 |
13 |
--------------------------------------------------------------------------------
/static/admin/config.yml:
--------------------------------------------------------------------------------
1 | backend:
2 | name: git-gateway
3 | branch: main
4 | collections:
5 | - name: routes
6 | label: routes
7 | folder: src/routes
8 | create: true
9 | fields:
10 | - name: title
11 | - name: nav_label
12 | - name: body
13 | widget: markdown
14 | media_folder: "static/uploads"
15 | public_folder: "/uploads"
16 |
17 | # site_url: https://your-site.com
18 | # display_url: https://your-site.com
19 | # logo_url: https://your-site.com/images/logo.svg
--------------------------------------------------------------------------------
/svelte.config.js:
--------------------------------------------------------------------------------
1 | import { mdsvex } from "mdsvex";
2 | import mdsvexConfig from "./mdsvex.config.js";
3 | import adapter from '@sveltejs/adapter-netlify'
4 |
5 | const config = {
6 | kit: {
7 | adapter: adapter(), // currently the adapter does not take any options
8 | target: '#svelte',
9 | prerender: {
10 | crawl: true,
11 | enabled: true,
12 | onError: 'continue',
13 | entries: ['*'],
14 | },
15 | },
16 | extensions: [".svelte", ...mdsvexConfig.extensions],
17 | preprocess: [mdsvex(mdsvexConfig)]
18 | };
19 |
20 | export default config;
21 |
--------------------------------------------------------------------------------
/src/routes/index.md:
--------------------------------------------------------------------------------
1 | ---
2 | label: Home
3 | title: SvelteKit Netlify CMS
4 | ---
5 |
6 | # Welcome to the SvelteKit Netlify CMS example
7 |
8 | This is the [`/routes/index.md`](https://github.com/buhrmi/sveltekit-netlify-cms/blob/main/src/routes/index.md) file, which is preprocessed by [mdsvex](https://mdsvex.com) and is editable through Netlify CMS
9 |
10 | [](https://app.netlify.com/start/deploy?repository=https://github.com/buhrmi/sveltekit-netlify-cms&stack=cms) or [view repo](https://github.com/buhrmi/sveltekit-netlify-cms)
--------------------------------------------------------------------------------
/src/app.html:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 | %svelte.head%
9 |
10 |
11 | %svelte.body%
12 |
23 |
24 |
25 |
--------------------------------------------------------------------------------
/README.md:
--------------------------------------------------------------------------------
1 | # sveltekit-netlify-cms
2 |
3 | A SvelteKit skeleton app with Netlify CMS living in `/admin`. Netlify CMS is configured to directly edit `/routes/*.md` files, which are preprocessed by [mdsvex](https://mdsvex.com).
4 |
5 |
6 |
7 | [Demo](https://sveltekit-netlify-cms.netlify.app)
8 |
9 | ## Developing
10 |
11 | Once you've downloaded this repo and installed dependencies with `npm install` (or `pnpm install` or `yarn`), start a development server:
12 |
13 | ```bash
14 | npm run dev
15 |
16 | # or start the server and open the app in a new browser tab
17 | npm run dev -- --open
18 | ```
19 |
20 | ## Building
21 |
22 | To create the production version of your app, run:
23 |
24 | ```bash
25 | npm run build
26 | ```
27 |
28 | > You can preview the built app with `npm run preview`. However, this should _not_ be used to serve your app in production.
29 |
--------------------------------------------------------------------------------