@san-siva/blogkit-md 0.2.4 → 0.2.6
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 +3 -47
- package/dist/index.d.mts +3 -4
- package/dist/index.js +1 -1
- package/package.json +1 -1
- package/src/hooks/readMarkdownFile.ts +2 -2
- package/src/index.ts +1 -0
package/README.md
CHANGED
|
@@ -1,44 +1,14 @@
|
|
|
1
1
|
---
|
|
2
2
|
title: blogkit-md
|
|
3
|
-
description: A
|
|
3
|
+
description: A React component library that converts markdown files into rendered blog posts for `@san-siva/blogkit`.
|
|
4
4
|
---
|
|
5
5
|
|
|
6
|
-
A
|
|
6
|
+
A React component library that converts markdown files into rendered blog posts for [`@san-siva/blogkit`](https://blogkit.santhoshsiva.dev).
|
|
7
7
|
|
|
8
|
-
>
|
|
8
|
+
> Live preview of this README is available here [blogkit-md.santhoshsiva.dev](https://blogkit-md.santhoshsiva.dev)
|
|
9
9
|
|
|
10
10
|
## Getting started
|
|
11
11
|
|
|
12
|
-
```bash
|
|
13
|
-
git clone https://github.com/san-siva/blogkit-md.git
|
|
14
|
-
npm install
|
|
15
|
-
```
|
|
16
|
-
|
|
17
|
-
### Dev server
|
|
18
|
-
|
|
19
|
-
```bash
|
|
20
|
-
npm run dev # uses data/test.md by default
|
|
21
|
-
npm run dev -- --file=data/my-post.md # specify a markdown file
|
|
22
|
-
```
|
|
23
|
-
|
|
24
|
-
The dev server watches the markdown file for changes and auto-reloads the browser via HMR.
|
|
25
|
-
|
|
26
|
-
### Build
|
|
27
|
-
|
|
28
|
-
```bash
|
|
29
|
-
npm run build
|
|
30
|
-
npm run start
|
|
31
|
-
```
|
|
32
|
-
|
|
33
|
-
### Lint
|
|
34
|
-
|
|
35
|
-
```bash
|
|
36
|
-
npm run lint # check
|
|
37
|
-
npm run fix # auto-fix
|
|
38
|
-
```
|
|
39
|
-
|
|
40
|
-
## Using BlogPost in your own Next.js app
|
|
41
|
-
|
|
42
12
|
`blogkit-md` exposes a `BlogPost` server component you can drop into any Next.js project.
|
|
43
13
|
|
|
44
14
|
### Install
|
|
@@ -47,20 +17,6 @@ npm run fix # auto-fix
|
|
|
47
17
|
npm install @san-siva/blogkit-md
|
|
48
18
|
```
|
|
49
19
|
|
|
50
|
-
Or as a local package:
|
|
51
|
-
|
|
52
|
-
```json
|
|
53
|
-
"@san-siva/blogkit-md": "file:../blogkit-md"
|
|
54
|
-
```
|
|
55
|
-
|
|
56
|
-
Add it to `transpilePackages` in your `next.config.ts`:
|
|
57
|
-
|
|
58
|
-
```ts
|
|
59
|
-
const nextConfig = {
|
|
60
|
-
transpilePackages: ['@san-siva/blogkit-md'],
|
|
61
|
-
};
|
|
62
|
-
```
|
|
63
|
-
|
|
64
20
|
### Usage
|
|
65
21
|
|
|
66
22
|
```tsx
|
package/dist/index.d.mts
CHANGED
|
@@ -20,14 +20,13 @@ declare const MarkdownSections: ({ rendered, }: {
|
|
|
20
20
|
rendered: RenderedMarkdown;
|
|
21
21
|
}) => React.ReactNode;
|
|
22
22
|
|
|
23
|
-
type MarkdownFileResult = {
|
|
23
|
+
type MarkdownFileResult = ({
|
|
24
24
|
success: true;
|
|
25
25
|
rendered: RenderedMarkdown;
|
|
26
|
-
|
|
27
|
-
} | {
|
|
26
|
+
} & Frontmatter) | {
|
|
28
27
|
success: false;
|
|
29
28
|
error: string;
|
|
30
29
|
};
|
|
31
30
|
declare const readMarkdownFile: (filePath: string | undefined) => Promise<MarkdownFileResult>;
|
|
32
31
|
|
|
33
|
-
export { BlogPost, MarkdownSections, readMarkdownFile };
|
|
32
|
+
export { BlogPost, type Frontmatter, MarkdownSections, readMarkdownFile };
|
package/dist/index.js
CHANGED
|
@@ -404,7 +404,7 @@ var readMarkdownFile = async (filePath) => {
|
|
|
404
404
|
}
|
|
405
405
|
const { ast, frontmatter } = parseMarkdown(content);
|
|
406
406
|
const rendered = renderMarkdownAst(ast);
|
|
407
|
-
return { success: true, rendered, frontmatter
|
|
407
|
+
return __spreadValues({ success: true, rendered }, frontmatter);
|
|
408
408
|
};
|
|
409
409
|
export {
|
|
410
410
|
BlogPost_default as BlogPost,
|
package/package.json
CHANGED
|
@@ -7,7 +7,7 @@ import type { RenderedMarkdown } from '../utils/renderMarkdown';
|
|
|
7
7
|
import { renderMarkdownAst } from '../utils/renderMarkdown';
|
|
8
8
|
|
|
9
9
|
type MarkdownFileResult =
|
|
10
|
-
| { success: true; rendered: RenderedMarkdown
|
|
10
|
+
| ({ success: true; rendered: RenderedMarkdown } & Frontmatter)
|
|
11
11
|
| { success: false; error: string };
|
|
12
12
|
|
|
13
13
|
export const readMarkdownFile = async (
|
|
@@ -38,5 +38,5 @@ export const readMarkdownFile = async (
|
|
|
38
38
|
const { ast, frontmatter } = parseMarkdown(content);
|
|
39
39
|
const rendered = renderMarkdownAst(ast);
|
|
40
40
|
|
|
41
|
-
return { success: true, rendered, frontmatter };
|
|
41
|
+
return { success: true, rendered, ...frontmatter };
|
|
42
42
|
};
|
package/src/index.ts
CHANGED