Comments (7)
@juliomrqz Thanks for your explanation.
Will work on it soon then!
from content.
Thank you for your comments and feedback @juliomrqz
Beautiful website BTW!
from content.
Hey @juliomrqz,
We're considering this option indeed.
Juste to make sure, do you have any example of something you can do with a rehype plugin but not with remark?
Thanks!
from content.
In my blog, I use math equations in TeX format (an example article here https://marquez.co/blog/probabilities-and-uncertainty). The easy way to support this, it's using an official remark
plugin remark-math, but it's required to use one of these official rehype
plugins to work properly: rehype-katex or rehype-mathjax.
I managed to make them work with the latest version of @nuxt/content
but I had to apply this hack for rehype-katex
:
// nuxt.config.js
import rehypeKatex from 'rehype-katex'
import visit from 'unist-util-visit'
export default {
//....
hooks: {
'content:file:beforeInsert': (document) => {
if (document.extension === '.md') {
const transformMath = rehypeKatex()
visit(document.body, 'element', (element) => {
element.properties = element.props
})
transformMath(document.body)
visit(document.body, 'element', (element) => {
element.props = element.properties
element.tag = element.tagName || element.tag
delete element.properties
delete element.tagName
})
}
},
},
//...
}
Fortunately, for this case, it was not a complicated hack.
Other rehype
plugins can improve the developer's experience, for example:
- If you want to add TailwindCSS classes for some HTML tags, you can easily use rehype-add-classes
- For advanced HTML minifications, rehype-minify seems to be a good choice.
from content.
@benjamincanac. Another example is to easily support responsive tables if it's being used a bootstrap-lie approach https://getbootstrap.com/docs/4.5/content/tables/#responsive-tables
// nuxt.config.js
export default {
content: {
rehypePlugins: ["rehype-wrap", "rehype-add-classes"],
rehypeWrap: {
selector: "table",
wrapper: "div.table-responsive",
},
rehypeAddClasses: {
table: "table table-hover",
},
},
};
Maybe this example can be included in the Docs for advanced usage.
from content.
In nuxt/content v1.14.0, rehype-add-classes
worked well with the following writing style.
// nuxt.config.js
export default {
content: {
markdown: {
rehypePlugins: [
['rehype-add-classes', { table: 'table' }]
]
}
},
}
from content.
Just as a side node for others looking on how to use the rehype-wrap
plugin with nuxt: It does only wrap the first occurrence. so the table
example will only wrap the first table in a content document.
from content.
Related Issues (20)
- No queryContent from yml files when compatibility version 4 HOT 2
- Upgrade to @nuxt/content 2.13.1 breaks static page generation HOT 7
- Highlight content (shiki) not working HOT 6
- @nuxt/content 2.13.1 -> ERROR [unhandledRejection] connect ECONNREFUSED 127.0.0.1:49363 HOT 23
- docs(bugs): content.nuxt.com is 404 error HOT 2
- respectPathCase in defineTransformer() HOT 1
- Experimental Search: splitPageIntoSections fails if file does not have description
- [Landing] - Design review
- want some magic ? An image is switched with another one on client side HOT 2
- Add Default Language Field to Nuxt Config for Shiki Code Highlighting HOT 1
- bug: home page layout shift
- Can't Access Nuxt Studio Data in Frontend of Application HOT 1
- Error on Nuxt Content for Static Site Generation : Document not found, overwrite this content with #not-found slot in <ContentDoc>. HOT 1
- When I set useHead in app.vue, the webpage title does not change after leaving the content-related page
- bug(search): unicode characters display wrong on indexed mode HOT 1
- Unwanted class added on anchor links when target="_self"
- Image path changed in when linking images in markdown content
- queryContent matches on start of path not directory name
- Unable to install nuxt with @nuxt/content with pnpm
- Unable to start project after creation (#internal/nitro/virtual/app-config is not defined) HOT 2
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
π Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. πππ
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google β€οΈ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from content.