@san-siva/blogkit-md 0.1.0 → 0.1.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md CHANGED
@@ -89,23 +89,25 @@ export default function Page() {
89
89
 
90
90
  ## Supported markdown features
91
91
 
92
- | Feature | Syntax |
93
- | --------------- | ---------------------------------- |
94
- | Headings | `# H1` `## H2` `### H3` `#### H4` |
95
- | Paragraph | Plain text |
96
- | Hard line break | Two spaces at end of line |
97
- | Bold | `**bold**` |
98
- | Italic | `_italic_` |
99
- | Inline code | `` `code` `` |
100
- | Link | `[text](url)` |
101
- | Image | `![alt](url)` |
102
- | Ordered list | `1. item` |
103
- | Unordered list | `- item` |
104
- | Table | GFM table syntax |
105
- | Code block | ` ```lang ` |
106
- | Mermaid diagram | ` ```mermaid ` |
107
- | Thematic break | `---` |
108
- | Blockquote | `> text` — renders as info callout |
92
+ | Feature | Syntax |
93
+ | -------------------- | -------------------------------------- |
94
+ | Headings | `# H1` `## H2` `### H3` `#### H4` |
95
+ | Paragraph | Plain text |
96
+ | Hard line break | Two spaces at end of line |
97
+ | Bold | `**bold**` |
98
+ | Italic | `_italic_` |
99
+ | Inline code | `` `code` `` |
100
+ | Link | `[text](url)` |
101
+ | Image | `![alt](url)` |
102
+ | Ordered list | `1. item` |
103
+ | Unordered list | `- item` |
104
+ | Table | GFM table syntax |
105
+ | Code block | ` ```lang ` |
106
+ | Mermaid diagram | ` ```mermaid ` |
107
+ | Thematic break | `---` |
108
+ | Blockquote | `> text` — renders as info callout |
109
+ | Blockquote (warning) | `> ~text` — renders as warning callout |
110
+ | Blockquote (error) | `> !text` — renders as error callout |
109
111
 
110
112
  ## Philosophy
111
113
 
@@ -221,13 +223,25 @@ Nested content belongs here.
221
223
  ## The Results
222
224
  ```
223
225
 
226
+ ### Callouts
227
+
228
+ Blockquotes are rendered as styled callout banners. The callout type is controlled by a prefix on the first word of the quote:
229
+
230
+ | Syntax | Callout Type | Example |
231
+ | :-------- | :----------- | :--------------------------- |
232
+ | `> text` | Info | `> This is an info callout.` |
233
+ | `> ~text` | Warning | `> ~This is a warning.` |
234
+ | `> !text` | Error | `> !This is an error.` |
235
+
236
+ The prefix character is stripped from the rendered output — only the callout style changes.
237
+
224
238
  ## Want more customization?
225
239
 
226
240
  `blogkit-md` is just one piece of the puzzle. If you want to customize the underlying React components, tweak the UI, or take full control over your blog's layout, dive into the official [Blogkit documentation](https://blogkit.santhoshsiva.dev/).
227
241
 
228
242
  ## License
229
243
 
230
- `blogkit-md` is open source software licensed under the [MIT license](https://github.com/san-siva/blogkit-md/blob/main/LICENSE).
244
+ `blogkit-md` is open source software licensed under the [MIT license](https://github.com/san-siva/blogkit-md/blob/main/LICENSE).
231
245
  Contributions are welcome!
232
246
 
233
247
  ## About
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@san-siva/blogkit-md",
3
- "version": "0.1.0",
3
+ "version": "0.1.1",
4
4
  "description": "Converts markdown files into JSX blog posts for Blogkit",
5
5
  "main": "index.ts",
6
6
  "exports": {
@@ -1,6 +1,12 @@
1
1
  import React from 'react';
2
2
 
3
- import { BlogSection, Callout, CodeBlock, Mermaid, Table } from '@san-siva/blogkit';
3
+ import {
4
+ BlogSection,
5
+ Callout,
6
+ CodeBlock,
7
+ Mermaid,
8
+ Table,
9
+ } from '@san-siva/blogkit';
4
10
  import type { Root, RootContent } from 'mdast';
5
11
 
6
12
  import type { Section } from './groupSections';
@@ -84,10 +90,47 @@ function renderNode(
84
90
  }
85
91
  case 'blockquote': {
86
92
  const children = node.children as RootContent[];
93
+ let calloutType: 'info' | 'warning' | 'error' = 'info';
94
+ let strippedChildren = children;
95
+
96
+ const firstChild = children[0];
97
+ if (firstChild?.type === 'paragraph') {
98
+ const firstInline = firstChild.children[0];
99
+ if (firstInline?.type === 'text') {
100
+ if (firstInline.value.startsWith('!')) {
101
+ calloutType = 'error';
102
+ const trimmed = firstInline.value.slice(1).trimStart();
103
+ strippedChildren = [
104
+ {
105
+ ...firstChild,
106
+ children: [
107
+ { ...firstInline, value: trimmed },
108
+ ...firstChild.children.slice(1),
109
+ ],
110
+ },
111
+ ...children.slice(1),
112
+ ];
113
+ } else if (firstInline.value.startsWith('~')) {
114
+ calloutType = 'warning';
115
+ const trimmed = firstInline.value.slice(1).trimStart();
116
+ strippedChildren = [
117
+ {
118
+ ...firstChild,
119
+ children: [
120
+ { ...firstInline, value: trimmed },
121
+ ...firstChild.children.slice(1),
122
+ ],
123
+ },
124
+ ...children.slice(1),
125
+ ];
126
+ }
127
+ }
128
+ }
129
+
87
130
  return (
88
- <Callout key={key} type="info" hasMarginUp hasMarginDown>
89
- {children.map((child, index) =>
90
- renderNode(child, index, children[index + 1])
131
+ <Callout key={key} type={calloutType} hasMarginUp hasMarginDown>
132
+ {strippedChildren.map((child, index) =>
133
+ renderNode(child, index, strippedChildren[index + 1])
91
134
  )}
92
135
  </Callout>
93
136
  );
@@ -95,7 +138,7 @@ function renderNode(
95
138
  case 'list': {
96
139
  const Tag = node.ordered ? 'ol' : 'ul';
97
140
  return (
98
- <Tag key={key}>
141
+ <Tag key={key} className={styles['margin-bottom--2']}>
99
142
  {node.children.map((item, index) => (
100
143
  <li key={index}>
101
144
  {item.children.map((child, index) =>