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

Unable to add mermaid remark plugin #122

Open
bennypowers opened this issue Dec 7, 2020 · 2 comments
Open

Unable to add mermaid remark plugin #122

bennypowers opened this issue Dec 7, 2020 · 2 comments

Comments

@bennypowers
Copy link
Collaborator

Using this config:

import { rocketLaunch } from '@d4kmor/launch';

import remarkMermaid from 'remark-mermaid';

console.log(remarkMermaid); // [Function: mermaid]

export default {
  themes: [rocketLaunch()],
  setupUnifiedPlugins: [
    function addMermaid(plugins) {
      if (plugins.findIndex(plugin => plugin.name === 'remark-mermaid') === -1) {
        const insertAfterIndex =
          plugins.findIndex(plugin => plugin.name === 'remark2rehype');
          // plugins.findIndex(plugin => plugin.name === 'markdown'); // also doesn't work
        plugins.splice(insertAfterIndex + 1, 0, {
          name: 'remark-mermaid',
          plugin: remarkMermaid,
        });
      }
      return plugins;
    },
  ],
};

I got this error:

Problem writing Eleventy templates: (more in DEBUG output)
> Having trouble rendering liquid (and markdown) template ./docs/guides/using apollo/local-state/advanced-local-state.md

`TemplateContentRenderError` was thrown
> Unknown language: `mermaid` is not registered
stack trace
`Error` was thrown:
    Error: Unknown language: `mermaid` is not registered
        at Refractor.highlight (/Users/bennyp/Documents/apollo-elements/node_modules/refractor/core.js:115:13)
        at visitor (/Users/bennyp/Documents/apollo-elements/node_modules/rehype-prism-template/index.js:30:26)
        at overload (/Users/bennyp/Documents/apollo-elements/node_modules/unist-util-visit/index.js:27:12)
        at one (/Users/bennyp/Documents/apollo-elements/node_modules/unist-util-visit-parents/index.js:34:25)
        at all (/Users/bennyp/Documents/apollo-elements/node_modules/unist-util-visit-parents/index.js:57:16)
        at one (/Users/bennyp/Documents/apollo-elements/node_modules/unist-util-visit-parents/index.js:42:28)
        at all (/Users/bennyp/Documents/apollo-elements/node_modules/unist-util-visit-parents/index.js:57:16)
        at one (/Users/bennyp/Documents/apollo-elements/node_modules/unist-util-visit-parents/index.js:42:28)
        at visitParents (/Users/bennyp/Documents/apollo-elements/node_modules/unist-util-visit-parents/index.js:26:3)
        at visit (/Users/bennyp/Documents/apollo-elements/node_modules/unist-util-visit/index.js:22:3)
Using pathPrefix: /_site-dev
Copied 30 files / Wrote 0 files in 7.10 seconds (v0.11.1)

I'm not sure if this is something special about mermaid, if the underlying setupUnifiedPlugins needs a patch, or if I'm doing it wrong

@daKmoR
Copy link
Owner

daKmoR commented Dec 7, 2020

do you have an example of the markdown using the mermaid code block?

@bennypowers
Copy link
Collaborator Author

https://github.com/apollo-elements/apollo-elements/blob/master/pages/advanced-local-state.md

<meta name="description" content="Some advanced recipes for Apollo Elements to manage local state"/>

blah blah blah

This mutation requires an input which is a list of site IDs. In order to provide that list, our user will click on the checkboxes in the list of `<select-item>`s. This in turn will write to that `Site`'s client-side `selected @client` field on `Site`, which in turn will be read to determine whether a site's corresponding `<select-item>` component will be marked selected: Whenever the user clicks on an item in the list, `onSelectItem` writes the new selected state to the cache for that Site.

```mermaid
sequenceDiagram
    participant CA as Apollo Cache
    participant UI as <all-sites>
    participant OL as <select-item>
    CA->>UI: AllSitesQuery
    UI-->>OL: Property Assignment
    OL->>UI: MouseEvent
    UI-->>CA: writeFragment
```

Then, when the user is ready to create the Network, she clicks the `Create` button, and the component issues the mutation over the network with variables based on the currently selected sites.

blah blah blah

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

2 participants