@haroonwaves/blog-kit-core 1.3.1 → 2.0.0

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/README.md CHANGED
@@ -20,8 +20,7 @@ For complete documentation, API reference, and examples, please visit the
20
20
 
21
21
  ## Quick Links
22
22
 
23
- - [Quick Start](https://blog-kit.haroonwaves.com/docs/quick-start)
24
- - [Core Package Usage](https://blog-kit.haroonwaves.com/docs/core-package)
23
+ - [Getting Started](https://blog-kit.haroonwaves.com/docs/getting-started)
25
24
  - [API Reference](https://blog-kit.haroonwaves.com/docs/api-reference)
26
25
 
27
26
  ## Related Packages
package/dist/index.cjs CHANGED
@@ -30,8 +30,8 @@ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: tru
30
30
  // src/index.ts
31
31
  var src_exports = {};
32
32
  __export(src_exports, {
33
- getAllBlogsMeta: () => getAllBlogsMeta,
34
- getBlog: () => getBlog
33
+ getAllContentMeta: () => getAllContentMeta,
34
+ getContent: () => getContent
35
35
  });
36
36
  module.exports = __toCommonJS(src_exports);
37
37
 
@@ -40,16 +40,16 @@ var import_fs = __toESM(require("fs"), 1);
40
40
  var import_path = __toESM(require("path"), 1);
41
41
  var import_gray_matter = __toESM(require("gray-matter"), 1);
42
42
  var import_reading_time = __toESM(require("reading-time"), 1);
43
- function getAllBlogsMeta(config) {
44
- const blogDirectory = import_path.default.join(config.contentDirectory, config.blogSubdirectory || "blog");
45
- if (!import_fs.default.existsSync(blogDirectory)) {
46
- console.warn(`Blog directory not found: ${blogDirectory}`);
43
+ function getAllContentMeta(config) {
44
+ const contentDirectory = import_path.default.join(config.contentDirectory, config.contentSubdirectory || "blog");
45
+ if (!import_fs.default.existsSync(contentDirectory)) {
46
+ console.warn(`Content directory not found: ${contentDirectory}`);
47
47
  return [];
48
48
  }
49
- const files = import_fs.default.readdirSync(blogDirectory);
50
- const blogs = files.filter((file) => file.endsWith(".md")).map((file) => {
49
+ const files = import_fs.default.readdirSync(contentDirectory);
50
+ const allContent = files.filter((file) => file.endsWith(".md")).map((file) => {
51
51
  const slug = file.replace(".md", "");
52
- const filePath = import_path.default.join(blogDirectory, file);
52
+ const filePath = import_path.default.join(contentDirectory, file);
53
53
  const fileContent = import_fs.default.readFileSync(filePath, "utf8");
54
54
  const { data, content } = (0, import_gray_matter.default)(fileContent);
55
55
  const readingTimeText = (0, import_reading_time.default)(content).text;
@@ -61,11 +61,11 @@ function getAllBlogsMeta(config) {
61
61
  }).sort((a, b) => {
62
62
  return new Date(b.date).getTime() - new Date(a.date).getTime();
63
63
  });
64
- return blogs;
64
+ return allContent;
65
65
  }
66
- function getBlog(slug, config) {
67
- const blogDirectory = import_path.default.join(config.contentDirectory, config.blogSubdirectory || "blog");
68
- const filePath = import_path.default.join(blogDirectory, `${slug}.md`);
66
+ function getContent(slug, config) {
67
+ const contentDirectory = import_path.default.join(config.contentDirectory, config.contentSubdirectory || "blog");
68
+ const filePath = import_path.default.join(contentDirectory, `${slug}.md`);
69
69
  if (!import_fs.default.existsSync(filePath)) {
70
70
  return null;
71
71
  }
@@ -78,11 +78,11 @@ function getBlog(slug, config) {
78
78
  slug,
79
79
  readingTime: readingTimeText
80
80
  },
81
- content
81
+ body: content
82
82
  };
83
83
  }
84
84
  // Annotate the CommonJS export names for ESM import in node:
85
85
  0 && (module.exports = {
86
- getAllBlogsMeta,
87
- getBlog
86
+ getAllContentMeta,
87
+ getContent
88
88
  });
package/dist/index.d.cts CHANGED
@@ -1,4 +1,4 @@
1
- interface BlogMeta {
1
+ interface ContentMeta {
2
2
  title: string;
3
3
  description: string;
4
4
  date: string;
@@ -6,33 +6,33 @@ interface BlogMeta {
6
6
  slug: string;
7
7
  readingTime: string;
8
8
  }
9
- interface Blog {
10
- metadata: BlogMeta;
11
- content: string;
9
+ interface Content {
10
+ metadata: ContentMeta;
11
+ body: string;
12
12
  }
13
- interface BlogConfig {
13
+ interface ContentConfig {
14
14
  contentDirectory: string;
15
- blogSubdirectory?: string;
15
+ contentSubdirectory?: string;
16
16
  }
17
17
 
18
18
  /**
19
- * SSR and SSG only: Get all blogs metadata from the filesystem.
19
+ * SSR and SSG only: Get all content metadata from the filesystem.
20
20
  * This function requires Node.js fs module and only works in server environments
21
21
  * (Next.js SSR/SSG, Node.js scripts, etc.).
22
22
  *
23
- * @param config - Blog kit configuration
24
- * @returns Array of blog metadata
23
+ * @param config - Content kit configuration
24
+ * @returns Array of content metadata
25
25
  */
26
- declare function getAllBlogsMeta(config: BlogConfig): BlogMeta[];
26
+ declare function getAllContentMeta(config: ContentConfig): ContentMeta[];
27
27
  /**
28
- * SSR and SSG only: Get blog from the filesystem.
28
+ * SSR and SSG only: Get content from the filesystem.
29
29
  * This function requires Node.js fs module and only works in server environments
30
30
  * (Next.js SSR/SSG, Node.js scripts, etc.).
31
31
  *
32
- * @param slug - Blog post slug/identifier
33
- * @param config - Blog kit configuration
34
- * @returns Blog data or null if not found
32
+ * @param slug - Content slug/identifier
33
+ * @param config - Content kit configuration
34
+ * @returns Content data or null if not found
35
35
  */
36
- declare function getBlog(slug: string, config: BlogConfig): Blog | null;
36
+ declare function getContent(slug: string, config: ContentConfig): Content | null;
37
37
 
38
- export { type Blog, type BlogConfig, type BlogMeta, getAllBlogsMeta, getBlog };
38
+ export { type Content, type ContentConfig, type ContentMeta, getAllContentMeta, getContent };
package/dist/index.d.ts CHANGED
@@ -1,4 +1,4 @@
1
- interface BlogMeta {
1
+ interface ContentMeta {
2
2
  title: string;
3
3
  description: string;
4
4
  date: string;
@@ -6,33 +6,33 @@ interface BlogMeta {
6
6
  slug: string;
7
7
  readingTime: string;
8
8
  }
9
- interface Blog {
10
- metadata: BlogMeta;
11
- content: string;
9
+ interface Content {
10
+ metadata: ContentMeta;
11
+ body: string;
12
12
  }
13
- interface BlogConfig {
13
+ interface ContentConfig {
14
14
  contentDirectory: string;
15
- blogSubdirectory?: string;
15
+ contentSubdirectory?: string;
16
16
  }
17
17
 
18
18
  /**
19
- * SSR and SSG only: Get all blogs metadata from the filesystem.
19
+ * SSR and SSG only: Get all content metadata from the filesystem.
20
20
  * This function requires Node.js fs module and only works in server environments
21
21
  * (Next.js SSR/SSG, Node.js scripts, etc.).
22
22
  *
23
- * @param config - Blog kit configuration
24
- * @returns Array of blog metadata
23
+ * @param config - Content kit configuration
24
+ * @returns Array of content metadata
25
25
  */
26
- declare function getAllBlogsMeta(config: BlogConfig): BlogMeta[];
26
+ declare function getAllContentMeta(config: ContentConfig): ContentMeta[];
27
27
  /**
28
- * SSR and SSG only: Get blog from the filesystem.
28
+ * SSR and SSG only: Get content from the filesystem.
29
29
  * This function requires Node.js fs module and only works in server environments
30
30
  * (Next.js SSR/SSG, Node.js scripts, etc.).
31
31
  *
32
- * @param slug - Blog post slug/identifier
33
- * @param config - Blog kit configuration
34
- * @returns Blog data or null if not found
32
+ * @param slug - Content slug/identifier
33
+ * @param config - Content kit configuration
34
+ * @returns Content data or null if not found
35
35
  */
36
- declare function getBlog(slug: string, config: BlogConfig): Blog | null;
36
+ declare function getContent(slug: string, config: ContentConfig): Content | null;
37
37
 
38
- export { type Blog, type BlogConfig, type BlogMeta, getAllBlogsMeta, getBlog };
38
+ export { type Content, type ContentConfig, type ContentMeta, getAllContentMeta, getContent };
package/dist/index.js CHANGED
@@ -3,16 +3,16 @@ import fs from "fs";
3
3
  import path from "path";
4
4
  import matter from "gray-matter";
5
5
  import readingTime from "reading-time";
6
- function getAllBlogsMeta(config) {
7
- const blogDirectory = path.join(config.contentDirectory, config.blogSubdirectory || "blog");
8
- if (!fs.existsSync(blogDirectory)) {
9
- console.warn(`Blog directory not found: ${blogDirectory}`);
6
+ function getAllContentMeta(config) {
7
+ const contentDirectory = path.join(config.contentDirectory, config.contentSubdirectory || "blog");
8
+ if (!fs.existsSync(contentDirectory)) {
9
+ console.warn(`Content directory not found: ${contentDirectory}`);
10
10
  return [];
11
11
  }
12
- const files = fs.readdirSync(blogDirectory);
13
- const blogs = files.filter((file) => file.endsWith(".md")).map((file) => {
12
+ const files = fs.readdirSync(contentDirectory);
13
+ const allContent = files.filter((file) => file.endsWith(".md")).map((file) => {
14
14
  const slug = file.replace(".md", "");
15
- const filePath = path.join(blogDirectory, file);
15
+ const filePath = path.join(contentDirectory, file);
16
16
  const fileContent = fs.readFileSync(filePath, "utf8");
17
17
  const { data, content } = matter(fileContent);
18
18
  const readingTimeText = readingTime(content).text;
@@ -24,11 +24,11 @@ function getAllBlogsMeta(config) {
24
24
  }).sort((a, b) => {
25
25
  return new Date(b.date).getTime() - new Date(a.date).getTime();
26
26
  });
27
- return blogs;
27
+ return allContent;
28
28
  }
29
- function getBlog(slug, config) {
30
- const blogDirectory = path.join(config.contentDirectory, config.blogSubdirectory || "blog");
31
- const filePath = path.join(blogDirectory, `${slug}.md`);
29
+ function getContent(slug, config) {
30
+ const contentDirectory = path.join(config.contentDirectory, config.contentSubdirectory || "blog");
31
+ const filePath = path.join(contentDirectory, `${slug}.md`);
32
32
  if (!fs.existsSync(filePath)) {
33
33
  return null;
34
34
  }
@@ -41,10 +41,10 @@ function getBlog(slug, config) {
41
41
  slug,
42
42
  readingTime: readingTimeText
43
43
  },
44
- content
44
+ body: content
45
45
  };
46
46
  }
47
47
  export {
48
- getAllBlogsMeta,
49
- getBlog
48
+ getAllContentMeta,
49
+ getContent
50
50
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@haroonwaves/blog-kit-core",
3
- "version": "1.3.1",
3
+ "version": "2.0.0",
4
4
  "main": "dist/index.js",
5
5
  "module": "dist/index.mjs",
6
6
  "types": "dist/index.d.ts",