content icon indicating copy to clipboard operation
content copied to clipboard

Custom markdown styles

Open augnustin opened this issue 2 years ago • 2 comments

Is your feature request related to a problem? Please describe

I would like to apply custom styles to all the markdown generated content in my app.

Describe the solution you'd like

I would like to have an HTML class applied to a wrapper of the component <ContentDoc /> . It would produce like

<div class="nuxt-content nuxt-content-markdown">
  <!-- Markdown content -->
</div>

And global styles like:

.nuxt-content-markdown {
  font-size: 1.2rem;
  a {
    color: green;
  }
}

Describe alternatives you've considered

I'm aware it is possible to customize markdown tags through the Prose options, which is amazingly powerful, but kind of overkill here. Unless it offers the possibility to customize a <Wrapper /> component that would surround the markdown content.

Another option would be to create myself a <ContentDocWrapper /> component that would forward all props and slots, but I'm not comfortable enough with this nuxt-content to make sure this wouldn't produce any unexpected side-effect.

Additional context

Eventually, make this class name customizable in the nuxt.config.js.

augnustin avatar Feb 27 '23 15:02 augnustin

You can simply pass class to ContentDoc component <ContentDoc calss="nuxt-content-markdow" /> where you use it.

If you are using Document Driven mode, all you need it to create a catch-all page inside your pages directory [...slug].vue and override Document-Driven page. Checkout default document-driven page: https://github.com/nuxt/content/blob/main/src/runtime/pages/document-driven.vue

farnabaz avatar Mar 08 '23 12:03 farnabaz

if I added scoped in the style tag of [...slug].vue, the style doen't work, why is that?

randomseed42 avatar Aug 09 '24 10:08 randomseed42

This issue is stale because it has been open 60 days with no activity. Remove stale label or comment or this will be closed in 30 days.

github-actions[bot] avatar Jan 09 '25 16:01 github-actions[bot]

This issue was closed because it has been stalled for 30 days with no activity.

github-actions[bot] avatar Feb 08 '25 17:02 github-actions[bot]