question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

vue-remark issues with remark plugins

See original GitHub issue

Description

I tried replacing the @gridsome/source-filesystem with the new @gridsome/vue-remark, but ran into issues with remark plugins. When using the @gridsome/vue-remark with @gridsome/remark-prismjs the prism plugin is not working (not tokenizing the html output to apply styling to).

Steps to reproduce

In gridsome.config.js

module.exports = {  
  plugins: [
    {
      // Create posts from markdown files
      use: "@gridsome/vue-remark",
      options: {
        typeName: "Post",
        path: "content/posts/*.md",
        baseDir: "./content/posts",
        template: "./src/templates/Post.vue",
        remark: {
          plugins: ["@gridsome/remark-prismjs"]
        }
      }
    },  
  ],
  
  transformers: {
     remark: {
       plugins: ["@gridsome/remark-prismjs"]
     }
   }
};

Expected result

The prism plugin should add additional token classes to the html generated when using code blocks in markdown.

Actual result

The actual html looks like this (no tokenized output):

<pre><code class="language-css">
.test {
    background: none;
}
</code></pre>

Environment


Libs:
- gridsome version: 0.7.5
- @gridsome/cli version: 0.2.3


For Tooling issues:
- Node version: 11.14.0
- Platform:  Windows

Issue Analytics

  • State:open
  • Created 4 years ago
  • Reactions:1
  • Comments:18 (4 by maintainers)

github_iconTop GitHub Comments

4reactions
hjvedvikcommented, Nov 6, 2019

@danrocha I tested your repository now and it seems to work as expected 😃

Here is what I did:

  • Removed the transformers config from gridsome.config.js
  • Uncommented the plugins option on each @gridsome/vue-remark entry
  • Inserted a ## Table of Contents heading after the import statement in ./content/blog/magic-hours-will-make-photography-shine.md

And I got a nested list containing all headings below. Can you try the same and see if it works?

2reactions
kai-oswaldcommented, Nov 8, 2019

Hey @sebastianluszczek, I cloned your repository and your configuration worked after I made a change in the markdown file. Just be sure to edit the markdown file while in gridsome develop, else it will use an older cached version. I don’t know why it works like this, this is probably an additional bug worthy to report?

Config:

module.exports = {
  plugins: [  
    {
      use: "@gridsome/vue-remark",
      options: {
        typeName: "Project",
        baseDir: "./markdown/projects",
        template: "./src/templates/Project.vue",
        pathPrefix: "/projects",
        route: "/projects/:title"
      }
    },
    {
      use: "@gridsome/vue-remark",
      options: {
        typeName: "Tag",
        baseDir: "./markdown/tags",
        template: "./src/templates/Tag.vue",
        pathPrefix: "/blog/tags"
      },
    },  
    {
      use: "@gridsome/vue-remark",
      options: {
        typeName: "Post",
        baseDir: "./markdown/posts",
        template: "./src/templates/Post.vue",
        pathPrefix: "/posts",
        route: "/blog/:slug",
        refs: {
          tags: "Tag"
        },
        plugins: ["@gridsome/remark-prismjs"]
      }
    },
  ]

}

Generated HTML:

<pre class="language-js"><code class="language-js"><span class="token comment">// src/index.jse</span>

<span class="token keyword">import</span> express <span class="token keyword">from</span> <span class="token string">"express"</span><span class="token punctuation">;</span>

<span class="token keyword">const</span> app <span class="token operator">=</span> <span class="token function">express</span><span class="token punctuation">(</span><span class="token punctuation">)</span><span class="token punctuation">;</span>

app<span class="token punctuation">.</span><span class="token function">listen</span><span class="token punctuation">(</span><span class="token number">5000</span><span class="token punctuation">,</span> <span class="token punctuation">(</span><span class="token punctuation">)</span> <span class="token operator">=&gt;</span> <span class="token punctuation">{</span>
  console<span class="token punctuation">.</span><span class="token function">log</span><span class="token punctuation">(</span><span class="token string">"Server started on port 5000!"</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
<span class="token punctuation">}</span><span class="token punctuation">)</span><span class="token punctuation">;</span></code></pre>
Read more comments on GitHub >

github_iconTop Results From Across the Web

gridsome/vue-remark
Insert the <VueRemarkContent> component where you want to show the Markdown content. module.exports = { plugins: [ { use: '@gridsome/vue-remark', ...
Read more >
How To add Code Highlighting To Gridsome Using Prismjs
This is a guide on how to enable or add code syntax highlighting to a gridsome blog using the prisimjs via the @gridsome/remark-prismjs...
Read more >
Creating blog post images automatically for Gridsome
Vue-Remark plugin config. The important part of the configuration for generating blog cover images is the typeName - for more details on configuring...
Read more >
@gridsome/vue-remark examples - CodeSandbox
Learn how to use @gridsome/vue-remark by viewing and forking @gridsome/vue-remark example apps on CodeSandbox.
Read more >
vue-remark - npm Package Health Analysis | Snyk
While scanning the latest version of vue-remark, we found that a security review is needed. A total of 1 vulnerabilities or license issues...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found