Skip to content

Commit f0961fd

Browse files
authored
Update README.md
1 parent b723fcf commit f0961fd

File tree

1 file changed

+60
-1
lines changed

1 file changed

+60
-1
lines changed

README.md

Lines changed: 60 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,61 @@
11
# gatsby-remark-classes
2-
Automatically add class attributes to markdown elements
2+
Automatically add class attributes to markdown elements.
3+
4+
This is a plugin for [gatsby-transformer-remark](https://www.gatsbyjs.org/packages/gatsby-transformer-remark/?=gatsby-transformer-remark).
5+
6+
## Install
7+
```
8+
npm install --save gatsby-remark-classes
9+
```
10+
11+
## Configure
12+
In your `gatsby-config.js`:
13+
14+
```js
15+
{
16+
resolve: `gatsby-transformer-remark`,
17+
options: {
18+
plugins: [
19+
{
20+
resolve: `gatsby-remark-classes`,
21+
options: {
22+
classMap: {
23+
h1: 'title',
24+
h2: 'subtitle',
25+
paragraph: 'para'
26+
}
27+
}
28+
}
29+
]
30+
}
31+
}
32+
```
33+
34+
The rules above applied to the following markdown
35+
36+
```markdown
37+
# Main heading
38+
Lorem ipsum dolor sit amet, consectetur adipisicing elit. Eum, odio.
39+
40+
## Sub header
41+
Lorem ipsum dolor sit amet, consectetur adipisicing.
42+
```
43+
44+
Will result in this HTML output:
45+
46+
```html
47+
<h1 class="title">Main heading</h1>
48+
<p class="para">Lorem ipsum dolor sit amet, consectetur adipisicing elit. Eum, odio.</p>
49+
50+
<h2 class="subtitle">Sub header</h2>
51+
<p class="para">Lorem ipsum dolor sit amet, consectetur adipisicing.</p>
52+
```
53+
54+
## The classMap
55+
Right now you can add styles for **heading** elements (h1 - h6), **paragraphs** and **tables**.
56+
57+
## Motivation
58+
59+
Applying custom styles is also possible by just wrapping your converted markdown in a parent element and write the styles for that. This will however not work if you use atomic css in your project or a framework like Semantic UI or Tailwind CSS.
60+
61+
With this project you define which classes get assigned to which element.

0 commit comments

Comments
 (0)