@san-siva/blogkit-md 0.3.3 → 0.3.4

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
@@ -245,7 +245,3 @@ Contributions are welcome!
245
245
 
246
246
  - **Author:** [Santhosh Siva](https://www.santhoshsiva.dev)
247
247
  - **License:** [MIT](https://github.com/san-siva/blogkit-md/blob/main/LICENSE)
248
-
249
- > [!WARNING]
250
- >
251
- > This project is in early development.
package/dist/index.js CHANGED
@@ -301,7 +301,9 @@ function renderNode({
301
301
  if ((firstChild == null ? void 0 : firstChild.type) === "paragraph") {
302
302
  const firstInline = firstChild.children[0];
303
303
  if ((firstInline == null ? void 0 : firstInline.type) === "text") {
304
- const githubAlertMatch = /^\[!(NOTE|TIP|IMPORTANT|WARNING|CAUTION)\]$/i.exec(firstInline.value);
304
+ const githubAlertMatch = /^\[!(NOTE|TIP|IMPORTANT|WARNING|CAUTION)\]$/i.exec(
305
+ firstInline.value
306
+ );
305
307
  if (githubAlertMatch) {
306
308
  const alertType = githubAlertMatch[1].toUpperCase();
307
309
  calloutType = alertType === "WARNING" ? "warning" : alertType === "CAUTION" ? "error" : "info";
@@ -309,7 +311,7 @@ function renderNode({
309
311
  }
310
312
  }
311
313
  }
312
- return /* @__PURE__ */ jsx2(Callout, { type: calloutType, hasMarginUp: true, hasMarginDown: true, children: strippedChildren.map(
314
+ return /* @__PURE__ */ jsx2(Callout, { type: calloutType, hasMarginUp: true, hasMarginDown: true, children: /* @__PURE__ */ jsx2("div", { children: strippedChildren.map(
313
315
  (child, index) => renderNode({
314
316
  node: child,
315
317
  key: index,
@@ -317,16 +319,23 @@ function renderNode({
317
319
  inCallout: true,
318
320
  counters
319
321
  })
320
- ) }, key);
322
+ ) }) }, key);
321
323
  }
322
324
  case "list": {
323
- const isTaskList = node.children.every((item) => item.checked !== null && item.checked !== void 0);
325
+ const isTaskList = node.children.every(
326
+ (item) => item.checked !== null && item.checked !== void 0
327
+ );
324
328
  if (isTaskList) {
325
329
  const items = node.children.map((item, index) => ({
326
330
  id: String(index),
327
331
  isChecked: item.checked === true,
328
332
  children: item.children.map(
329
- (child, childIndex) => renderNode({ node: child, key: childIndex, inList: true, counters })
333
+ (child, childIndex) => renderNode({
334
+ node: child,
335
+ key: childIndex,
336
+ inList: true,
337
+ counters
338
+ })
330
339
  )
331
340
  }));
332
341
  return /* @__PURE__ */ jsx2(CheckList, { items, hasMarginUp: true, hasMarginDown: true }, key);
@@ -364,7 +373,9 @@ var renderMarkdownAst = (ast) => {
364
373
  const counters = { mermaid: 0 };
365
374
  const grouped = groupSections(ast.children);
366
375
  return {
367
- sections: grouped.map((section, index) => renderSection(section, counters, index))
376
+ sections: grouped.map(
377
+ (section, index) => renderSection(section, counters, index)
378
+ )
368
379
  };
369
380
  };
370
381
  var MarkdownSections = ({
@@ -379,11 +390,11 @@ var BlogPost = async ({ filePath, jsonLd }) => {
379
390
  try {
380
391
  content = await readFile(absolutePath, "utf8");
381
392
  } catch (e) {
382
- return /* @__PURE__ */ jsx3(Blog, { children: /* @__PURE__ */ jsxs2(Callout2, { type: "warning", children: [
393
+ return /* @__PURE__ */ jsx3(Blog, { children: /* @__PURE__ */ jsx3(Callout2, { type: "warning", children: /* @__PURE__ */ jsxs2("p", { children: [
383
394
  'Could not read file: "',
384
395
  filePath,
385
396
  '". Make sure the path is correct and the file exists.'
386
- ] }) });
397
+ ] }) }) });
387
398
  }
388
399
  if (!content.trim()) {
389
400
  return /* @__PURE__ */ jsx3(Blog, { children: /* @__PURE__ */ jsxs2(Callout2, { type: "warning", children: [
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@san-siva/blogkit-md",
3
- "version": "0.3.3",
3
+ "version": "0.3.4",
4
4
  "description": "Converts markdown files into JSX blog posts for Blogkit",
5
5
  "main": "./dist/index.js",
6
6
  "exports": {
@@ -23,8 +23,10 @@ const BlogPost = async ({ filePath, jsonLd }: BlogPostProperties) => {
23
23
  return (
24
24
  <Blog>
25
25
  <Callout type="warning">
26
- Could not read file: &quot;{filePath}&quot;. Make sure the path is
27
- correct and the file exists.
26
+ <p>
27
+ Could not read file: &quot;{filePath}&quot;. Make sure the path is
28
+ correct and the file exists.
29
+ </p>
28
30
  </Callout>
29
31
  </Blog>
30
32
  );
@@ -117,10 +117,18 @@ function renderNode({
117
117
  if (firstChild?.type === 'paragraph') {
118
118
  const firstInline = firstChild.children[0];
119
119
  if (firstInline?.type === 'text') {
120
- const githubAlertMatch = /^\[!(NOTE|TIP|IMPORTANT|WARNING|CAUTION)\]$/i.exec(firstInline.value);
120
+ const githubAlertMatch =
121
+ /^\[!(NOTE|TIP|IMPORTANT|WARNING|CAUTION)\]$/i.exec(
122
+ firstInline.value
123
+ );
121
124
  if (githubAlertMatch) {
122
125
  const alertType = githubAlertMatch[1].toUpperCase();
123
- calloutType = alertType === 'WARNING' ? 'warning' : alertType === 'CAUTION' ? 'error' : 'info';
126
+ calloutType =
127
+ alertType === 'WARNING'
128
+ ? 'warning'
129
+ : alertType === 'CAUTION'
130
+ ? 'error'
131
+ : 'info';
124
132
  strippedChildren = children.slice(1);
125
133
  }
126
134
  }
@@ -128,26 +136,35 @@ function renderNode({
128
136
 
129
137
  return (
130
138
  <Callout key={key} type={calloutType} hasMarginUp hasMarginDown>
131
- {strippedChildren.map((child, index) =>
132
- renderNode({
133
- node: child,
134
- key: index,
135
- nextNode: strippedChildren[index + 1],
136
- inCallout: true,
137
- counters,
138
- })
139
- )}
139
+ <div>
140
+ {strippedChildren.map((child, index) =>
141
+ renderNode({
142
+ node: child,
143
+ key: index,
144
+ nextNode: strippedChildren[index + 1],
145
+ inCallout: true,
146
+ counters,
147
+ })
148
+ )}
149
+ </div>
140
150
  </Callout>
141
151
  );
142
152
  }
143
153
  case 'list': {
144
- const isTaskList = node.children.every(item => item.checked !== null && item.checked !== undefined);
154
+ const isTaskList = node.children.every(
155
+ item => item.checked !== null && item.checked !== undefined
156
+ );
145
157
  if (isTaskList) {
146
158
  const items: CheckListItem[] = node.children.map((item, index) => ({
147
159
  id: String(index),
148
160
  isChecked: item.checked === true,
149
161
  children: item.children.map((child, childIndex) =>
150
- renderNode({ node: child as RootContent, key: childIndex, inList: true, counters })
162
+ renderNode({
163
+ node: child as RootContent,
164
+ key: childIndex,
165
+ inList: true,
166
+ counters,
167
+ })
151
168
  ),
152
169
  }));
153
170
  return <CheckList key={key} items={items} hasMarginUp hasMarginDown />;
@@ -176,13 +193,20 @@ function renderNode({
176
193
  }
177
194
  }
178
195
 
179
- function renderNodes(nodes: RootContent[], counters: Counters): React.ReactNode[] {
196
+ function renderNodes(
197
+ nodes: RootContent[],
198
+ counters: Counters
199
+ ): React.ReactNode[] {
180
200
  return nodes.map((node, index) =>
181
201
  renderNode({ node, key: index, nextNode: nodes[index + 1], counters })
182
202
  );
183
203
  }
184
204
 
185
- function renderSection(section: Section, counters: Counters, key = -1): React.ReactNode {
205
+ function renderSection(
206
+ section: Section,
207
+ counters: Counters,
208
+ key = -1
209
+ ): React.ReactNode {
186
210
  return (
187
211
  <BlogSection key={key} title={section?.title ?? ''}>
188
212
  {renderNodes(section.nodes, counters)}
@@ -201,7 +225,9 @@ export const renderMarkdownAst = (ast: Root): RenderedMarkdown => {
201
225
  const counters: Counters = { mermaid: 0 };
202
226
  const grouped = groupSections(ast.children);
203
227
  return {
204
- sections: grouped.map((section, index) => renderSection(section, counters, index)),
228
+ sections: grouped.map((section, index) =>
229
+ renderSection(section, counters, index)
230
+ ),
205
231
  };
206
232
  };
207
233