Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Docusaurus integration not working #171

Open
vecerek opened this issue Nov 3, 2022 · 4 comments
Open

Docusaurus integration not working #171

vecerek opened this issue Nov 3, 2022 · 4 comments

Comments

@vecerek
Copy link

vecerek commented Nov 3, 2022

Hi there 👋 I'm trying to build a documentation site with this amazing tool. However upon following the getting started bootstrap from docusaurus and the shiki-twoslash setup for docusaurus, and having the following markdown page:

---
title: Markdown page example
---

# Markdown page example

You don't need React to write simple standalone pages.

```ts twoslash
const a = 123
// ---cut---
const b = 321
``` <!-- I cannot render this example properly without adding this HTML comment -->

My content gets rendered like this:

Screenshot 2022-11-03 at 16 11 21

Have I missed something?

@vecerek
Copy link
Author

vecerek commented Nov 3, 2022

Oh, wait a second... This does not work on a regular page but it does work in a page nested under /docs. Is this the expected behavior?

@felipecrs
Copy link

The same thing is observed here. Works for /docs, /blog but not for regular markdown pages or docs under different routes.

@felipecrs
Copy link

I created an example to illustrate the problem:

https://github.com/felipecrs/shiki-docusaurus-test

@lachieh
Copy link

lachieh commented Nov 15, 2023

I resolved this by specifying the plugin within all three preset-config sections, as well as in the top-level preset section.

import remarkShikiTwoSlash, { Options as RemarkShikiTwoslashOptions } from 'remark-shiki-twoslash'
const remarkShikiOptions: RemarkShikiTwoSlashOptions = {
  themes: ['github-light', 'github-dark'],
  // more shiki options
};

export default {
  presets: [
    [
      'classic',
      {
        docs: {
          // ...
          beforeDefaultRemarkPlugins: [[remarkShikiTwoSlash, remarkShikiOptions]],
        },
        pages: {
          // ...
          beforeDefaultRemarkPlugins: [[remarkShikiTwoSlash, remarkShikiOptions]],
        },
        blog: {
          // ...
          beforeDefaultRemarkPlugins: [[remarkShikiTwoSlash, remarkShikiOptions]],
        },
      }
    ],
    ['docusaurus-preset-shiki-twoslash', remarkShikiOptions]
    // ... rest of config

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants