postfolio 1.0.3 → 1.0.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/dist/server.d.ts +35 -0
- package/dist/server.js +91 -0
- package/dist/src/client.d.ts +6 -4
- package/dist/src/client.js +38 -31
- package/dist/src/renderer.d.ts +6 -4
- package/dist/src/renderer.js +12 -6
- package/package.json +46 -43
- package/dist/index.d.ts +0 -3
- package/dist/index.d.ts.map +0 -1
- package/dist/index.js +0 -3
- package/dist/index.js.map +0 -1
- package/dist/src/client.d.ts.map +0 -1
- package/dist/src/client.js.map +0 -1
- package/dist/src/main.d.ts +0 -35
- package/dist/src/main.d.ts.map +0 -1
- package/dist/src/main.js +0 -94
- package/dist/src/main.js.map +0 -1
- package/dist/src/renderer.d.ts.map +0 -1
- package/dist/src/renderer.js.map +0 -1
package/dist/server.d.ts
ADDED
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
declare function setContentDirectory(newPath: string): void;
|
|
2
|
+
type BlogFrontmatter = {
|
|
3
|
+
title?: string;
|
|
4
|
+
description?: string;
|
|
5
|
+
date?: string;
|
|
6
|
+
tags?: string[];
|
|
7
|
+
author?: string;
|
|
8
|
+
draft?: boolean;
|
|
9
|
+
[key: string]: string | string[] | boolean | undefined;
|
|
10
|
+
};
|
|
11
|
+
type BlogPostSource = {
|
|
12
|
+
slug: string;
|
|
13
|
+
filename: string;
|
|
14
|
+
filePath: string;
|
|
15
|
+
mdx: string;
|
|
16
|
+
frontmatter?: any;
|
|
17
|
+
};
|
|
18
|
+
type TOCItem = {
|
|
19
|
+
level: number;
|
|
20
|
+
text: string;
|
|
21
|
+
slug: string;
|
|
22
|
+
};
|
|
23
|
+
declare function generateSlug(text: string): string;
|
|
24
|
+
declare function generateTOC(content: string): TOCItem[];
|
|
25
|
+
declare function Slugs(): string[];
|
|
26
|
+
declare function Post(slug: string): BlogPostSource | undefined;
|
|
27
|
+
declare function allPosts(): Promise<BlogPostSource[]>;
|
|
28
|
+
declare function MDXPost(slug: string): Promise<{
|
|
29
|
+
slug: string;
|
|
30
|
+
code: string;
|
|
31
|
+
frontmatter: any;
|
|
32
|
+
raw: string;
|
|
33
|
+
} | undefined>;
|
|
34
|
+
|
|
35
|
+
export { type BlogFrontmatter, type BlogPostSource, MDXPost, Post, Slugs, allPosts, generateSlug, generateTOC, setContentDirectory };
|
package/dist/server.js
ADDED
|
@@ -0,0 +1,91 @@
|
|
|
1
|
+
// src/server.ts
|
|
2
|
+
import "server-only";
|
|
3
|
+
import fs from "fs";
|
|
4
|
+
import path from "path";
|
|
5
|
+
import { bundleMDX } from "mdx-bundler";
|
|
6
|
+
var BLOG_DIR_PATH = path.join(process.cwd(), "content", "blogs");
|
|
7
|
+
function setContentDirectory(newPath) {
|
|
8
|
+
BLOG_DIR_PATH = newPath;
|
|
9
|
+
}
|
|
10
|
+
function transformFilenameToSlug(filename) {
|
|
11
|
+
return filename.replace(/\.mdx$/, "").toLowerCase().trim().replace(/[^a-z0-9\s-]/g, "").replace(/\s+/g, "-").replace(/-+/g, "-").replace(/^-+|-+$/g, "");
|
|
12
|
+
}
|
|
13
|
+
function getMdxFileNames() {
|
|
14
|
+
if (!fs.existsSync(BLOG_DIR_PATH)) {
|
|
15
|
+
return [];
|
|
16
|
+
}
|
|
17
|
+
return fs.readdirSync(BLOG_DIR_PATH).filter((file) => file.endsWith(".mdx"));
|
|
18
|
+
}
|
|
19
|
+
function getPostSourceBySlug(slug) {
|
|
20
|
+
const filename = getMdxFileNames().find(
|
|
21
|
+
(file) => transformFilenameToSlug(file) === slug
|
|
22
|
+
);
|
|
23
|
+
if (!filename) {
|
|
24
|
+
return void 0;
|
|
25
|
+
}
|
|
26
|
+
const filePath = path.join(BLOG_DIR_PATH, filename);
|
|
27
|
+
return {
|
|
28
|
+
slug,
|
|
29
|
+
filename,
|
|
30
|
+
filePath,
|
|
31
|
+
mdx: fs.readFileSync(filePath, "utf8")
|
|
32
|
+
};
|
|
33
|
+
}
|
|
34
|
+
function generateSlug(text) {
|
|
35
|
+
return text.toLowerCase().replace(/[^\w\s-]/g, "").replace(/\s+/g, "-");
|
|
36
|
+
}
|
|
37
|
+
function generateTOC(content) {
|
|
38
|
+
const headingRegex = /^(#{1,6})\s+(.+)$/gm;
|
|
39
|
+
return [...content.matchAll(headingRegex)].map((match) => {
|
|
40
|
+
const level = match[1].length;
|
|
41
|
+
const text = match[2].trim();
|
|
42
|
+
return {
|
|
43
|
+
level,
|
|
44
|
+
text,
|
|
45
|
+
slug: text.toLowerCase().replace(/[^\w\s-]/g, "").replace(/\s+/g, "-")
|
|
46
|
+
};
|
|
47
|
+
});
|
|
48
|
+
}
|
|
49
|
+
function Slugs() {
|
|
50
|
+
return getMdxFileNames().map(transformFilenameToSlug);
|
|
51
|
+
}
|
|
52
|
+
function Post(slug) {
|
|
53
|
+
return getPostSourceBySlug(slug);
|
|
54
|
+
}
|
|
55
|
+
async function allPosts() {
|
|
56
|
+
const posts = Slugs().map(getPostSourceBySlug).filter((post) => Boolean(post));
|
|
57
|
+
return Promise.all(
|
|
58
|
+
posts.map(async (post) => {
|
|
59
|
+
const { frontmatter } = await bundleMDX({
|
|
60
|
+
file: post.filePath,
|
|
61
|
+
cwd: BLOG_DIR_PATH
|
|
62
|
+
});
|
|
63
|
+
return { ...post, frontmatter };
|
|
64
|
+
})
|
|
65
|
+
);
|
|
66
|
+
}
|
|
67
|
+
async function MDXPost(slug) {
|
|
68
|
+
const post = Post(slug);
|
|
69
|
+
if (!post) {
|
|
70
|
+
return void 0;
|
|
71
|
+
}
|
|
72
|
+
const { code, frontmatter } = await bundleMDX({
|
|
73
|
+
file: post.filePath,
|
|
74
|
+
cwd: BLOG_DIR_PATH
|
|
75
|
+
});
|
|
76
|
+
return {
|
|
77
|
+
slug: post.slug,
|
|
78
|
+
code,
|
|
79
|
+
frontmatter,
|
|
80
|
+
raw: post.mdx
|
|
81
|
+
};
|
|
82
|
+
}
|
|
83
|
+
export {
|
|
84
|
+
MDXPost,
|
|
85
|
+
Post,
|
|
86
|
+
Slugs,
|
|
87
|
+
allPosts,
|
|
88
|
+
generateSlug,
|
|
89
|
+
generateTOC,
|
|
90
|
+
setContentDirectory
|
|
91
|
+
};
|
package/dist/src/client.d.ts
CHANGED
|
@@ -1,4 +1,6 @@
|
|
|
1
|
-
import
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
1
|
+
import { ReactNode } from 'react';
|
|
2
|
+
|
|
3
|
+
declare function generateSlug(text: string | ReactNode | undefined): string;
|
|
4
|
+
declare function useActiveHeading(): string;
|
|
5
|
+
|
|
6
|
+
export { generateSlug, useActiveHeading };
|
package/dist/src/client.js
CHANGED
|
@@ -1,35 +1,42 @@
|
|
|
1
1
|
"use client";
|
|
2
|
+
|
|
3
|
+
// src/client.ts
|
|
2
4
|
import { useEffect, useState } from "react";
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
: String(text);
|
|
10
|
-
return textString
|
|
11
|
-
.toLowerCase()
|
|
12
|
-
.replace(/[^\w\s-]/g, "")
|
|
13
|
-
.replace(/\s+/g, "-");
|
|
5
|
+
function generateSlug(text) {
|
|
6
|
+
if (text === void 0) {
|
|
7
|
+
return "";
|
|
8
|
+
}
|
|
9
|
+
const textString = typeof text === "string" ? text : String(text);
|
|
10
|
+
return textString.toLowerCase().replace(/[^\w\s-]/g, "").replace(/\s+/g, "-");
|
|
14
11
|
}
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
12
|
+
function useActiveHeading() {
|
|
13
|
+
const [activeId, setActiveId] = useState("");
|
|
14
|
+
useEffect(() => {
|
|
15
|
+
const headings = document.querySelectorAll(
|
|
16
|
+
"h1[id], h2[id], h3[id], h4[id]"
|
|
17
|
+
);
|
|
18
|
+
const observer = new IntersectionObserver(
|
|
19
|
+
(entries) => {
|
|
20
|
+
const visible = entries.filter((entry) => entry.isIntersecting).sort(
|
|
21
|
+
(a, b) => a.boundingClientRect.top - b.boundingClientRect.top
|
|
22
|
+
);
|
|
23
|
+
if (visible.length > 0) {
|
|
24
|
+
setActiveId(
|
|
25
|
+
visible[0].target.getAttribute("id") || ""
|
|
26
|
+
);
|
|
27
|
+
}
|
|
28
|
+
},
|
|
29
|
+
{
|
|
30
|
+
rootMargin: "0px 0px -70% 0px",
|
|
31
|
+
threshold: 0
|
|
32
|
+
}
|
|
33
|
+
);
|
|
34
|
+
headings.forEach((heading) => observer.observe(heading));
|
|
35
|
+
return () => observer.disconnect();
|
|
36
|
+
}, []);
|
|
37
|
+
return activeId;
|
|
34
38
|
}
|
|
35
|
-
|
|
39
|
+
export {
|
|
40
|
+
generateSlug,
|
|
41
|
+
useActiveHeading
|
|
42
|
+
};
|
package/dist/src/renderer.d.ts
CHANGED
|
@@ -1,7 +1,9 @@
|
|
|
1
|
-
import * as React from
|
|
2
|
-
import { getMDXComponent } from
|
|
3
|
-
|
|
1
|
+
import * as React from 'react';
|
|
2
|
+
import { getMDXComponent } from 'mdx-bundler/client/index.js';
|
|
3
|
+
|
|
4
|
+
declare function Content({ code, components, }: {
|
|
4
5
|
code: string;
|
|
5
6
|
components?: React.ComponentProps<ReturnType<typeof getMDXComponent>>["components"];
|
|
6
7
|
}): React.JSX.Element;
|
|
7
|
-
|
|
8
|
+
|
|
9
|
+
export { Content };
|
package/dist/src/renderer.js
CHANGED
|
@@ -1,10 +1,16 @@
|
|
|
1
1
|
"use client";
|
|
2
|
-
|
|
2
|
+
|
|
3
|
+
// src/renderer.tsx
|
|
3
4
|
import * as React from "react";
|
|
4
5
|
import { getMDXComponent } from "mdx-bundler/client/index.js";
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
6
|
+
import { jsx } from "react/jsx-runtime";
|
|
7
|
+
function Content({
|
|
8
|
+
code,
|
|
9
|
+
components
|
|
10
|
+
}) {
|
|
11
|
+
const Render = React.useMemo(() => getMDXComponent(code), [code]);
|
|
12
|
+
return /* @__PURE__ */ jsx(Render, { components });
|
|
9
13
|
}
|
|
10
|
-
|
|
14
|
+
export {
|
|
15
|
+
Content
|
|
16
|
+
};
|
package/package.json
CHANGED
|
@@ -1,43 +1,46 @@
|
|
|
1
|
-
{
|
|
2
|
-
"name": "postfolio",
|
|
3
|
-
"version": "1.0.
|
|
4
|
-
"type": "module",
|
|
5
|
-
"main": "./dist/
|
|
6
|
-
"types": "./dist/
|
|
7
|
-
"exports": {
|
|
8
|
-
"
|
|
9
|
-
"types": "./dist/
|
|
10
|
-
"import": "./dist/
|
|
11
|
-
},
|
|
12
|
-
"./renderer": {
|
|
13
|
-
"types": "./dist/src/renderer.d.ts",
|
|
14
|
-
"import": "./dist/src/renderer.js"
|
|
15
|
-
},
|
|
16
|
-
"./client": {
|
|
17
|
-
"types": "./dist/src/client.d.ts",
|
|
18
|
-
"import": "./dist/src/client.js"
|
|
19
|
-
}
|
|
20
|
-
},
|
|
21
|
-
"files": [
|
|
22
|
-
"dist"
|
|
23
|
-
],
|
|
24
|
-
"scripts": {
|
|
25
|
-
"build": "
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
"
|
|
30
|
-
"
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
"
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
"
|
|
42
|
-
}
|
|
43
|
-
|
|
1
|
+
{
|
|
2
|
+
"name": "postfolio",
|
|
3
|
+
"version": "1.0.5",
|
|
4
|
+
"type": "module",
|
|
5
|
+
"main": "./dist/server.js",
|
|
6
|
+
"types": "./dist/server.d.ts",
|
|
7
|
+
"exports": {
|
|
8
|
+
"./server": {
|
|
9
|
+
"types": "./dist/server.d.ts",
|
|
10
|
+
"import": "./dist/server.js"
|
|
11
|
+
},
|
|
12
|
+
"./renderer": {
|
|
13
|
+
"types": "./dist/src/renderer.d.ts",
|
|
14
|
+
"import": "./dist/src/renderer.js"
|
|
15
|
+
},
|
|
16
|
+
"./client": {
|
|
17
|
+
"types": "./dist/src/client.d.ts",
|
|
18
|
+
"import": "./dist/src/client.js"
|
|
19
|
+
}
|
|
20
|
+
},
|
|
21
|
+
"files": [
|
|
22
|
+
"dist"
|
|
23
|
+
],
|
|
24
|
+
"scripts": {
|
|
25
|
+
"build": "tsup",
|
|
26
|
+
"dev": "tsup --watch"
|
|
27
|
+
},
|
|
28
|
+
"dependencies": {
|
|
29
|
+
"esbuild": "^0.28.0",
|
|
30
|
+
"gray-matter": "^4.0.3",
|
|
31
|
+
"mdx-bundler": "^10.1.1",
|
|
32
|
+
"server-only": "^0.0.1"
|
|
33
|
+
},
|
|
34
|
+
"peerDependencies": {
|
|
35
|
+
"react": ">=19"
|
|
36
|
+
},
|
|
37
|
+
"devDependencies": {
|
|
38
|
+
"@types/node": "^20",
|
|
39
|
+
"@types/react": "^19",
|
|
40
|
+
"tsup": "^8.5.1",
|
|
41
|
+
"typescript": "^5"
|
|
42
|
+
},
|
|
43
|
+
"allowScripts": {
|
|
44
|
+
"esbuild@0.27.7": true
|
|
45
|
+
}
|
|
46
|
+
}
|
package/dist/index.d.ts
DELETED
package/dist/index.d.ts.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../index.ts"],"names":[],"mappings":"AACA,OAAO,EACL,KAAK,EACL,IAAI,EACJ,QAAQ,EACR,OAAO,EACP,YAAY,EACZ,WAAW,EACX,mBAAmB,GACpB,MAAM,eAAe,CAAC;AACvB,YAAY,EAAE,eAAe,EAAE,cAAc,EAAE,MAAM,eAAe,CAAC"}
|
package/dist/index.js
DELETED
package/dist/index.js.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../index.ts"],"names":[],"mappings":"AAAA,WAAW;AACX,OAAO,EACL,KAAK,EACL,IAAI,EACJ,QAAQ,EACR,OAAO,EACP,YAAY,EACZ,WAAW,EACX,mBAAmB,GACpB,MAAM,eAAe,CAAC"}
|
package/dist/src/client.d.ts.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"client.d.ts","sourceRoot":"","sources":["../../src/client.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,OAAO,CAAC;AAGvC,wBAAgB,YAAY,CAAC,IAAI,EAAE,MAAM,GAAG,SAAS,GAAG,SAAS,GAAG,MAAM,CAYzE;AAGD,wBAAgB,gBAAgB,WAmC/B"}
|
package/dist/src/client.js.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"client.js","sourceRoot":"","sources":["../../src/client.ts"],"names":[],"mappings":"AAAA,YAAY,CAAC;AAEb,OAAO,EAAE,SAAS,EAAE,QAAQ,EAAE,MAAM,OAAO,CAAC;AAE5C,MAAM,UAAU,YAAY,CAAC,IAAoC;IAC/D,IAAI,IAAI,KAAK,SAAS,EAAE,CAAC;QACvB,OAAO,EAAE,CAAC;IACZ,CAAC;IACD,MAAM,UAAU,GAAG,OAAO,IAAI,KAAK,QAAQ;QACzC,CAAC,CAAC,IAAI;QACN,CAAC,CAAC,MAAM,CAAC,IAAI,CAAC,CAAC;IAEjB,OAAO,UAAU;SACd,WAAW,EAAE;SACb,OAAO,CAAC,WAAW,EAAE,EAAE,CAAC;SACxB,OAAO,CAAC,MAAM,EAAE,GAAG,CAAC,CAAC;AAC1B,CAAC;AAGD,MAAM,UAAU,gBAAgB;IAC9B,MAAM,CAAC,QAAQ,EAAE,WAAW,CAAC,GAAG,QAAQ,CAAC,EAAE,CAAC,CAAC;IAE7C,SAAS,CAAC,GAAG,EAAE;QACb,MAAM,QAAQ,GAAG,QAAQ,CAAC,gBAAgB,CACxC,gCAAgC,CACjC,CAAC;QAEF,MAAM,QAAQ,GAAG,IAAI,oBAAoB,CACvC,CAAC,OAAO,EAAE,EAAE;YACV,MAAM,OAAO,GAAG,OAAO;iBACpB,MAAM,CAAC,CAAC,KAAK,EAAE,EAAE,CAAC,KAAK,CAAC,cAAc,CAAC;iBACvC,IAAI,CACH,CAAC,CAAC,EAAE,CAAC,EAAE,EAAE,CACP,CAAC,CAAC,kBAAkB,CAAC,GAAG,GAAG,CAAC,CAAC,kBAAkB,CAAC,GAAG,CACtD,CAAC;YAEJ,IAAI,OAAO,CAAC,MAAM,GAAG,CAAC,EAAE,CAAC;gBACvB,WAAW,CACT,OAAO,CAAC,CAAC,CAAC,CAAC,MAAM,CAAC,YAAY,CAAC,IAAI,CAAC,IAAI,EAAE,CAC3C,CAAC;YACJ,CAAC;QACH,CAAC,EACD;YACE,UAAU,EAAE,kBAAkB;YAC9B,SAAS,EAAE,CAAC;SACb,CACF,CAAC;QAEF,QAAQ,CAAC,OAAO,CAAC,CAAC,OAAO,EAAE,EAAE,CAAC,QAAQ,CAAC,OAAO,CAAC,OAAO,CAAC,CAAC,CAAC;QAEzD,OAAO,GAAG,EAAE,CAAC,QAAQ,CAAC,UAAU,EAAE,CAAC;IACrC,CAAC,EAAE,EAAE,CAAC,CAAC;IAEP,OAAO,QAAQ,CAAC;AAClB,CAAC"}
|
package/dist/src/main.d.ts
DELETED
|
@@ -1,35 +0,0 @@
|
|
|
1
|
-
export declare function setContentDirectory(newPath: string): void;
|
|
2
|
-
export type BlogFrontmatter = {
|
|
3
|
-
title?: string;
|
|
4
|
-
description?: string;
|
|
5
|
-
date?: string;
|
|
6
|
-
tags?: string[];
|
|
7
|
-
author?: string;
|
|
8
|
-
draft?: boolean;
|
|
9
|
-
[key: string]: string | string[] | boolean | undefined;
|
|
10
|
-
};
|
|
11
|
-
export type BlogPostSource = {
|
|
12
|
-
slug: string;
|
|
13
|
-
filename: string;
|
|
14
|
-
filePath: string;
|
|
15
|
-
mdx: string;
|
|
16
|
-
frontmatter?: any;
|
|
17
|
-
};
|
|
18
|
-
type TOCItem = {
|
|
19
|
-
level: number;
|
|
20
|
-
text: string;
|
|
21
|
-
slug: string;
|
|
22
|
-
};
|
|
23
|
-
export declare function generateSlug(text: string): string;
|
|
24
|
-
export declare function generateTOC(content: string): TOCItem[];
|
|
25
|
-
export declare function Slugs(): string[];
|
|
26
|
-
export declare function Post(slug: string): BlogPostSource | undefined;
|
|
27
|
-
export declare function allPosts(): Promise<BlogPostSource[]>;
|
|
28
|
-
export declare function MDXPost(slug: string): Promise<{
|
|
29
|
-
slug: string;
|
|
30
|
-
code: string;
|
|
31
|
-
frontmatter: any;
|
|
32
|
-
raw: string;
|
|
33
|
-
} | undefined>;
|
|
34
|
-
export {};
|
|
35
|
-
//# sourceMappingURL=main.d.ts.map
|
package/dist/src/main.d.ts.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"main.d.ts","sourceRoot":"","sources":["../../src/main.ts"],"names":[],"mappings":"AAOA,wBAAgB,mBAAmB,CAAC,OAAO,EAAE,MAAM,QAElD;AAED,MAAM,MAAM,eAAe,GAAG;IAC5B,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,IAAI,CAAC,EAAE,MAAM,EAAE,CAAC;IAChB,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,KAAK,CAAC,EAAE,OAAO,CAAC;IAEhB,CAAC,GAAG,EAAE,MAAM,GAAG,MAAM,GAAG,MAAM,EAAE,GAAG,OAAO,GAAG,SAAS,CAAC;CACxD,CAAC;AAEF,MAAM,MAAM,cAAc,GAAG;IAC3B,IAAI,EAAE,MAAM,CAAC;IACb,QAAQ,EAAE,MAAM,CAAC;IACjB,QAAQ,EAAE,MAAM,CAAC;IACjB,GAAG,EAAE,MAAM,CAAC;IACZ,WAAW,CAAC,EAAE,GAAG,CAAC;CACnB,CAAC;AA4CF,KAAK,OAAO,GAAG;IACb,KAAK,EAAE,MAAM,CAAC;IACd,IAAI,EAAE,MAAM,CAAC;IACb,IAAI,EAAE,MAAM,CAAC;CACd,CAAC;AAGF,wBAAgB,YAAY,CAAC,IAAI,EAAE,MAAM,UAKxC;AAED,wBAAgB,WAAW,CAAC,OAAO,EAAE,MAAM,GAAG,OAAO,EAAE,CAgBtD;AAED,wBAAgB,KAAK,IAAI,MAAM,EAAE,CAEhC;AAED,wBAAgB,IAAI,CAAC,IAAI,EAAE,MAAM,GAAG,cAAc,GAAG,SAAS,CAE7D;AAED,wBAAsB,QAAQ,IAAI,OAAO,CAAC,cAAc,EAAE,CAAC,CAgB1D;AAED,wBAAsB,OAAO,CAAC,IAAI,EAAE,MAAM;;;;;eAoBzC"}
|
package/dist/src/main.js
DELETED
|
@@ -1,94 +0,0 @@
|
|
|
1
|
-
import fs from "node:fs";
|
|
2
|
-
import path from "node:path";
|
|
3
|
-
import { bundleMDX } from "mdx-bundler";
|
|
4
|
-
let BLOG_DIR_PATH = path.join(process.cwd(), "content", "blogs");
|
|
5
|
-
export function setContentDirectory(newPath) {
|
|
6
|
-
BLOG_DIR_PATH = newPath;
|
|
7
|
-
}
|
|
8
|
-
function transformFilenameToSlug(filename) {
|
|
9
|
-
return filename
|
|
10
|
-
.replace(/\.mdx$/, "")
|
|
11
|
-
.toLowerCase()
|
|
12
|
-
.trim()
|
|
13
|
-
.replace(/[^a-z0-9\s-]/g, "")
|
|
14
|
-
.replace(/\s+/g, "-")
|
|
15
|
-
.replace(/-+/g, "-")
|
|
16
|
-
.replace(/^-+|-+$/g, "");
|
|
17
|
-
}
|
|
18
|
-
function getMdxFileNames() {
|
|
19
|
-
if (!fs.existsSync(BLOG_DIR_PATH)) {
|
|
20
|
-
return [];
|
|
21
|
-
}
|
|
22
|
-
return fs
|
|
23
|
-
.readdirSync(BLOG_DIR_PATH)
|
|
24
|
-
.filter((file) => file.endsWith(".mdx"));
|
|
25
|
-
}
|
|
26
|
-
function getPostSourceBySlug(slug) {
|
|
27
|
-
const filename = getMdxFileNames().find((file) => transformFilenameToSlug(file) === slug);
|
|
28
|
-
if (!filename) {
|
|
29
|
-
return undefined;
|
|
30
|
-
}
|
|
31
|
-
const filePath = path.join(BLOG_DIR_PATH, filename);
|
|
32
|
-
return {
|
|
33
|
-
slug,
|
|
34
|
-
filename,
|
|
35
|
-
filePath,
|
|
36
|
-
mdx: fs.readFileSync(filePath, "utf8"),
|
|
37
|
-
};
|
|
38
|
-
}
|
|
39
|
-
export function generateSlug(text) {
|
|
40
|
-
return text
|
|
41
|
-
.toLowerCase()
|
|
42
|
-
.replace(/[^\w\s-]/g, "")
|
|
43
|
-
.replace(/\s+/g, "-");
|
|
44
|
-
}
|
|
45
|
-
export function generateTOC(content) {
|
|
46
|
-
const headingRegex = /^(#{1,6})\s+(.+)$/gm;
|
|
47
|
-
return [...content.matchAll(headingRegex)].map((match) => {
|
|
48
|
-
const level = match[1].length;
|
|
49
|
-
const text = match[2].trim();
|
|
50
|
-
return {
|
|
51
|
-
level,
|
|
52
|
-
text,
|
|
53
|
-
slug: text
|
|
54
|
-
.toLowerCase()
|
|
55
|
-
.replace(/[^\w\s-]/g, "")
|
|
56
|
-
.replace(/\s+/g, "-"),
|
|
57
|
-
};
|
|
58
|
-
});
|
|
59
|
-
}
|
|
60
|
-
export function Slugs() {
|
|
61
|
-
return getMdxFileNames().map(transformFilenameToSlug);
|
|
62
|
-
}
|
|
63
|
-
export function Post(slug) {
|
|
64
|
-
return getPostSourceBySlug(slug);
|
|
65
|
-
}
|
|
66
|
-
export async function allPosts() {
|
|
67
|
-
const posts = Slugs()
|
|
68
|
-
.map(getPostSourceBySlug)
|
|
69
|
-
.filter((post) => Boolean(post));
|
|
70
|
-
return Promise.all(posts.map(async (post) => {
|
|
71
|
-
const { frontmatter } = await bundleMDX({
|
|
72
|
-
file: post.filePath,
|
|
73
|
-
cwd: BLOG_DIR_PATH,
|
|
74
|
-
});
|
|
75
|
-
return { ...post, frontmatter };
|
|
76
|
-
}));
|
|
77
|
-
}
|
|
78
|
-
export async function MDXPost(slug) {
|
|
79
|
-
const post = Post(slug);
|
|
80
|
-
if (!post) {
|
|
81
|
-
return undefined;
|
|
82
|
-
}
|
|
83
|
-
const { code, frontmatter } = await bundleMDX({
|
|
84
|
-
file: post.filePath,
|
|
85
|
-
cwd: BLOG_DIR_PATH,
|
|
86
|
-
});
|
|
87
|
-
return {
|
|
88
|
-
slug: post.slug,
|
|
89
|
-
code,
|
|
90
|
-
frontmatter,
|
|
91
|
-
raw: post.mdx
|
|
92
|
-
};
|
|
93
|
-
}
|
|
94
|
-
//# sourceMappingURL=main.js.map
|
package/dist/src/main.js.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"main.js","sourceRoot":"","sources":["../../src/main.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,SAAS,CAAC;AACzB,OAAO,IAAI,MAAM,WAAW,CAAC;AAE7B,OAAO,EAAE,SAAS,EAAE,MAAM,aAAa,CAAC;AAExC,IAAI,aAAa,GAAG,IAAI,CAAC,IAAI,CAAC,OAAO,CAAC,GAAG,EAAE,EAAE,SAAS,EAAE,OAAO,CAAC,CAAC;AAEjE,MAAM,UAAU,mBAAmB,CAAC,OAAe;IACjD,aAAa,GAAG,OAAO,CAAC;AAC1B,CAAC;AAuBD,SAAS,uBAAuB,CAAC,QAAgB;IAC/C,OAAO,QAAQ;SACZ,OAAO,CAAC,QAAQ,EAAE,EAAE,CAAC;SACrB,WAAW,EAAE;SACb,IAAI,EAAE;SACN,OAAO,CAAC,eAAe,EAAE,EAAE,CAAC;SAC5B,OAAO,CAAC,MAAM,EAAE,GAAG,CAAC;SACpB,OAAO,CAAC,KAAK,EAAE,GAAG,CAAC;SACnB,OAAO,CAAC,UAAU,EAAE,EAAE,CAAC,CAA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,CAAC,CAAC;IAEH,OAAO;QACL,IAAI,EAAE,IAAI,CAAC,IAAI;QACf,IAAI;QACJ,WAAW;QACX,GAAG,EAAE,IAAI,CAAC,GAAG;KACd,CAAC;AACJ,CAAC"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"renderer.d.ts","sourceRoot":"","sources":["../../src/renderer.tsx"],"names":[],"mappings":"AAEA,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;AAC/B,OAAO,EAAE,eAAe,EAAE,MAAM,6BAA6B,CAAC;AAE9D,wBAAgB,OAAO,CAAC,EACtB,IAAI,EACJ,UAAU,GACX,EAAE;IACD,IAAI,EAAE,MAAM,CAAC;IACb,UAAU,CAAC,EAAE,KAAK,CAAC,cAAc,CAC/B,UAAU,CAAC,OAAO,eAAe,CAAC,CACnC,CAAC,YAAY,CAAC,CAAC;CACjB,qBAKA"}
|
package/dist/src/renderer.js.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"renderer.js","sourceRoot":"","sources":["../../src/renderer.tsx"],"names":[],"mappings":"AAAA,YAAY,CAAC;;AAEb,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;AAC/B,OAAO,EAAE,eAAe,EAAE,MAAM,6BAA6B,CAAC;AAE9D,MAAM,UAAU,OAAO,CAAC,EACtB,IAAI,EACJ,UAAU,GAMX;IACC,MAAM,MAAM,GAAG,KAAK,CAAC,OAAO,CAAC,GAAG,EAAE,CAAC,eAAe,CAAC,IAAI,CAAC,EAAE,CAAC,IAAI,CAAC,CAAC,CAAC;IAElE,0HAA0H;IAC1H,OAAO,KAAC,MAAM,IAAC,UAAU,EAAE,UAAU,GAAI,CAAC;AAC5C,CAAC"}
|