Skip to content

Instantly share code, notes, and snippets.

@shnam7
Last active January 14, 2023 10:27
Show Gist options
  • Select an option

  • Save shnam7/1ac4cfd302f39b775f80a62c1faf9994 to your computer and use it in GitHub Desktop.

Select an option

Save shnam7/1ac4cfd302f39b775f80a62c1faf9994 to your computer and use it in GitHub Desktop.
Create svelte-sass-markdown project
# create svelte project using sveltekit
pnpm create svelte@latest my-app
# add markdonw support using svelte-add tool
# https://github.com/svelte-add/mdsvex
pnpx svelte-add@latest mdsvex
# add prism css link from cdn:
# add following contents to /src/routes/+layout.svelte
```svelte
<svelte:head>
<!-- include code highligh style from a cdn link -->
<link
rel="stylesheet"
href="https://cdnjs.cloudflare.com/ajax/libs/prism/1.29.0/themes/prism-tomorrow.min.css"
integrity="sha512-vswe+cgvic/XBoF1OcM/TeJ2FW0OofqAVdCZiEYkd6dwGXthvkSFWOoGGJgS2CW70VK5dQM5Oh+7ne47s74VTg=="
crossorigin="anonymous"
referrerpolicy="no-referrer"
/>
</svelte:head>
```
# optionally change the project to static (for github docs, for example)
# first, create /src/routes/+layout.js with following contents
```
export const prerender = true;
```
# secondly, replace adapter-auto to adapter-static in svelte,config.js
# this requires installaing @sveltejs/adapter-static
pnpm remove @sveltejs/adapter-auto
pnpm i -D @sveltejs/adapter-static
# optionally, add sass-wdk library and set alias to the source
pnpm i -D sass-wdk
#update svelte.config.js with "alias" field:
```
const config = {
extensions: [".svelte", ...mdsvexConfig.extensions],
// Consult https://kit.svelte.dev/docs/integrations#preprocessors
// for more information about preprocessors
preprocess: [vitePreprocess(), mdsvex(mdsvexConfig)],
kit: {
adapter: adapter(),
alias: {
"sass-wdk": "./node-modules/sass-wdk",
},
},
};
```
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment