daKmoR / rocket

Move to https://github.com/modernweb-dev/rocket/
MIT License
13 stars 5 forks source link

Unable to add mermaid remark plugin #122

Open bennypowers opened 3 years ago

bennypowers commented 3 years ago

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 commented 3 years ago

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

bennypowers commented 3 years ago

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