Skip to content

Commit f20fdb9

Browse files
authored
Merge pull request #7 from rishichawda/update-docs
update docs to include new config options
2 parents f47dfd3 + 80be5b7 commit f20fdb9

File tree

7 files changed

+330
-72
lines changed

7 files changed

+330
-72
lines changed

.github/workflows/test.yml

Lines changed: 32 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -1,29 +1,14 @@
1-
name: Test
1+
name: Pull Request tests
22

33
on:
44
pull_request:
55
branches: [main]
6-
paths:
7-
- 'lib/**'
8-
- 'index.ts'
9-
- 'styles.css'
10-
- 'package.json'
11-
- '__tests__/**'
12-
- 'tsconfig.json'
13-
- '.github/workflows/test.yml'
146
push:
157
branches: [main]
16-
paths:
17-
- 'lib/**'
18-
- 'index.ts'
19-
- 'styles.css'
20-
- 'package.json'
21-
- '__tests__/**'
22-
- 'tsconfig.json'
23-
- '.github/workflows/test.yml'
248

259
jobs:
2610
test:
11+
name: plugin/tests (ubuntu-latest, Node v${{ matrix.node-version }})
2712
runs-on: ubuntu-latest
2813
strategy:
2914
matrix:
@@ -52,6 +37,7 @@ jobs:
5237
run: yarn build:ts
5338

5439
lint:
40+
name: plugin/lint (ubuntu-latest, Node v22)
5541
runs-on: ubuntu-latest
5642

5743
steps:
@@ -72,3 +58,32 @@ jobs:
7258

7359
- name: Check TypeScript types
7460
run: yarn build:ts --noEmit
61+
62+
docs-build:
63+
name: docs/build (ubuntu-latest, Node v18)
64+
runs-on: ubuntu-latest
65+
66+
steps:
67+
- name: Checkout
68+
uses: actions/checkout@v4
69+
70+
- name: Setup Node.js
71+
uses: actions/setup-node@v4
72+
with:
73+
node-version: '18'
74+
cache: 'yarn'
75+
76+
- name: Install Root Dependencies & Build Plugin
77+
run: |
78+
yarn install --frozen-lockfile
79+
yarn build
80+
81+
- name: Install Docs Dependencies
82+
run: |
83+
cd docs
84+
yarn install --frozen-lockfile
85+
86+
- name: Build Documentation Site
87+
run: |
88+
cd docs
89+
yarn build

README.md

Lines changed: 86 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -22,10 +22,13 @@ npm install remark-notes-plugin
2222

2323
## 🚀 Usage
2424

25+
### Basic Usage
26+
2527
```typescript
2628
import { unified } from 'unified'
2729
import remarkParse from 'remark-parse'
28-
import remarkStringify from 'remark-stringify'
30+
import remarkRehype from 'remark-rehype'
31+
import rehypeStringify from 'rehype-stringify'
2932
import remarkNotes from 'remark-notes-plugin'
3033

3134
const markdown = `
@@ -48,12 +51,40 @@ const markdown = `
4851
const file = await unified()
4952
.use(remarkParse)
5053
.use(remarkNotes)
51-
.use(remarkStringify)
54+
.use(remarkRehype)
55+
.use(rehypeStringify)
5256
.process(markdown)
5357

5458
console.log(String(file))
5559
```
5660

61+
### Configuration Options
62+
63+
```typescript
64+
import remarkNotes from 'remark-notes-plugin'
65+
66+
// Default configuration (styles are auto-injected)
67+
unified().use(remarkNotes)
68+
69+
// Custom class prefix
70+
unified().use(remarkNotes, {
71+
classPrefix: 'my-callout'
72+
})
73+
// Generates classes like: my-callout-remark-note, my-callout-remark-note-tip, etc.
74+
75+
// Disable automatic style injection (import CSS manually)
76+
unified().use(remarkNotes, {
77+
injectStyles: false
78+
})
79+
// Then import: import 'remark-notes-plugin/styles.css'
80+
81+
// Both options
82+
unified().use(remarkNotes, {
83+
classPrefix: 'custom',
84+
injectStyles: false
85+
})
86+
```
87+
5788
## 📝 Note Types
5889

5990
The plugin supports five distinct types of notes, each with its own unique style:
@@ -90,34 +121,75 @@ The plugin supports five distinct types of notes, each with its own unique style
90121

91122
## 🎨 Styling
92123

93-
Default styles are loaded automatically when you use the plugin. You can also modify the styles since the plugin uses a modular class structure that makes it easy to customize the appearance:
124+
By default, styles are automatically injected into your document. You can customize this behavior:
125+
126+
### Automatic Style Injection (Default)
127+
128+
Styles are included automatically when you use the plugin with default settings:
129+
130+
```typescript
131+
unified().use(remarkNotes) // Styles auto-injected
132+
```
133+
134+
### Manual Style Import
135+
136+
If you prefer to manage styles yourself (e.g., for SSR or custom build tools), disable auto-injection:
137+
138+
```typescript
139+
unified().use(remarkNotes, { injectStyles: false })
140+
```
141+
142+
Then manually import the CSS:
143+
144+
```typescript
145+
import 'remark-notes-plugin/styles.css'
146+
```
147+
148+
### Customizing Styles
149+
150+
The plugin uses a modular class structure that makes it easy to customize the appearance:
94151

95-
### Base Classes
152+
#### Base Classes
96153

97154
- `.remark-note` - Base container for all note types
98155
- `.remark-note-header` - Note header container
99156
- `.remark-note-icon` - Icon styling
100157
- `.remark-note-title` - Note title styling
101158
- `.remark-note-content` - Note content container
102159

103-
### Type-Specific Classes
160+
#### Type-Specific Classes
161+
162+
- `.remark-note-note` - Note type styling
163+
- `.remark-note-tip` - Tip type styling
164+
- `.remark-note-important` - Important type styling
165+
- `.remark-note-quote` - Quote type styling
166+
- `.remark-note-bonus` - Bonus type styling
167+
168+
#### Custom Class Prefix
169+
170+
You can add a custom prefix to all CSS classes:
171+
172+
```typescript
173+
unified().use(remarkNotes, { classPrefix: 'my-callout' })
174+
```
175+
176+
This generates classes like:
104177

105-
- `.remark-note.note` - Note type styling
106-
- `.remark-note.tip` - Tip type styling
107-
- `.remark-note.important` - Important type styling
108-
- `.remark-note.quote` - Quote type styling
109-
- `.remark-note.bonus` - Bonus type styling
178+
- `.my-callout-remark-note`
179+
- `.my-callout-remark-note-tip`
180+
- `.my-callout-remark-note-header`
181+
- etc.
110182

111-
### Customization Example
183+
#### Customization Example
112184

113185
```css
114186
/* Example: Customize the Note type */
115-
.remark-note.note {
187+
.remark-note-note {
116188
background-color: #your-color;
117189
border-color: #your-border-color;
118190
}
119191

120-
.remark-note.note .remark-note-title {
192+
.remark-note-note .remark-note-title {
121193
color: #your-text-color;
122194
}
123195
```
@@ -152,4 +224,4 @@ Please ensure your pull request passes all tests and includes appropriate docume
152224

153225
---
154226

155-
⭐️ If you find this plugin useful, please consider giving it a star on GitHub! ⭐️
227+
⭐️ If you find this plugin useful, please consider giving it a star on GitHub! ⭐️

0 commit comments

Comments
 (0)