lite-matter 0.0.1 → 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/package.json +14 -3
- package/.gitattributes +0 -2
- package/.github/workflows/publish.yml +0 -32
- package/src/index.ts +0 -34
- package/tsconfig.json +0 -14
package/package.json
CHANGED
|
@@ -1,10 +1,21 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "lite-matter",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.1.1",
|
|
4
4
|
"description": "Ultra lightweight, zero-bloat frontmatter extractor.",
|
|
5
5
|
"type": "module",
|
|
6
|
+
"files": [
|
|
7
|
+
"dist"
|
|
8
|
+
],
|
|
6
9
|
"main": "dist/index.js",
|
|
7
10
|
"types": "dist/index.d.ts",
|
|
11
|
+
"exports": {
|
|
12
|
+
".": {
|
|
13
|
+
"import": {
|
|
14
|
+
"types": "./dist/index.d.ts",
|
|
15
|
+
"default": "./dist/index.js"
|
|
16
|
+
}
|
|
17
|
+
}
|
|
18
|
+
},
|
|
8
19
|
"scripts": {
|
|
9
20
|
"build": "tsc"
|
|
10
21
|
},
|
|
@@ -32,11 +43,11 @@
|
|
|
32
43
|
},
|
|
33
44
|
"repository": {
|
|
34
45
|
"type": "git",
|
|
35
|
-
"url": "git+https://github.com/docmd-io/
|
|
46
|
+
"url": "git+https://github.com/docmd-io/lite-matter.git",
|
|
36
47
|
"directory": "lite-matter"
|
|
37
48
|
},
|
|
38
49
|
"bugs": {
|
|
39
|
-
"url": "https://github.com/docmd-io/
|
|
50
|
+
"url": "https://github.com/docmd-io/lite-matter/issues"
|
|
40
51
|
},
|
|
41
52
|
"homepage": "https://docmd.io",
|
|
42
53
|
"funding": "https://github.com/sponsors/mgks",
|
package/.gitattributes
DELETED
|
@@ -1,32 +0,0 @@
|
|
|
1
|
-
name: Publish to NPM
|
|
2
|
-
on:
|
|
3
|
-
release:
|
|
4
|
-
types: [published]
|
|
5
|
-
workflow_dispatch:
|
|
6
|
-
|
|
7
|
-
permissions:
|
|
8
|
-
contents: read
|
|
9
|
-
id-token: write
|
|
10
|
-
|
|
11
|
-
jobs:
|
|
12
|
-
publish:
|
|
13
|
-
runs-on: ubuntu-latest
|
|
14
|
-
steps:
|
|
15
|
-
- uses: actions/checkout@v6
|
|
16
|
-
|
|
17
|
-
- name: Setup Node.js
|
|
18
|
-
uses: actions/setup-node@v6
|
|
19
|
-
with:
|
|
20
|
-
node-version: '22'
|
|
21
|
-
registry-url: 'https://registry.npmjs.org'
|
|
22
|
-
|
|
23
|
-
- name: Install dependencies
|
|
24
|
-
run: npm install
|
|
25
|
-
|
|
26
|
-
- name: Build package
|
|
27
|
-
run: npm run build
|
|
28
|
-
|
|
29
|
-
- name: Publish to npm
|
|
30
|
-
run: npm publish --access public
|
|
31
|
-
env:
|
|
32
|
-
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}
|
package/src/index.ts
DELETED
|
@@ -1,34 +0,0 @@
|
|
|
1
|
-
import { parse } from 'yaml';
|
|
2
|
-
|
|
3
|
-
export interface MatterResult {
|
|
4
|
-
data: Record<string, any>;
|
|
5
|
-
content: string;
|
|
6
|
-
}
|
|
7
|
-
|
|
8
|
-
/**
|
|
9
|
-
* Extracts and parses YAML frontmatter from a string.
|
|
10
|
-
* Mimics the API of `gray-matter` for easy drop-in replacement.
|
|
11
|
-
*/
|
|
12
|
-
export function matter(str: string): MatterResult {
|
|
13
|
-
// Regex matches frontmatter bounded by --- only at the very start of the string
|
|
14
|
-
const regex = /^(?:---[\r\n]+)([\s\S]*?)(?:[\r\n]+---(?:[\r\n]+|$))/;
|
|
15
|
-
const match = str.match(regex);
|
|
16
|
-
|
|
17
|
-
if (!match) {
|
|
18
|
-
return { data: {}, content: str };
|
|
19
|
-
}
|
|
20
|
-
|
|
21
|
-
const yamlStr = match[1];
|
|
22
|
-
const content = str.slice(match[0].length);
|
|
23
|
-
|
|
24
|
-
try {
|
|
25
|
-
const data = parse(yamlStr) || {};
|
|
26
|
-
return { data, content };
|
|
27
|
-
} catch (err) {
|
|
28
|
-
// Return empty data but successfully parse the rest of the text if YAML fails
|
|
29
|
-
return { data: {}, content: str };
|
|
30
|
-
}
|
|
31
|
-
}
|
|
32
|
-
|
|
33
|
-
// Fallback default export for total compatibility
|
|
34
|
-
export default matter;
|
package/tsconfig.json
DELETED
|
@@ -1,14 +0,0 @@
|
|
|
1
|
-
{
|
|
2
|
-
"compilerOptions": {
|
|
3
|
-
"target": "ES2022",
|
|
4
|
-
"module": "Node16",
|
|
5
|
-
"moduleResolution": "node16",
|
|
6
|
-
"strict": true,
|
|
7
|
-
"declaration": true,
|
|
8
|
-
"outDir": "dist",
|
|
9
|
-
"esModuleInterop": true,
|
|
10
|
-
"forceConsistentCasingInFileNames": true,
|
|
11
|
-
"skipLibCheck": true
|
|
12
|
-
},
|
|
13
|
-
"include": ["src/**/*"]
|
|
14
|
-
}
|