@haroonwaves/blog-kit-react 0.0.5 → 0.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.
- package/dist/index.cjs +16 -16
- package/dist/index.d.cts +5 -6
- package/dist/index.d.ts +5 -6
- package/dist/index.js +15 -15
- package/package.json +1 -1
package/dist/index.cjs
CHANGED
|
@@ -33,12 +33,12 @@ __export(src_exports, {
|
|
|
33
33
|
BlogCard: () => BlogCard,
|
|
34
34
|
BlogList: () => BlogList,
|
|
35
35
|
BlogPlaceholder: () => BlogPlaceholder,
|
|
36
|
-
|
|
36
|
+
BlogRenderer: () => BlogRenderer,
|
|
37
37
|
useBlogs: () => useBlogs
|
|
38
38
|
});
|
|
39
39
|
module.exports = __toCommonJS(src_exports);
|
|
40
40
|
|
|
41
|
-
// src/components/
|
|
41
|
+
// src/components/BlogRenderer.tsx
|
|
42
42
|
var import_react_markdown = __toESM(require("react-markdown"), 1);
|
|
43
43
|
var import_remark_gfm = __toESM(require("remark-gfm"), 1);
|
|
44
44
|
var import_rehype_prism_plus = __toESM(require("rehype-prism-plus"), 1);
|
|
@@ -56,7 +56,7 @@ function Badge({ children, className }) {
|
|
|
56
56
|
);
|
|
57
57
|
}
|
|
58
58
|
|
|
59
|
-
// src/components/
|
|
59
|
+
// src/components/BlogRenderer.tsx
|
|
60
60
|
var import_jsx_runtime2 = require("react/jsx-runtime");
|
|
61
61
|
function BlogRenderer({ content, metadata, className = "", components }) {
|
|
62
62
|
const defaultComponents = {
|
|
@@ -135,7 +135,7 @@ function BlogRenderer({ content, metadata, className = "", components }) {
|
|
|
135
135
|
// src/components/BlogCard.tsx
|
|
136
136
|
var import_jsx_runtime3 = require("react/jsx-runtime");
|
|
137
137
|
function BlogCard({
|
|
138
|
-
|
|
138
|
+
metadata,
|
|
139
139
|
basePath = "/blog",
|
|
140
140
|
renderLink,
|
|
141
141
|
className = "",
|
|
@@ -143,7 +143,7 @@ function BlogCard({
|
|
|
143
143
|
showReadingTime = true,
|
|
144
144
|
showDate = true
|
|
145
145
|
}) {
|
|
146
|
-
const href = `${basePath}/${
|
|
146
|
+
const href = `${basePath}/${metadata.slug}`;
|
|
147
147
|
const defaultLink = (href2, children) => /* @__PURE__ */ (0, import_jsx_runtime3.jsx)("a", { href: href2, children });
|
|
148
148
|
const Link = renderLink || defaultLink;
|
|
149
149
|
return /* @__PURE__ */ (0, import_jsx_runtime3.jsxs)(
|
|
@@ -152,11 +152,11 @@ function BlogCard({
|
|
|
152
152
|
className: `bg-white rounded-lg border border-gray-200 hover:border-gray-300 p-6 transition-colors ${className}`,
|
|
153
153
|
children: [
|
|
154
154
|
/* @__PURE__ */ (0, import_jsx_runtime3.jsx)("div", { className: "flex items-center justify-between mb-3", children: /* @__PURE__ */ (0, import_jsx_runtime3.jsxs)("div", { className: "flex items-center gap-3", children: [
|
|
155
|
-
showCategory &&
|
|
155
|
+
showCategory && metadata.category && /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(Badge, { children: metadata.category }),
|
|
156
156
|
(showReadingTime || showDate) && /* @__PURE__ */ (0, import_jsx_runtime3.jsxs)("div", { className: "flex items-center gap-2 text-sm text-gray-500", children: [
|
|
157
|
-
showReadingTime && /* @__PURE__ */ (0, import_jsx_runtime3.jsx)("span", { children:
|
|
157
|
+
showReadingTime && /* @__PURE__ */ (0, import_jsx_runtime3.jsx)("span", { children: metadata.readingTime }),
|
|
158
158
|
showReadingTime && showDate && /* @__PURE__ */ (0, import_jsx_runtime3.jsx)("span", { children: "\u2022" }),
|
|
159
|
-
showDate && /* @__PURE__ */ (0, import_jsx_runtime3.jsx)("time", { dateTime:
|
|
159
|
+
showDate && /* @__PURE__ */ (0, import_jsx_runtime3.jsx)("time", { dateTime: metadata.date, children: new Date(metadata.date).toLocaleDateString("en-US", {
|
|
160
160
|
year: "numeric",
|
|
161
161
|
month: "long",
|
|
162
162
|
day: "numeric"
|
|
@@ -165,9 +165,9 @@ function BlogCard({
|
|
|
165
165
|
] }) }),
|
|
166
166
|
Link(
|
|
167
167
|
href,
|
|
168
|
-
/* @__PURE__ */ (0, import_jsx_runtime3.jsx)("h2", { className: "font-semibold text-xl text-gray-700 mb-2 hover:underline transition-colors", children:
|
|
168
|
+
/* @__PURE__ */ (0, import_jsx_runtime3.jsx)("h2", { className: "font-semibold text-xl text-gray-700 mb-2 hover:underline transition-colors", children: metadata.title })
|
|
169
169
|
),
|
|
170
|
-
/* @__PURE__ */ (0, import_jsx_runtime3.jsx)("p", { className: "text-sm text-gray-500 leading-6 mb-4", children:
|
|
170
|
+
/* @__PURE__ */ (0, import_jsx_runtime3.jsx)("p", { className: "text-sm text-gray-500 leading-6 mb-4", children: metadata.description }),
|
|
171
171
|
Link(
|
|
172
172
|
href,
|
|
173
173
|
/* @__PURE__ */ (0, import_jsx_runtime3.jsx)("span", { className: "inline-flex items-center text-blue-600 hover:text-blue-700 font-medium text-sm", children: "Read more \u2192" })
|
|
@@ -180,25 +180,25 @@ function BlogCard({
|
|
|
180
180
|
// src/components/BlogList.tsx
|
|
181
181
|
var import_jsx_runtime4 = require("react/jsx-runtime");
|
|
182
182
|
function BlogList({
|
|
183
|
-
|
|
183
|
+
metadata,
|
|
184
184
|
basePath = "/blog",
|
|
185
185
|
renderLink,
|
|
186
186
|
className = "",
|
|
187
187
|
emptyMessage = "No blog posts found.",
|
|
188
188
|
cardProps
|
|
189
189
|
}) {
|
|
190
|
-
if (
|
|
190
|
+
if (metadata.length === 0) {
|
|
191
191
|
return /* @__PURE__ */ (0, import_jsx_runtime4.jsx)("div", { className: `text-center text-gray-500 py-12 ${className}`, children: emptyMessage });
|
|
192
192
|
}
|
|
193
|
-
return /* @__PURE__ */ (0, import_jsx_runtime4.jsx)("div", { className: `space-y-6 ${className}`, children:
|
|
193
|
+
return /* @__PURE__ */ (0, import_jsx_runtime4.jsx)("div", { className: `space-y-6 ${className}`, children: metadata.map((meta) => /* @__PURE__ */ (0, import_jsx_runtime4.jsx)(
|
|
194
194
|
BlogCard,
|
|
195
195
|
{
|
|
196
|
-
|
|
196
|
+
metadata: meta,
|
|
197
197
|
basePath,
|
|
198
198
|
renderLink,
|
|
199
199
|
...cardProps
|
|
200
200
|
},
|
|
201
|
-
|
|
201
|
+
meta.slug
|
|
202
202
|
)) });
|
|
203
203
|
}
|
|
204
204
|
|
|
@@ -247,6 +247,6 @@ function useBlogs(blogs) {
|
|
|
247
247
|
BlogCard,
|
|
248
248
|
BlogList,
|
|
249
249
|
BlogPlaceholder,
|
|
250
|
-
|
|
250
|
+
BlogRenderer,
|
|
251
251
|
useBlogs
|
|
252
252
|
});
|
package/dist/index.d.cts
CHANGED
|
@@ -13,7 +13,6 @@ interface BlogMeta {
|
|
|
13
13
|
interface Blog {
|
|
14
14
|
metadata: BlogMeta;
|
|
15
15
|
content: string;
|
|
16
|
-
readingTime: string;
|
|
17
16
|
}
|
|
18
17
|
interface BlogConfig {
|
|
19
18
|
contentDirectory: string;
|
|
@@ -29,7 +28,7 @@ interface BlogRendererProps {
|
|
|
29
28
|
declare function BlogRenderer({ content, metadata, className, components }: BlogRendererProps): react_jsx_runtime.JSX.Element;
|
|
30
29
|
|
|
31
30
|
interface BlogCardProps {
|
|
32
|
-
|
|
31
|
+
metadata: BlogMeta;
|
|
33
32
|
basePath?: string;
|
|
34
33
|
renderLink?: (href: string, children: react__default.ReactNode) => react__default.ReactNode;
|
|
35
34
|
className?: string;
|
|
@@ -37,17 +36,17 @@ interface BlogCardProps {
|
|
|
37
36
|
showReadingTime?: boolean;
|
|
38
37
|
showDate?: boolean;
|
|
39
38
|
}
|
|
40
|
-
declare function BlogCard({
|
|
39
|
+
declare function BlogCard({ metadata, basePath, renderLink, className, showCategory, showReadingTime, showDate, }: BlogCardProps): react_jsx_runtime.JSX.Element;
|
|
41
40
|
|
|
42
41
|
interface BlogListProps {
|
|
43
|
-
|
|
42
|
+
metadata: BlogMeta[];
|
|
44
43
|
basePath?: string;
|
|
45
44
|
renderLink?: BlogCardProps['renderLink'];
|
|
46
45
|
className?: string;
|
|
47
46
|
emptyMessage?: string;
|
|
48
47
|
cardProps?: Omit<BlogCardProps, 'blog' | 'basePath' | 'renderLink'>;
|
|
49
48
|
}
|
|
50
|
-
declare function BlogList({
|
|
49
|
+
declare function BlogList({ metadata, basePath, renderLink, className, emptyMessage, cardProps, }: BlogListProps): react_jsx_runtime.JSX.Element;
|
|
51
50
|
|
|
52
51
|
interface BlogPlaceholderProps {
|
|
53
52
|
count?: number;
|
|
@@ -64,4 +63,4 @@ declare function useBlogs(blogs: BlogMeta[]): {
|
|
|
64
63
|
categories: string[];
|
|
65
64
|
};
|
|
66
65
|
|
|
67
|
-
export { type Blog, BlogCard, type BlogCardProps, type BlogConfig, BlogList, type BlogListProps, type BlogMeta, BlogPlaceholder, type BlogPlaceholderProps, BlogRenderer
|
|
66
|
+
export { type Blog, BlogCard, type BlogCardProps, type BlogConfig, BlogList, type BlogListProps, type BlogMeta, BlogPlaceholder, type BlogPlaceholderProps, BlogRenderer, type BlogRendererProps, useBlogs };
|
package/dist/index.d.ts
CHANGED
|
@@ -13,7 +13,6 @@ interface BlogMeta {
|
|
|
13
13
|
interface Blog {
|
|
14
14
|
metadata: BlogMeta;
|
|
15
15
|
content: string;
|
|
16
|
-
readingTime: string;
|
|
17
16
|
}
|
|
18
17
|
interface BlogConfig {
|
|
19
18
|
contentDirectory: string;
|
|
@@ -29,7 +28,7 @@ interface BlogRendererProps {
|
|
|
29
28
|
declare function BlogRenderer({ content, metadata, className, components }: BlogRendererProps): react_jsx_runtime.JSX.Element;
|
|
30
29
|
|
|
31
30
|
interface BlogCardProps {
|
|
32
|
-
|
|
31
|
+
metadata: BlogMeta;
|
|
33
32
|
basePath?: string;
|
|
34
33
|
renderLink?: (href: string, children: react__default.ReactNode) => react__default.ReactNode;
|
|
35
34
|
className?: string;
|
|
@@ -37,17 +36,17 @@ interface BlogCardProps {
|
|
|
37
36
|
showReadingTime?: boolean;
|
|
38
37
|
showDate?: boolean;
|
|
39
38
|
}
|
|
40
|
-
declare function BlogCard({
|
|
39
|
+
declare function BlogCard({ metadata, basePath, renderLink, className, showCategory, showReadingTime, showDate, }: BlogCardProps): react_jsx_runtime.JSX.Element;
|
|
41
40
|
|
|
42
41
|
interface BlogListProps {
|
|
43
|
-
|
|
42
|
+
metadata: BlogMeta[];
|
|
44
43
|
basePath?: string;
|
|
45
44
|
renderLink?: BlogCardProps['renderLink'];
|
|
46
45
|
className?: string;
|
|
47
46
|
emptyMessage?: string;
|
|
48
47
|
cardProps?: Omit<BlogCardProps, 'blog' | 'basePath' | 'renderLink'>;
|
|
49
48
|
}
|
|
50
|
-
declare function BlogList({
|
|
49
|
+
declare function BlogList({ metadata, basePath, renderLink, className, emptyMessage, cardProps, }: BlogListProps): react_jsx_runtime.JSX.Element;
|
|
51
50
|
|
|
52
51
|
interface BlogPlaceholderProps {
|
|
53
52
|
count?: number;
|
|
@@ -64,4 +63,4 @@ declare function useBlogs(blogs: BlogMeta[]): {
|
|
|
64
63
|
categories: string[];
|
|
65
64
|
};
|
|
66
65
|
|
|
67
|
-
export { type Blog, BlogCard, type BlogCardProps, type BlogConfig, BlogList, type BlogListProps, type BlogMeta, BlogPlaceholder, type BlogPlaceholderProps, BlogRenderer
|
|
66
|
+
export { type Blog, BlogCard, type BlogCardProps, type BlogConfig, BlogList, type BlogListProps, type BlogMeta, BlogPlaceholder, type BlogPlaceholderProps, BlogRenderer, type BlogRendererProps, useBlogs };
|
package/dist/index.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
// src/components/
|
|
1
|
+
// src/components/BlogRenderer.tsx
|
|
2
2
|
import ReactMarkdown from "react-markdown";
|
|
3
3
|
import remarkGfm from "remark-gfm";
|
|
4
4
|
import rehypePrismPlus from "rehype-prism-plus";
|
|
@@ -16,7 +16,7 @@ function Badge({ children, className }) {
|
|
|
16
16
|
);
|
|
17
17
|
}
|
|
18
18
|
|
|
19
|
-
// src/components/
|
|
19
|
+
// src/components/BlogRenderer.tsx
|
|
20
20
|
import { Fragment, jsx as jsx2, jsxs } from "react/jsx-runtime";
|
|
21
21
|
function BlogRenderer({ content, metadata, className = "", components }) {
|
|
22
22
|
const defaultComponents = {
|
|
@@ -95,7 +95,7 @@ function BlogRenderer({ content, metadata, className = "", components }) {
|
|
|
95
95
|
// src/components/BlogCard.tsx
|
|
96
96
|
import { jsx as jsx3, jsxs as jsxs2 } from "react/jsx-runtime";
|
|
97
97
|
function BlogCard({
|
|
98
|
-
|
|
98
|
+
metadata,
|
|
99
99
|
basePath = "/blog",
|
|
100
100
|
renderLink,
|
|
101
101
|
className = "",
|
|
@@ -103,7 +103,7 @@ function BlogCard({
|
|
|
103
103
|
showReadingTime = true,
|
|
104
104
|
showDate = true
|
|
105
105
|
}) {
|
|
106
|
-
const href = `${basePath}/${
|
|
106
|
+
const href = `${basePath}/${metadata.slug}`;
|
|
107
107
|
const defaultLink = (href2, children) => /* @__PURE__ */ jsx3("a", { href: href2, children });
|
|
108
108
|
const Link = renderLink || defaultLink;
|
|
109
109
|
return /* @__PURE__ */ jsxs2(
|
|
@@ -112,11 +112,11 @@ function BlogCard({
|
|
|
112
112
|
className: `bg-white rounded-lg border border-gray-200 hover:border-gray-300 p-6 transition-colors ${className}`,
|
|
113
113
|
children: [
|
|
114
114
|
/* @__PURE__ */ jsx3("div", { className: "flex items-center justify-between mb-3", children: /* @__PURE__ */ jsxs2("div", { className: "flex items-center gap-3", children: [
|
|
115
|
-
showCategory &&
|
|
115
|
+
showCategory && metadata.category && /* @__PURE__ */ jsx3(Badge, { children: metadata.category }),
|
|
116
116
|
(showReadingTime || showDate) && /* @__PURE__ */ jsxs2("div", { className: "flex items-center gap-2 text-sm text-gray-500", children: [
|
|
117
|
-
showReadingTime && /* @__PURE__ */ jsx3("span", { children:
|
|
117
|
+
showReadingTime && /* @__PURE__ */ jsx3("span", { children: metadata.readingTime }),
|
|
118
118
|
showReadingTime && showDate && /* @__PURE__ */ jsx3("span", { children: "\u2022" }),
|
|
119
|
-
showDate && /* @__PURE__ */ jsx3("time", { dateTime:
|
|
119
|
+
showDate && /* @__PURE__ */ jsx3("time", { dateTime: metadata.date, children: new Date(metadata.date).toLocaleDateString("en-US", {
|
|
120
120
|
year: "numeric",
|
|
121
121
|
month: "long",
|
|
122
122
|
day: "numeric"
|
|
@@ -125,9 +125,9 @@ function BlogCard({
|
|
|
125
125
|
] }) }),
|
|
126
126
|
Link(
|
|
127
127
|
href,
|
|
128
|
-
/* @__PURE__ */ jsx3("h2", { className: "font-semibold text-xl text-gray-700 mb-2 hover:underline transition-colors", children:
|
|
128
|
+
/* @__PURE__ */ jsx3("h2", { className: "font-semibold text-xl text-gray-700 mb-2 hover:underline transition-colors", children: metadata.title })
|
|
129
129
|
),
|
|
130
|
-
/* @__PURE__ */ jsx3("p", { className: "text-sm text-gray-500 leading-6 mb-4", children:
|
|
130
|
+
/* @__PURE__ */ jsx3("p", { className: "text-sm text-gray-500 leading-6 mb-4", children: metadata.description }),
|
|
131
131
|
Link(
|
|
132
132
|
href,
|
|
133
133
|
/* @__PURE__ */ jsx3("span", { className: "inline-flex items-center text-blue-600 hover:text-blue-700 font-medium text-sm", children: "Read more \u2192" })
|
|
@@ -140,25 +140,25 @@ function BlogCard({
|
|
|
140
140
|
// src/components/BlogList.tsx
|
|
141
141
|
import { jsx as jsx4 } from "react/jsx-runtime";
|
|
142
142
|
function BlogList({
|
|
143
|
-
|
|
143
|
+
metadata,
|
|
144
144
|
basePath = "/blog",
|
|
145
145
|
renderLink,
|
|
146
146
|
className = "",
|
|
147
147
|
emptyMessage = "No blog posts found.",
|
|
148
148
|
cardProps
|
|
149
149
|
}) {
|
|
150
|
-
if (
|
|
150
|
+
if (metadata.length === 0) {
|
|
151
151
|
return /* @__PURE__ */ jsx4("div", { className: `text-center text-gray-500 py-12 ${className}`, children: emptyMessage });
|
|
152
152
|
}
|
|
153
|
-
return /* @__PURE__ */ jsx4("div", { className: `space-y-6 ${className}`, children:
|
|
153
|
+
return /* @__PURE__ */ jsx4("div", { className: `space-y-6 ${className}`, children: metadata.map((meta) => /* @__PURE__ */ jsx4(
|
|
154
154
|
BlogCard,
|
|
155
155
|
{
|
|
156
|
-
|
|
156
|
+
metadata: meta,
|
|
157
157
|
basePath,
|
|
158
158
|
renderLink,
|
|
159
159
|
...cardProps
|
|
160
160
|
},
|
|
161
|
-
|
|
161
|
+
meta.slug
|
|
162
162
|
)) });
|
|
163
163
|
}
|
|
164
164
|
|
|
@@ -206,6 +206,6 @@ export {
|
|
|
206
206
|
BlogCard,
|
|
207
207
|
BlogList,
|
|
208
208
|
BlogPlaceholder,
|
|
209
|
-
BlogRenderer
|
|
209
|
+
BlogRenderer,
|
|
210
210
|
useBlogs
|
|
211
211
|
};
|