@haroonwaves/blog-kit-react 0.0.6 → 0.0.8
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 +10 -10
- package/dist/index.d.cts +3 -3
- package/dist/index.d.ts +3 -3
- package/dist/index.js +9 -9
- 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 = {
|
|
@@ -214,12 +214,12 @@ function BlogPlaceholder({ count = 3, className = "" }) {
|
|
|
214
214
|
|
|
215
215
|
// src/hooks/useBlogs.ts
|
|
216
216
|
var import_react = require("react");
|
|
217
|
-
function useBlogs(
|
|
218
|
-
const [filteredBlogs, setFilteredBlogs] = (0, import_react.useState)(
|
|
217
|
+
function useBlogs(blogsMeta) {
|
|
218
|
+
const [filteredBlogs, setFilteredBlogs] = (0, import_react.useState)(blogsMeta);
|
|
219
219
|
const [searchTerm, setSearchTerm] = (0, import_react.useState)("");
|
|
220
220
|
const [selectedCategory, setSelectedCategory] = (0, import_react.useState)(null);
|
|
221
221
|
(0, import_react.useEffect)(() => {
|
|
222
|
-
let filtered =
|
|
222
|
+
let filtered = blogsMeta;
|
|
223
223
|
if (searchTerm) {
|
|
224
224
|
filtered = filtered.filter(
|
|
225
225
|
(blog) => blog.title.toLowerCase().includes(searchTerm.toLowerCase()) || blog.description.toLowerCase().includes(searchTerm.toLowerCase())
|
|
@@ -229,12 +229,12 @@ function useBlogs(blogs) {
|
|
|
229
229
|
filtered = filtered.filter((blog) => blog.category === selectedCategory);
|
|
230
230
|
}
|
|
231
231
|
setFilteredBlogs(filtered);
|
|
232
|
-
}, [
|
|
232
|
+
}, [blogsMeta, searchTerm, selectedCategory]);
|
|
233
233
|
const categories = Array.from(
|
|
234
|
-
new Set(
|
|
234
|
+
new Set(blogsMeta.map((blog) => blog.category).filter(Boolean))
|
|
235
235
|
);
|
|
236
236
|
return {
|
|
237
|
-
|
|
237
|
+
metadata: filteredBlogs,
|
|
238
238
|
searchTerm,
|
|
239
239
|
setSearchTerm,
|
|
240
240
|
selectedCategory,
|
|
@@ -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
|
@@ -54,8 +54,8 @@ interface BlogPlaceholderProps {
|
|
|
54
54
|
}
|
|
55
55
|
declare function BlogPlaceholder({ count, className }: BlogPlaceholderProps): react_jsx_runtime.JSX.Element;
|
|
56
56
|
|
|
57
|
-
declare function useBlogs(
|
|
58
|
-
|
|
57
|
+
declare function useBlogs(blogsMeta: BlogMeta[]): {
|
|
58
|
+
metadata: BlogMeta[];
|
|
59
59
|
searchTerm: string;
|
|
60
60
|
setSearchTerm: react.Dispatch<react.SetStateAction<string>>;
|
|
61
61
|
selectedCategory: string | null;
|
|
@@ -63,4 +63,4 @@ declare function useBlogs(blogs: BlogMeta[]): {
|
|
|
63
63
|
categories: string[];
|
|
64
64
|
};
|
|
65
65
|
|
|
66
|
-
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
|
@@ -54,8 +54,8 @@ interface BlogPlaceholderProps {
|
|
|
54
54
|
}
|
|
55
55
|
declare function BlogPlaceholder({ count, className }: BlogPlaceholderProps): react_jsx_runtime.JSX.Element;
|
|
56
56
|
|
|
57
|
-
declare function useBlogs(
|
|
58
|
-
|
|
57
|
+
declare function useBlogs(blogsMeta: BlogMeta[]): {
|
|
58
|
+
metadata: BlogMeta[];
|
|
59
59
|
searchTerm: string;
|
|
60
60
|
setSearchTerm: react.Dispatch<react.SetStateAction<string>>;
|
|
61
61
|
selectedCategory: string | null;
|
|
@@ -63,4 +63,4 @@ declare function useBlogs(blogs: BlogMeta[]): {
|
|
|
63
63
|
categories: string[];
|
|
64
64
|
};
|
|
65
65
|
|
|
66
|
-
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 = {
|
|
@@ -174,12 +174,12 @@ function BlogPlaceholder({ count = 3, className = "" }) {
|
|
|
174
174
|
|
|
175
175
|
// src/hooks/useBlogs.ts
|
|
176
176
|
import { useState, useEffect } from "react";
|
|
177
|
-
function useBlogs(
|
|
178
|
-
const [filteredBlogs, setFilteredBlogs] = useState(
|
|
177
|
+
function useBlogs(blogsMeta) {
|
|
178
|
+
const [filteredBlogs, setFilteredBlogs] = useState(blogsMeta);
|
|
179
179
|
const [searchTerm, setSearchTerm] = useState("");
|
|
180
180
|
const [selectedCategory, setSelectedCategory] = useState(null);
|
|
181
181
|
useEffect(() => {
|
|
182
|
-
let filtered =
|
|
182
|
+
let filtered = blogsMeta;
|
|
183
183
|
if (searchTerm) {
|
|
184
184
|
filtered = filtered.filter(
|
|
185
185
|
(blog) => blog.title.toLowerCase().includes(searchTerm.toLowerCase()) || blog.description.toLowerCase().includes(searchTerm.toLowerCase())
|
|
@@ -189,12 +189,12 @@ function useBlogs(blogs) {
|
|
|
189
189
|
filtered = filtered.filter((blog) => blog.category === selectedCategory);
|
|
190
190
|
}
|
|
191
191
|
setFilteredBlogs(filtered);
|
|
192
|
-
}, [
|
|
192
|
+
}, [blogsMeta, searchTerm, selectedCategory]);
|
|
193
193
|
const categories = Array.from(
|
|
194
|
-
new Set(
|
|
194
|
+
new Set(blogsMeta.map((blog) => blog.category).filter(Boolean))
|
|
195
195
|
);
|
|
196
196
|
return {
|
|
197
|
-
|
|
197
|
+
metadata: filteredBlogs,
|
|
198
198
|
searchTerm,
|
|
199
199
|
setSearchTerm,
|
|
200
200
|
selectedCategory,
|
|
@@ -206,6 +206,6 @@ export {
|
|
|
206
206
|
BlogCard,
|
|
207
207
|
BlogList,
|
|
208
208
|
BlogPlaceholder,
|
|
209
|
-
BlogRenderer
|
|
209
|
+
BlogRenderer,
|
|
210
210
|
useBlogs
|
|
211
211
|
};
|