postfolio 1.0.5 → 1.0.7

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.
@@ -0,0 +1,12 @@
1
+ // src/utils.ts
2
+ function generateSlug(text) {
3
+ if (text === void 0) {
4
+ return "";
5
+ }
6
+ const textString = typeof text === "string" ? text : String(text);
7
+ return textString.toLowerCase().replace(/[^\w\s-]/g, "").replace(/\s+/g, "-").replace(/-+/g, "-").replace(/^-+|-+$/g, "");
8
+ }
9
+
10
+ export {
11
+ generateSlug
12
+ };
@@ -0,0 +1,44 @@
1
+ // src/client.tsx
2
+ import * as React from "react";
3
+ import { useEffect, useState } from "react";
4
+ import { getMDXComponent } from "mdx-bundler/client";
5
+ import { jsx } from "react/jsx-runtime";
6
+ function useActiveHeading() {
7
+ const [activeId, setActiveId] = useState("");
8
+ useEffect(() => {
9
+ const headings = document.querySelectorAll(
10
+ "h1[id], h2[id], h3[id], h4[id]"
11
+ );
12
+ const observer = new IntersectionObserver(
13
+ (entries) => {
14
+ const visible = entries.filter((entry) => entry.isIntersecting).sort(
15
+ (a, b) => a.boundingClientRect.top - b.boundingClientRect.top
16
+ );
17
+ if (visible.length > 0) {
18
+ setActiveId(
19
+ visible[0].target.getAttribute("id") || ""
20
+ );
21
+ }
22
+ },
23
+ {
24
+ rootMargin: "0px 0px -70% 0px",
25
+ threshold: 0
26
+ }
27
+ );
28
+ headings.forEach((heading) => observer.observe(heading));
29
+ return () => observer.disconnect();
30
+ }, []);
31
+ return activeId;
32
+ }
33
+ function Content({
34
+ code,
35
+ components
36
+ }) {
37
+ const Render = React.useMemo(() => getMDXComponent(code), [code]);
38
+ return /* @__PURE__ */ jsx(Render, { components });
39
+ }
40
+
41
+ export {
42
+ useActiveHeading,
43
+ Content
44
+ };
@@ -0,0 +1,10 @@
1
+ import * as React from "react";
2
+ import { getMDXComponent } from "mdx-bundler/client";
3
+ import { generateSlug } from "./utils.js";
4
+ export { generateSlug };
5
+ export declare function useActiveHeading(): string;
6
+ export declare function Content({ code, components, }: {
7
+ code: string;
8
+ components?: React.ComponentProps<ReturnType<typeof getMDXComponent>>["components"];
9
+ }): React.JSX.Element;
10
+ //# sourceMappingURL=client.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"client.d.ts","sourceRoot":"","sources":["../src/client.tsx"],"names":[],"mappings":"AAEA,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;AAE/B,OAAO,EAAE,eAAe,EAAE,MAAM,oBAAoB,CAAC;AACrD,OAAO,EAAE,YAAY,EAAE,MAAM,YAAY,CAAC;AAE1C,OAAO,EAAE,YAAY,EAAE,CAAC;AAExB,wBAAgB,gBAAgB,WAmC/B;AAED,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/client.js ADDED
@@ -0,0 +1,33 @@
1
+ "use client";
2
+ import { jsx as _jsx } from "react/jsx-runtime";
3
+ import * as React from "react";
4
+ import { useEffect, useState } from "react";
5
+ import { getMDXComponent } from "mdx-bundler/client";
6
+ import { generateSlug } from "./utils.js";
7
+ export { generateSlug };
8
+ export function useActiveHeading() {
9
+ const [activeId, setActiveId] = useState("");
10
+ useEffect(() => {
11
+ const headings = document.querySelectorAll("h1[id], h2[id], h3[id], h4[id]");
12
+ const observer = new IntersectionObserver((entries) => {
13
+ const visible = entries
14
+ .filter((entry) => entry.isIntersecting)
15
+ .sort((a, b) => a.boundingClientRect.top - b.boundingClientRect.top);
16
+ if (visible.length > 0) {
17
+ setActiveId(visible[0].target.getAttribute("id") || "");
18
+ }
19
+ }, {
20
+ rootMargin: "0px 0px -70% 0px",
21
+ threshold: 0,
22
+ });
23
+ headings.forEach((heading) => observer.observe(heading));
24
+ return () => observer.disconnect();
25
+ }, []);
26
+ return activeId;
27
+ }
28
+ export function Content({ code, components, }) {
29
+ const Render = React.useMemo(() => getMDXComponent(code), [code]);
30
+ // eslint-disable-next-line react-hooks/static-components -- mdx-bundler creates a component from compiled MDX at runtime.
31
+ return _jsx(Render, { components: components });
32
+ }
33
+ //# sourceMappingURL=client.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"client.js","sourceRoot":"","sources":["../src/client.tsx"],"names":[],"mappings":"AAAA,YAAY,CAAC;;AAEb,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;AAC/B,OAAO,EAAE,SAAS,EAAE,QAAQ,EAAE,MAAM,OAAO,CAAC;AAC5C,OAAO,EAAE,eAAe,EAAE,MAAM,oBAAoB,CAAC;AACrD,OAAO,EAAE,YAAY,EAAE,MAAM,YAAY,CAAC;AAE1C,OAAO,EAAE,YAAY,EAAE,CAAC;AAExB,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;AAED,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"}
@@ -0,0 +1,5 @@
1
+ import "server-only";
2
+ export { Slugs, Post, allPosts, MDXPost, generateSlug, generateTOC } from "./server.js";
3
+ export { Content, useActiveHeading } from "./client.js";
4
+ export type { BlogFrontmatter, BlogPostSource } from "./server.js";
5
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AACA,OAAO,aAAa,CAAC;AACrB,OAAO,EACL,KAAK,EACL,IAAI,EACJ,QAAQ,EACR,OAAO,EACP,YAAY,EACZ,WAAW,EACZ,MAAM,aAAa,CAAC;AACrB,OAAO,EAAE,OAAO,EAAE,gBAAgB,EAAE,MAAM,aAAa,CAAC;AACxD,YAAY,EAAE,eAAe,EAAE,cAAc,EAAE,MAAM,aAAa,CAAC"}
package/dist/index.js ADDED
@@ -0,0 +1,5 @@
1
+ // index.ts
2
+ import "server-only";
3
+ export { Slugs, Post, allPosts, MDXPost, generateSlug, generateTOC } from "./server.js";
4
+ export { Content, useActiveHeading } from "./client.js";
5
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,WAAW;AACX,OAAO,aAAa,CAAC;AACrB,OAAO,EACL,KAAK,EACL,IAAI,EACJ,QAAQ,EACR,OAAO,EACP,YAAY,EACZ,WAAW,EACZ,MAAM,aAAa,CAAC;AACrB,OAAO,EAAE,OAAO,EAAE,gBAAgB,EAAE,MAAM,aAAa,CAAC"}
@@ -0,0 +1,7 @@
1
+ import * as React from "react";
2
+ import { getMDXComponent } from "mdx-bundler/client";
3
+ export declare function Content({ code, components, }: {
4
+ code: string;
5
+ components?: React.ComponentProps<ReturnType<typeof getMDXComponent>>["components"];
6
+ }): React.JSX.Element;
7
+ //# sourceMappingURL=renderer.d.ts.map
@@ -0,0 +1 @@
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,oBAAoB,CAAC;AAErD,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"}
@@ -0,0 +1,10 @@
1
+ "use client";
2
+ import { jsx as _jsx } from "react/jsx-runtime";
3
+ import * as React from "react";
4
+ import { getMDXComponent } from "mdx-bundler/client";
5
+ export function Content({ code, components, }) {
6
+ const Render = React.useMemo(() => getMDXComponent(code), [code]);
7
+ // eslint-disable-next-line react-hooks/static-components -- mdx-bundler creates a component from compiled MDX at runtime.
8
+ return _jsx(Render, { components: components });
9
+ }
10
+ //# sourceMappingURL=renderer.js.map
@@ -0,0 +1 @@
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,oBAAoB,CAAC;AAErD,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"}
package/dist/server.d.ts CHANGED
@@ -1,5 +1,6 @@
1
- declare function setContentDirectory(newPath: string): void;
2
- type BlogFrontmatter = {
1
+ import "server-only";
2
+ import { generateSlug } from "./utils.js";
3
+ export type BlogFrontmatter = {
3
4
  title?: string;
4
5
  description?: string;
5
6
  date?: string;
@@ -8,28 +9,27 @@ type BlogFrontmatter = {
8
9
  draft?: boolean;
9
10
  [key: string]: string | string[] | boolean | undefined;
10
11
  };
11
- type BlogPostSource = {
12
+ export type BlogPostSource = {
12
13
  slug: string;
13
14
  filename: string;
14
15
  filePath: string;
15
16
  mdx: string;
16
- frontmatter?: any;
17
+ frontmatter?: BlogFrontmatter;
17
18
  };
18
19
  type TOCItem = {
19
20
  level: number;
20
21
  text: string;
21
22
  slug: string;
22
23
  };
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<{
24
+ export { generateSlug };
25
+ export declare function generateTOC(content: string): TOCItem[];
26
+ export declare function Slugs(contentDir: string): string[];
27
+ export declare function Post(slug: string, contentDir: string): BlogPostSource | undefined;
28
+ export declare function allPosts(contentDir: string): Promise<BlogPostSource[]>;
29
+ export declare function MDXPost(slug: string, contentDir: string): Promise<{
29
30
  slug: string;
30
31
  code: string;
31
- frontmatter: any;
32
+ frontmatter: BlogFrontmatter;
32
33
  raw: string;
33
34
  } | undefined>;
34
-
35
- export { type BlogFrontmatter, type BlogPostSource, MDXPost, Post, Slugs, allPosts, generateSlug, generateTOC, setContentDirectory };
35
+ //# sourceMappingURL=server.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"server.d.ts","sourceRoot":"","sources":["../src/server.ts"],"names":[],"mappings":"AAAA,OAAO,aAAa,CAAC;AAMrB,OAAO,EAAE,YAAY,EAAE,MAAM,YAAY,CAAC;AAE1C,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;IAChB,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,eAAe,CAAC;CAC/B,CAAC;AAEF,KAAK,OAAO,GAAG;IACb,KAAK,EAAE,MAAM,CAAC;IACd,IAAI,EAAE,MAAM,CAAC;IACb,IAAI,EAAE,MAAM,CAAC;CACd,CAAC;AAEF,OAAO,EAAE,YAAY,EAAE,CAAC;AA+CxB,wBAAgB,WAAW,CAAC,OAAO,EAAE,MAAM,GAAG,OAAO,EAAE,CAQtD;AAED,wBAAgB,KAAK,CAAC,UAAU,EAAE,MAAM,GAAG,MAAM,EAAE,CAElD;AAED,wBAAgB,IAAI,CAClB,IAAI,EAAE,MAAM,EACZ,UAAU,EAAE,MAAM,GACjB,cAAc,GAAG,SAAS,CAE5B;AAED,wBAAsB,QAAQ,CAC5B,UAAU,EAAE,MAAM,GACjB,OAAO,CAAC,cAAc,EAAE,CAAC,CAY3B;AAED,wBAAsB,OAAO,CAC3B,IAAI,EAAE,MAAM,EACZ,UAAU,EAAE,MAAM;;;;;eAqBnB"}
package/dist/server.js CHANGED
@@ -1,91 +1,83 @@
1
- // src/server.ts
2
1
  import "server-only";
3
- import fs from "fs";
4
- import path from "path";
2
+ import fs from "node:fs";
3
+ import path from "node:path";
4
+ import matter from "gray-matter";
5
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
- }
6
+ import { generateSlug } from "./utils.js";
7
+ export { generateSlug };
10
8
  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"));
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, "");
18
17
  }
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
- };
18
+ function getMdxFileNames(contentDir) {
19
+ if (!fs.existsSync(contentDir)) {
20
+ return [];
21
+ }
22
+ return fs
23
+ .readdirSync(contentDir)
24
+ .filter((file) => file.endsWith(".mdx"));
33
25
  }
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();
26
+ function getPostSourceBySlug(slug, contentDir) {
27
+ const resolvedDir = path.resolve(contentDir);
28
+ const filename = getMdxFileNames(resolvedDir).find((file) => transformFilenameToSlug(file) === slug);
29
+ if (!filename) {
30
+ return undefined;
31
+ }
32
+ const filePath = path.resolve(resolvedDir, filename);
42
33
  return {
43
- level,
44
- text,
45
- slug: text.toLowerCase().replace(/[^\w\s-]/g, "").replace(/\s+/g, "-")
34
+ slug,
35
+ filename,
36
+ filePath,
37
+ mdx: fs.readFileSync(filePath, "utf8"),
46
38
  };
47
- });
48
39
  }
