@san-siva/blogkit 1.1.44 → 1.1.45

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.
@@ -5,7 +5,8 @@ interface BlogProperties {
5
5
  title?: string;
6
6
  jsonLd?: WithContext<Thing>;
7
7
  increasedWidthMode?: boolean;
8
+ isTocEnabled?: boolean;
8
9
  }
9
- declare const Blog: ({ children, title, jsonLd, increasedWidthMode }: BlogProperties) => import("react").JSX.Element;
10
+ declare const Blog: ({ children, title, jsonLd, increasedWidthMode, isTocEnabled, }: BlogProperties) => import("react").JSX.Element;
10
11
  export default Blog;
11
12
  //# sourceMappingURL=Blog.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"Blog.d.ts","sourceRoot":"","sources":["../../../src/components/Blog.tsx"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,OAAO,CAAC;AACvC,OAAO,KAAK,EAAE,KAAK,EAAE,WAAW,EAAE,MAAM,YAAY,CAAC;AAKrD,UAAU,cAAc;IACvB,QAAQ,EAAE,SAAS,CAAC;IACpB,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,MAAM,CAAC,EAAE,WAAW,CAAC,KAAK,CAAC,CAAC;IAC5B,kBAAkB,CAAC,EAAE,OAAO,CAAC;CAC7B;AAED,QAAA,MAAM,IAAI,GAAI,iDAA6E,cAAc,gCAMxG,CAAC;AAEF,eAAe,IAAI,CAAC"}
1
+ {"version":3,"file":"Blog.d.ts","sourceRoot":"","sources":["../../../src/components/Blog.tsx"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,OAAO,CAAC;AACvC,OAAO,KAAK,EAAE,KAAK,EAAE,WAAW,EAAE,MAAM,YAAY,CAAC;AAKrD,UAAU,cAAc;IACvB,QAAQ,EAAE,SAAS,CAAC;IACpB,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,MAAM,CAAC,EAAE,WAAW,CAAC,KAAK,CAAC,CAAC;IAC5B,kBAAkB,CAAC,EAAE,OAAO,CAAC;IAC7B,YAAY,CAAC,EAAE,OAAO,CAAC;CACvB;AAED,QAAA,MAAM,IAAI,GAAI,gEAMX,cAAc,gCAchB,CAAC;AAEF,eAAe,IAAI,CAAC"}
@@ -0,0 +1,2 @@
1
+ export {};
2
+ //# sourceMappingURL=Blog.test.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"Blog.test.d.ts","sourceRoot":"","sources":["../../../src/components/Blog.test.tsx"],"names":[],"mappings":""}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@san-siva/blogkit",
3
- "version": "1.1.44",
3
+ "version": "1.1.45",
4
4
  "description": "A reusable blog component library for React/Next.js applications with code highlighting, diagrams, and rich content features",
5
5
  "main": "dist/cjs/index.js",
6
6
  "module": "dist/esm/index.js",
@@ -0,0 +1,40 @@
1
+ import { describe, expect, it } from 'vitest';
2
+ import { Suspense } from 'react';
3
+ import { renderToStaticMarkup } from 'react-dom/server';
4
+
5
+ import Blog from './Blog';
6
+ import BlogStatic from '../staticComponents/BlogStatic';
7
+
8
+ describe('Blog', () => {
9
+ it('renders BlogStatic directly when isTocEnabled is false, skipping Suspense/BlogDynamic', () => {
10
+ const element = Blog({ children: 'hello', isTocEnabled: false } as never);
11
+ expect(element.type).toBe(BlogStatic);
12
+ expect(element.props.children).toBe('hello');
13
+ });
14
+
15
+ it('wraps BlogDynamic in a Suspense boundary with a BlogStatic fallback when isTocEnabled is true (default)', () => {
16
+ const element = Blog({ children: 'hello' } as never);
17
+ expect(element.type).toBe(Suspense);
18
+ expect(element.props.fallback.type).toBe(BlogStatic);
19
+ expect(element.props.children.type.$$typeof).toBe(Symbol.for('react.lazy'));
20
+ });
21
+
22
+ it('renders children through the static path', () => {
23
+ const html = renderToStaticMarkup(<Blog isTocEnabled={false}>content</Blog>);
24
+ expect(html).toContain('content');
25
+ });
26
+
27
+ it('passes increasedWidthMode through to BlogStatic when isTocEnabled is false', () => {
28
+ const withIncreasedWidth = Blog({ children: 'hi', isTocEnabled: false, increasedWidthMode: true } as never);
29
+ expect(withIncreasedWidth.props.increasedWidthMode).toBe(true);
30
+
31
+ const withoutIncreasedWidth = Blog({ children: 'hi', isTocEnabled: false } as never);
32
+ expect(withoutIncreasedWidth.props.increasedWidthMode).toBe(false);
33
+ });
34
+
35
+ it('passes jsonLd through to BlogStatic when isTocEnabled is false', () => {
36
+ const jsonLd = { '@context': 'https://schema.org', '@type': 'Thing' } as never;
37
+ const element = Blog({ children: 'hi', isTocEnabled: false, jsonLd } as never);
38
+ expect(element.props.jsonLd).toBe(jsonLd);
39
+ });
40
+ });
@@ -12,9 +12,24 @@ interface BlogProperties {
12
12
  title?: string;
13
13
  jsonLd?: WithContext<Thing>;
14
14
  increasedWidthMode?: boolean;
15
+ isTocEnabled?: boolean;
15
16
  }
16
17
 
17
- const Blog = ({ children, title = 'In this article', jsonLd, increasedWidthMode = false }: BlogProperties) => {
18
+ const Blog = ({
19
+ children,
20
+ title = 'In this article',
21
+ jsonLd,
22
+ increasedWidthMode = false,
23
+ isTocEnabled = true,
24
+ }: BlogProperties) => {
25
+ if (!isTocEnabled) {
26
+ return (
27
+ <BlogStatic jsonLd={jsonLd} increasedWidthMode={increasedWidthMode}>
28
+ {children}
29
+ </BlogStatic>
30
+ );
31
+ }
32
+
18
33
  return (
19
34
  <Suspense fallback={<BlogStatic jsonLd={jsonLd} increasedWidthMode={increasedWidthMode}>{children}</BlogStatic>}>
20
35
  <BlogDynamic title={title} jsonLd={jsonLd} increasedWidthMode={increasedWidthMode}>{children}</BlogDynamic>
@@ -19,6 +19,7 @@
19
19
  margin-right: stylekit.space(1);
20
20
  margin-top: stylekit.rem(6);
21
21
  flex-shrink: 0;
22
+ cursor: pointer;
22
23
 
23
24
  &--checked {
24
25
  height: stylekit.rem(14);