Skip to content

Commit

Permalink
docs: replace sapper docs with shiki docs
Browse files Browse the repository at this point in the history
  • Loading branch information
benmccann committed Aug 14, 2024
1 parent c12dd3b commit 5094057
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 12 deletions.
35 changes: 24 additions & 11 deletions packages/site/src/routes/_docs.svtext
Original file line number Diff line number Diff line change
Expand Up @@ -662,21 +662,34 @@ Frontmatter also interacts with layouts, you can find more details in the [Layou

## Integrations

### With Sapper
### With shiki

To use mdsvex with sapper you need to add the mdsvex configuration to both the client and server sections of the rollup or webpack configuration. You will also need to add the CLI argument `--ext '.svelte .svx'` to all of the sapper scripts (`dev`, `build`, and `export`) in order to tell sapper that it should also allow `.svx` files to be page routes.
You can use shiki for highlighting rather than prism by leveraging the `highlighter` option:

Or you can use the templates:
- [Rollup](https://github.com/pngwn/sapper-mdsvex-template)
```js
import { mdsvex, escapeSvelte } from 'mdsvex';
import { createHighlighter } from 'shiki';

```bash
npx degit "pngwn/sapper-mdsvex-template" my-app
```
- [Webpack](https://github.com/shiryel/sapper-mdsvex-template-webpack)
const theme = 'github-dark';
const langs = ['javascript', 'typescript'];
const highlighter = await createHighlighter({
themes: [theme],
langs
});
for (const lang of langs) {
await highlighter.loadLanguage(lang);
}

```bash
npx degit "shiryel/sapper-mdsvex-template-webpack" my-app
```
/** @type {import('mdsvex').MdsvexOptions} */
const mdsvexOptions = {
highlight: {
highlighter: async (code, lang = 'text') => {
const html = escapeSvelte(highlighter.codeToHtml(code, { lang, theme }));
return `{@html \`${html}\` }`;
}
},
}
```

## Limitations

Expand Down
2 changes: 1 addition & 1 deletion packages/site/src/routes/docs/+page.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@
[
'Integrations',
'docs#integrations',
[['sapper', 'docs#with-sapper', false]],
[['shiki', 'docs#with-shiki', false]],
],
['Limitations', 'docs#limitations'],
];
Expand Down

0 comments on commit 5094057

Please sign in to comment.