49
- function Slugs() {
50
- return getMdxFileNames().map(transformFilenameToSlug);
40
+ export function generateTOC(content) {
41
+ const headingRegex = /^(#{1,6})\s+(.+)$/gm;
42
+ return [...content.matchAll(headingRegex)].map(([_, hashes, text]) => ({
43
+ level: hashes.length,
44
+ text: text.trim(),
45
+ slug: generateSlug(text.trim()),
46
+ }));
51
47
  }
52
- function Post(slug) {
53
- return getPostSourceBySlug(slug);
48
+ export function Slugs(contentDir) {
49
+ return getMdxFileNames(contentDir).map(transformFilenameToSlug);
54
50
  }
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
- );
51
+ export function Post(slug, contentDir) {
52
+ return getPostSourceBySlug(slug, contentDir);
66
53
  }
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
- };
54
+ export async function allPosts(contentDir) {
55
+ return Slugs(contentDir)
56
+ .map((slug) => getPostSourceBySlug(slug, contentDir))
57
+ .filter((post) => Boolean(post))
58
+ .map((post) => {
59
+ const { data: frontmatter } = matter(post.mdx);
60
+ return {
61
+ ...post,
62
+ frontmatter,
63
+ };
64
+ });
65
+ }
66
+ export async function MDXPost(slug, contentDir) {
67
+ const resolvedDir = path.resolve(contentDir);
68
+ const post = getPostSourceBySlug(slug, resolvedDir);
69
+ if (!post) {
70
+ return undefined;
71
+ }
72
+ const { code, frontmatter } = await bundleMDX({
73
+ file: post.filePath,
74
+ cwd: resolvedDir,
75
+ });
76
+ return {
77
+ slug: post.slug,
78
+ code,
79
+ frontmatter,
80
+ raw: post.mdx,
81
+ };
82
82
  }
83
- export {
84
- MDXPost,
85
- Post,
86
- Slugs,
87
- allPosts,
88
- generateSlug,
89
- generateTOC,
90
- setContentDirectory
91
- };
83
+ //# sourceMappingURL=server.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"server.js","sourceRoot":"","sources":["../src/server.ts"],"names":[],"mappings":"AAAA,OAAO,aAAa,CAAC;AACrB,OAAO,EAAE,MAAM,SAAS,CAAC;AACzB,OAAO,IAAI,MAAM,WAAW,CAAC;AAC7B,OAAO,MAAM,MAAM,aAAa,CAAC;AACjC,OAAO,EAAE,SAAS,EAAE,MAAM,aAAa,CAAC;AAExC,OAAO,EAAE,YAAY,EAAE,MAAM,YAAY,CA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AAM,IAAI,GAAG,mBAAmB,CAAC,IAAI,EAAE,WAAW,CAAC,CAAC;IAEpD,IAAI,CAAC,IAAI,EAAE,CAAC;QACV,OAAO,SAAS,CAAC;IACnB,CAAC;IAED,MAAM,EAAE,IAAI,EAAE,WAAW,EAAE,GAAG,MAAM,SAAS,CAAkB;QAC7D,IAAI,EAAE,IAAI,CAAC,QAAQ;QACnB,GAAG,EAAE,WAAW;KACjB,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,42 +1,13 @@
1
1
  "use client";
2
-
3
- // src/client.ts
4
- import { useEffect, useState } from "react";
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, "-");
11
- }
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;
38
- }
2
+ import {
3
+ Content,
4
+ useActiveHeading
5
+ } from "../chunk-JIP5R5U4.js";
6
+ import {
7
+ generateSlug
8
+ } from "../chunk-6PC5ONQ5.js";
39
9
  export {
10
+ Content,
40
11
  generateSlug,
41
12
  useActiveHeading
42
13
  };
