@md-plugins/shared 0.1.0-alpha.1 → 0.1.0-alpha.5
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/LICENSE.md +1 -1
- package/README.md +14 -14
- package/package.json +8 -3
package/LICENSE.md
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
The MIT License (MIT)
|
|
2
2
|
|
|
3
|
-
Copyright (c) 2024-present,
|
|
3
|
+
Copyright (c) 2024-present, MD-PLUGINS
|
|
4
4
|
|
|
5
5
|
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
6
|
of this software and associated documentation files (the "Software"), to deal
|
package/README.md
CHANGED
|
@@ -29,26 +29,26 @@ The `@md-plugins/shared` package is not intended to be used directly by end-user
|
|
|
29
29
|
## Example: Accessing Types
|
|
30
30
|
|
|
31
31
|
```ts
|
|
32
|
-
import type { MarkdownItEnv } from '@md-plugins/shared'
|
|
32
|
+
import type { MarkdownItEnv } from '@md-plugins/shared'
|
|
33
33
|
|
|
34
34
|
const env: MarkdownItEnv = {
|
|
35
35
|
toc: [],
|
|
36
36
|
frontmatter: {},
|
|
37
|
-
}
|
|
37
|
+
}
|
|
38
38
|
```
|
|
39
39
|
|
|
40
40
|
## Example: Utility Function
|
|
41
41
|
|
|
42
42
|
```ts
|
|
43
|
-
import { resolveTitleFromToken } from '@md-plugins/shared'
|
|
43
|
+
import { resolveTitleFromToken } from '@md-plugins/shared'
|
|
44
44
|
|
|
45
|
-
const token = { content: 'My Title' }
|
|
45
|
+
const token = { content: 'My Title' }
|
|
46
46
|
const title = resolveTitleFromToken(token, {
|
|
47
47
|
shouldAllowHtml: false,
|
|
48
48
|
shouldEscapeText: true,
|
|
49
|
-
})
|
|
49
|
+
})
|
|
50
50
|
|
|
51
|
-
console.log(title)
|
|
51
|
+
console.log(title) // "My Title"
|
|
52
52
|
```
|
|
53
53
|
|
|
54
54
|
## Provided Types
|
|
@@ -59,11 +59,11 @@ The `shared` package defines common types used across plugins. Here are some exa
|
|
|
59
59
|
|
|
60
60
|
```ts
|
|
61
61
|
export interface MarkdownItEnv {
|
|
62
|
-
toc?: Array<Record<string, any
|
|
63
|
-
frontmatter?: Record<string, unknown
|
|
64
|
-
pageScripts?: Set<string
|
|
65
|
-
content?: string
|
|
66
|
-
title?: string
|
|
62
|
+
toc?: Array<Record<string, any>> // Extracted table of contents
|
|
63
|
+
frontmatter?: Record<string, unknown> // Frontmatter data
|
|
64
|
+
pageScripts?: Set<string> // Scripts to be included in the page
|
|
65
|
+
content?: string // Markdown content excluding frontmatter
|
|
66
|
+
title?: string // Extracted title
|
|
67
67
|
}
|
|
68
68
|
```
|
|
69
69
|
|
|
@@ -78,8 +78,8 @@ A utility function to resolve the title from a Markdown-It token.
|
|
|
78
78
|
```ts
|
|
79
79
|
function resolveTitleFromToken(
|
|
80
80
|
token: Token,
|
|
81
|
-
options: { shouldAllowHtml: boolean; shouldEscapeText: boolean }
|
|
82
|
-
): string
|
|
81
|
+
options: { shouldAllowHtml: boolean; shouldEscapeText: boolean },
|
|
82
|
+
): string
|
|
83
83
|
```
|
|
84
84
|
|
|
85
85
|
- Parameters:
|
|
@@ -92,7 +92,7 @@ function resolveTitleFromToken(
|
|
|
92
92
|
Provides a standard implementation of slugification for plugins:
|
|
93
93
|
|
|
94
94
|
```ts
|
|
95
|
-
function slugify(str: string): string
|
|
95
|
+
function slugify(str: string): string
|
|
96
96
|
```
|
|
97
97
|
|
|
98
98
|
- Converts a string into a URL-friendly slug.
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@md-plugins/shared",
|
|
3
|
-
"version": "0.1.0-alpha.
|
|
3
|
+
"version": "0.1.0-alpha.5",
|
|
4
4
|
"description": "Shared functions and utilities for md-plugins.",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"markdown-it",
|
|
@@ -33,7 +33,12 @@
|
|
|
33
33
|
"./dist"
|
|
34
34
|
],
|
|
35
35
|
"dependencies": {
|
|
36
|
-
"
|
|
36
|
+
"markdown-it": "^14.1.0"
|
|
37
|
+
},
|
|
38
|
+
"devDependencies": {
|
|
39
|
+
"@types/markdown-it": "^14.1.2"
|
|
40
|
+
},
|
|
41
|
+
"peerDependencies": {
|
|
37
42
|
"markdown-it": "^14.1.0"
|
|
38
43
|
},
|
|
39
44
|
"publishConfig": {
|
|
@@ -41,7 +46,7 @@
|
|
|
41
46
|
},
|
|
42
47
|
"scripts": {
|
|
43
48
|
"build": "unbuild",
|
|
44
|
-
"clean": "rm -rf dist",
|
|
49
|
+
"clean": "rm -rf dist/ node_modules/",
|
|
45
50
|
"test": "vitest"
|
|
46
51
|
}
|
|
47
52
|
}
|