Skip to content

Commit 730e322

Browse files
merge markdown docs
1 parent 8291e7c commit 730e322

File tree

1 file changed

+126
-8
lines changed

1 file changed

+126
-8
lines changed

src/pages/docs/resources/markdown.md

Lines changed: 126 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -6,31 +6,149 @@ tocHeading: 2
66

77
# Markdown
88

9-
In this section we'll cover some of the Markdown related features of **Greenwood**, which by default supports the [CommonMark](https://commonmark.org/help/) specification and [**unifiedjs**](https://unifiedjs.com/) as the markdown / content framework.
9+
For authoring in markdown, Greenwood provides a plugin that you can install, which by default supports the [CommonMark](https://commonmark.org/help/) specification and uses [**unifiedjs**](https://unifiedjs.com/) as the markdown / content framework. See the [plugin's README](https://github.com/ProjectEvergreen/greenwood/tree/master/packages/plugin-markdown) for additional information, like standalone usage.
1010

11-
## Plugins
11+
## Installation
1212

13-
Using your _greenwood.config.js_ you can have additional [markdown customizations and configurations](/docs/reference/configuration/#markdown).
13+
You can use your favorite JavaScript package manager to install this plugin:
1414

15-
For example, to use the [**remark-github**](https://github.com/remarkjs/remark-github) plugin:
15+
<!-- prettier-ignore-start -->
16+
<app-ctc-block variant="runners">
17+
18+
```shell
19+
npm i -D @greenwood/plugin-markdown
20+
```
21+
22+
```shell
23+
yarn add @greenwood/plugin-markdown --dev
24+
```
25+
26+
```shell
27+
pnpm add -D @greenwood/plugin-markdown
28+
```
29+
30+
</app-ctc-block>
31+
32+
<!-- prettier-ignore-end -->
33+
34+
Then add this plugin to your _greenwood.config.js_.
1635

1736
<!-- prettier-ignore-start -->
1837

1938
<app-ctc-block variant="snippet" heading="greenwood.config.js">
2039

2140
```js
22-
// npm i -D remark-github
41+
import { greenwoodPluginMarkdown } from "@greenwood/plugin-markdown";
42+
2343
export default {
24-
markdown: {
25-
plugins: ["remark-github"],
26-
},
44+
plugins: [greenwoodPluginMarkdown()],
2745
};
2846
```
2947

3048
</app-ctc-block>
3149

3250
<!-- prettier-ignore-end -->
3351

52+
## Usage
53+
54+
Now you can start authoring your pages in markdown:
55+
56+
```shell
57+
src/
58+
pages/
59+
blog/
60+
first-post.md
61+
second-post.md
62+
index.md
63+
```
64+
65+
## Types
66+
67+
Types should automatically be inferred through this package's exports map, but can be referenced explicitly in both JavaScript (JSDoc) and TypeScript files if needed.
68+
69+
<!-- prettier-ignore-start -->
70+
71+
<app-ctc-block variant="snippet">
72+
73+
```js
74+
/** @type {import('@greenwood/plugin-markdown').MarkdownPlugin} */
75+
```
76+
77+
</app-ctc-block>
78+
79+
<!-- prettier-ignore-end -->
80+
81+
<!-- prettier-ignore-start -->
82+
83+
<app-ctc-block variant="snippet">
84+
85+
```ts
86+
import type { MarkdownPlugin } from '@greenwood/plugin-markdown';
87+
```
88+
89+
</app-ctc-block>
90+
91+
<!-- prettier-ignore-end -->
92+
93+
## Options
94+
95+
### Plugins
96+
97+
You can install **remark** or **rehype** compatible plugins to extend this plugin's markdown rendering and transformation capabilities by passing their names in as an array.
98+
99+
For example, after installing something like **rehype-slug**, pass the name as a string when adding the plugin to your Greenwood config file:
100+
101+
<!-- prettier-ignore-start -->
102+
103+
<app-ctc-block variant="snippet" heading="greenwood.config.js">
104+
105+
```js
106+
import { greenwoodPluginMarkdown } from '@greenwood/plugin-markdown';
107+
108+
export default {
109+
plugins: [
110+
greenwoodPluginMarkdown({
111+
// npm i -D rehype-slug
112+
plugins: [
113+
"rehype-slug"
114+
],
115+
})
116+
]
117+
}
118+
```
119+
120+
</app-ctc-block>
121+
122+
<!-- prettier-ignore-end -->
123+
124+
If you need to pass options to a markdown plugin, you can use object syntax with the plugin name and the options it takes.
125+
126+
<!-- prettier-ignore-start -->
127+
128+
<app-ctc-block variant="snippet" heading="greenwood.config.js">
129+
130+
```js
131+
import { greenwoodPluginMarkdown } from '@greenwood/plugin-markdown';
132+
133+
export default {
134+
plugins: [
135+
greenwoodPluginMarkdown({
136+
plugins: [
137+
"rehype-slug",
138+
{
139+
name: "rehype-autolink-headings",
140+
options: {
141+
behavior: "append"
142+
},
143+
},
144+
],
145+
})
146+
]
147+
}
148+
```
149+
150+
</app-ctc-block>
151+
34152
## Syntax Highlighting
35153

36154
Although Greenwood does not provide any syntax highlighting by default, you can add support for [**Prism**](https://prismjs.com/), for example.

0 commit comments

Comments
 (0)