@@ -0,0 +1,6 @@
1
+ import {
2
+ generateSlug
3
+ } from "../chunk-6PC5ONQ5.js";
4
+ export {
5
+ generateSlug
6
+ };
@@ -0,0 +1,6 @@
1
+ import type { ReactNode } from "react";
2
+ /**
3
+ * Generates a URL-friendly slug from a string or React node.
4
+ */
5
+ export declare function generateSlug(text: string | ReactNode | undefined): string;
6
+ //# sourceMappingURL=utils.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"utils.d.ts","sourceRoot":"","sources":["../src/utils.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,OAAO,CAAC;AAEvC;;GAEG;AACH,wBAAgB,YAAY,CAAC,IAAI,EAAE,MAAM,GAAG,SAAS,GAAG,SAAS,GAAG,MAAM,CAezE"}
package/dist/utils.js ADDED
@@ -0,0 +1,18 @@
1
+ /**
2
+ * Generates a URL-friendly slug from a string or React node.
3
+ */
4
+ export function generateSlug(text) {
5
+ if (text === undefined) {
6
+ return "";
7
+ }
8
+ const textString = typeof text === "string"
9
+ ? text
10
+ : String(text);
11
+ return textString
12
+ .toLowerCase()
13
+ .replace(/[^\w\s-]/g, "")
14
+ .replace(/\s+/g, "-")
15
+ .replace(/-+/g, "-")
16
+ .replace(/^-+|-+$/g, "");
17
+ }
18
+ //# sourceMappingURL=utils.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"utils.js","sourceRoot":"","sources":["../src/utils.ts"],"names":[],"mappings":"AAEA;;GAEG;AACH,MAAM,UAAU,YAAY,CAAC,IAAoC;IAC/D,IAAI,IAAI,KAAK,SAAS,EAAE,CAAC;QACvB,OAAO,EAAE,CAAC;IACZ,CAAC;IAED,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;SACpB,OAAO,CAAC,KAAK,EAAE,GAAG,CAAC;SACnB,OAAO,CAAC,UAAU,EAAE,EAAE,CAAC,CAAC;AAC7B,CAAC"}
package/package.json CHANGED
@@ -1,29 +1,43 @@
1
1
  {
2
2
  "name": "postfolio",
3
- "version": "1.0.5",
3
+ "version": "1.0.7",
4
4
  "type": "module",
5
5
  "main": "./dist/server.js",
6
6
  "types": "./dist/server.d.ts",
7
7
  "exports": {
8
+ ".": {
9
+ "react-server": {
10
+ "types": "./dist/server.d.ts",
11
+ "import": "./dist/server.js"
12
+ },
13
+ "default": {
14
+ "types": "./dist/client.d.ts",
15
+ "import": "./dist/client.js"
16
+ }
17
+ },
8
18
  "./server": {
9
19
  "types": "./dist/server.d.ts",
10
20
  "import": "./dist/server.js"
11
21
  },
22
+ "./client": {
23
+ "types": "./dist/client.d.ts",
24
+ "import": "./dist/client.js"
25
+ },
12
26
  "./renderer": {
13
- "types": "./dist/src/renderer.d.ts",
14
- "import": "./dist/src/renderer.js"
27
+ "types": "./dist/renderer.d.ts",
28
+ "import": "./dist/renderer.js"
15
29
  },
16
- "./client": {
17
- "types": "./dist/src/client.d.ts",
18
- "import": "./dist/src/client.js"
30
+ "./utils": {
31
+ "types": "./dist/utils.d.ts",
32
+ "import": "./dist/utils.js"
19
33
  }
20
34
  },
21
35
  "files": [
22
36
  "dist"
23
37
  ],
24
38
  "scripts": {
25
- "build": "tsup",
26
- "dev": "tsup --watch"
39
+ "build": "tsc",
40
+ "dev": "tsc --watch"
27
41
  },
28
42
  "dependencies": {
29
43
  "esbuild": "^0.28.0",
@@ -37,10 +51,9 @@
37
51
  "devDependencies": {
38
52
  "@types/node": "^20",
39
53
  "@types/react": "^19",
40
- "tsup": "^8.5.1",
41
54
  "typescript": "^5"
42
55
  },
43
56
  "allowScripts": {
44
- "esbuild@0.27.7": true
57
+ "esbuild@0.28.0": true
45
58
  }
46
59
  }
@@ -1,6 +0,0 @@
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 };
@@ -1,9 +0,0 @@
1
- import * as React from 'react';
2
- import { getMDXComponent } from 'mdx-bundler/client/index.js';
3
-
4
- declare function Content({ code, components, }: {
5
- code: string;
6
- components?: React.ComponentProps<ReturnType<typeof getMDXComponent>>["components"];
7
- }): React.JSX.Element;
8
-
9
- export { Content };
@@ -1,16 +0,0 @@
1
- "use client";
2
-
3
- // src/renderer.tsx
4
- import * as React from "react";
5
- import { getMDXComponent } from "mdx-bundler/client/index.js";
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 });
13
- }
14
- export {
15
- Content
16
- };