@san-siva/blogkit 1.1.44 → 1.1.46
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/cjs/components/Blog.js +4 -1
- package/dist/cjs/components/Blog.js.map +1 -1
- package/dist/cjs/index.css +1 -1
- package/dist/cjs/index.css.map +1 -1
- package/dist/cjs/staticComponents/BlogStatic.js +2 -2
- package/dist/cjs/staticComponents/BlogStatic.js.map +1 -1
- package/dist/cjs/styles/Blog.module.scss.js +1 -1
- package/dist/esm/components/Blog.js +4 -1
- package/dist/esm/components/Blog.js.map +1 -1
- package/dist/esm/index.css +1 -1
- package/dist/esm/index.css.map +1 -1
- package/dist/esm/staticComponents/BlogStatic.js +2 -2
- package/dist/esm/staticComponents/BlogStatic.js.map +1 -1
- package/dist/esm/styles/Blog.module.scss.js +1 -1
- package/dist/types/components/Blog.d.ts +2 -1
- package/dist/types/components/Blog.d.ts.map +1 -1
- package/dist/types/components/Blog.test.d.ts +2 -0
- package/dist/types/components/Blog.test.d.ts.map +1 -0
- package/dist/types/staticComponents/BlogStatic.d.ts +2 -1
- package/dist/types/staticComponents/BlogStatic.d.ts.map +1 -1
- package/package.json +1 -1
- package/src/components/Blog.test.tsx +41 -0
- package/src/components/Blog.tsx +16 -1
- package/src/staticComponents/BlogStatic.tsx +7 -2
- package/src/styles/Blog.module.scss +9 -0
- package/src/styles/Blog.module.scss.d.ts +1 -0
- package/src/styles/CheckList.module.scss +1 -0
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import { jsxs, jsx } from 'react/jsx-runtime';
|
|
2
2
|
import styles from '../styles/Blog.module.scss.js';
|
|
3
3
|
|
|
4
|
-
const BlogStatic = ({ children, jsonLd, increasedWidthMode = false }) => {
|
|
5
|
-
return (jsxs("div", { className: `${styles.blog} ${increasedWidthMode ? styles['blog--increased-width'] : ''}`, children: [jsonLd && (jsx("script", { type: "application/ld+json", dangerouslySetInnerHTML: { __html: JSON.stringify(jsonLd) } })), jsx("div", { className: styles['blog__content'], children: children })] }));
|
|
4
|
+
const BlogStatic = ({ children, jsonLd, increasedWidthMode = false, isTocEnabled = true }) => {
|
|
5
|
+
return (jsxs("div", { className: `${styles.blog} ${increasedWidthMode ? styles['blog--increased-width'] : ''} ${isTocEnabled ? '' : styles['blog--no-toc']}`, children: [jsonLd && (jsx("script", { type: "application/ld+json", dangerouslySetInnerHTML: { __html: JSON.stringify(jsonLd) } })), jsx("div", { className: styles['blog__content'], children: children })] }));
|
|
6
6
|
};
|
|
7
7
|
|
|
8
8
|
export { BlogStatic as default };
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"BlogStatic.js","sources":["../../../src/staticComponents/BlogStatic.tsx"],"sourcesContent":["import type { ReactNode } from 'react';\nimport type { Thing, WithContext } from 'schema-dts';\nimport styles from '../styles/Blog.module.scss';\n\ninterface BlogStaticProperties {\n\tchildren: ReactNode;\n\tjsonLd?: WithContext<Thing>;\n\tincreasedWidthMode?: boolean;\n}\n\nconst BlogStatic = ({ children, jsonLd, increasedWidthMode = false }: BlogStaticProperties) => {\n\treturn (\n\t\t<div
|
|
1
|
+
{"version":3,"file":"BlogStatic.js","sources":["../../../src/staticComponents/BlogStatic.tsx"],"sourcesContent":["import type { ReactNode } from 'react';\nimport type { Thing, WithContext } from 'schema-dts';\nimport styles from '../styles/Blog.module.scss';\n\ninterface BlogStaticProperties {\n\tchildren: ReactNode;\n\tjsonLd?: WithContext<Thing>;\n\tincreasedWidthMode?: boolean;\n\tisTocEnabled?: boolean;\n}\n\nconst BlogStatic = ({ children, jsonLd, increasedWidthMode = false, isTocEnabled = true }: BlogStaticProperties) => {\n\treturn (\n\t\t<div\n\t\t\tclassName={`${styles.blog} ${increasedWidthMode ? styles['blog--increased-width'] : ''} ${\n\t\t\t\tisTocEnabled ? '' : styles['blog--no-toc']\n\t\t\t}`}\n\t\t>\n\n\t\t\t{jsonLd && (\n\t\t\t\t<script\n\t\t\t\t\ttype=\"application/ld+json\"\n\t\t\t\t\tdangerouslySetInnerHTML={{ __html: JSON.stringify(jsonLd) }}\n\t\t\t\t/>\n\t\t\t)}\n\t\t\t<div className={styles['blog__content']}>{children}</div>\n\t\t</div>\n\t);\n};\n\nexport default BlogStatic;\n"],"names":["_jsxs","_jsx"],"mappings":";;;AAWA,MAAM,UAAU,GAAG,CAAC,EAAE,QAAQ,EAAE,MAAM,EAAE,kBAAkB,GAAG,KAAK,EAAE,YAAY,GAAG,IAAI,EAAwB,KAAI;AAClH,IAAA,QACCA,IAAA,CAAA,KAAA,EAAA,EACC,SAAS,EAAE,GAAG,MAAM,CAAC,IAAI,CAAA,CAAA,EAAI,kBAAkB,GAAG,MAAM,CAAC,uBAAuB,CAAC,GAAG,EAAE,CAAA,CAAA,EACrF,YAAY,GAAG,EAAE,GAAG,MAAM,CAAC,cAAc,CAC1C,CAAA,CAAE,EAAA,QAAA,EAAA,CAGD,MAAM,KACNC,GAAA,CAAA,QAAA,EAAA,EACC,IAAI,EAAC,qBAAqB,EAC1B,uBAAuB,EAAE,EAAE,MAAM,EAAE,IAAI,CAAC,SAAS,CAAC,MAAM,CAAC,EAAE,EAAA,CAC1D,CACF,EACDA,GAAA,CAAA,KAAA,EAAA,EAAK,SAAS,EAAE,MAAM,CAAC,eAAe,CAAC,EAAA,QAAA,EAAG,QAAQ,EAAA,CAAO,CAAA,EAAA,CACpD;AAER;;;;"}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
var styles = {"margin-bottom--3":"Blog-module_margin-bottom--3__ir35O","category__header":"Blog-module_category__header__F1K0V","blog":"Blog-module_blog__Lpv6Z","blog__content":"Blog-module_blog__content__RMDiY","blog__sidebar":"Blog-module_blog__sidebar__uSu3l","blog--increased-width":"Blog-module_blog--increased-width__QxyOD"};
|
|
1
|
+
var styles = {"margin-bottom--3":"Blog-module_margin-bottom--3__ir35O","category__header":"Blog-module_category__header__F1K0V","blog":"Blog-module_blog__Lpv6Z","blog__content":"Blog-module_blog__content__RMDiY","blog__sidebar":"Blog-module_blog__sidebar__uSu3l","blog--increased-width":"Blog-module_blog--increased-width__QxyOD","blog--no-toc":"Blog-module_blog--no-toc__ggkFH"};
|
|
2
2
|
|
|
3
3
|
export { styles as default };
|
|
4
4
|
//# sourceMappingURL=Blog.module.scss.js.map
|
|
@@ -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;
|
|
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 @@
|
|
|
1
|
+
{"version":3,"file":"Blog.test.d.ts","sourceRoot":"","sources":["../../../src/components/Blog.test.tsx"],"names":[],"mappings":""}
|
|
@@ -4,7 +4,8 @@ interface BlogStaticProperties {
|
|
|
4
4
|
children: ReactNode;
|
|
5
5
|
jsonLd?: WithContext<Thing>;
|
|
6
6
|
increasedWidthMode?: boolean;
|
|
7
|
+
isTocEnabled?: boolean;
|
|
7
8
|
}
|
|
8
|
-
declare const BlogStatic: ({ children, jsonLd, increasedWidthMode }: BlogStaticProperties) => import("react").JSX.Element;
|
|
9
|
+
declare const BlogStatic: ({ children, jsonLd, increasedWidthMode, isTocEnabled }: BlogStaticProperties) => import("react").JSX.Element;
|
|
9
10
|
export default BlogStatic;
|
|
10
11
|
//# sourceMappingURL=BlogStatic.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"BlogStatic.d.ts","sourceRoot":"","sources":["../../../src/staticComponents/BlogStatic.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,OAAO,CAAC;AACvC,OAAO,KAAK,EAAE,KAAK,EAAE,WAAW,EAAE,MAAM,YAAY,CAAC;AAGrD,UAAU,oBAAoB;IAC7B,QAAQ,EAAE,SAAS,CAAC;IACpB,MAAM,CAAC,EAAE,WAAW,CAAC,KAAK,CAAC,CAAC;IAC5B,kBAAkB,CAAC,EAAE,OAAO,CAAC;
|
|
1
|
+
{"version":3,"file":"BlogStatic.d.ts","sourceRoot":"","sources":["../../../src/staticComponents/BlogStatic.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,OAAO,CAAC;AACvC,OAAO,KAAK,EAAE,KAAK,EAAE,WAAW,EAAE,MAAM,YAAY,CAAC;AAGrD,UAAU,oBAAoB;IAC7B,QAAQ,EAAE,SAAS,CAAC;IACpB,MAAM,CAAC,EAAE,WAAW,CAAC,KAAK,CAAC,CAAC;IAC5B,kBAAkB,CAAC,EAAE,OAAO,CAAC;IAC7B,YAAY,CAAC,EAAE,OAAO,CAAC;CACvB;AAED,QAAA,MAAM,UAAU,GAAI,wDAAuE,oBAAoB,gCAiB9G,CAAC;AAEF,eAAe,UAAU,CAAC"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@san-siva/blogkit",
|
|
3
|
-
"version": "1.1.
|
|
3
|
+
"version": "1.1.46",
|
|
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,41 @@
|
|
|
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
|
+
expect(element.props.isTocEnabled).toBe(false);
|
|
14
|
+
});
|
|
15
|
+
|
|
16
|
+
it('wraps BlogDynamic in a Suspense boundary with a BlogStatic fallback when isTocEnabled is true (default)', () => {
|
|
17
|
+
const element = Blog({ children: 'hello' } as never);
|
|
18
|
+
expect(element.type).toBe(Suspense);
|
|
19
|
+
expect(element.props.fallback.type).toBe(BlogStatic);
|
|
20
|
+
expect(element.props.children.type.$$typeof).toBe(Symbol.for('react.lazy'));
|
|
21
|
+
});
|
|
22
|
+
|
|
23
|
+
it('renders children through the static path', () => {
|
|
24
|
+
const html = renderToStaticMarkup(<Blog isTocEnabled={false}>content</Blog>);
|
|
25
|
+
expect(html).toContain('content');
|
|
26
|
+
});
|
|
27
|
+
|
|
28
|
+
it('passes increasedWidthMode through to BlogStatic when isTocEnabled is false', () => {
|
|
29
|
+
const withIncreasedWidth = Blog({ children: 'hi', isTocEnabled: false, increasedWidthMode: true } as never);
|
|
30
|
+
expect(withIncreasedWidth.props.increasedWidthMode).toBe(true);
|
|
31
|
+
|
|
32
|
+
const withoutIncreasedWidth = Blog({ children: 'hi', isTocEnabled: false } as never);
|
|
33
|
+
expect(withoutIncreasedWidth.props.increasedWidthMode).toBe(false);
|
|
34
|
+
});
|
|
35
|
+
|
|
36
|
+
it('passes jsonLd through to BlogStatic when isTocEnabled is false', () => {
|
|
37
|
+
const jsonLd = { '@context': 'https://schema.org', '@type': 'Thing' } as never;
|
|
38
|
+
const element = Blog({ children: 'hi', isTocEnabled: false, jsonLd } as never);
|
|
39
|
+
expect(element.props.jsonLd).toBe(jsonLd);
|
|
40
|
+
});
|
|
41
|
+
});
|
package/src/components/Blog.tsx
CHANGED
|
@@ -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 = ({
|
|
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} isTocEnabled={false}>
|
|
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>
|
|
@@ -6,11 +6,16 @@ interface BlogStaticProperties {
|
|
|
6
6
|
children: ReactNode;
|
|
7
7
|
jsonLd?: WithContext<Thing>;
|
|
8
8
|
increasedWidthMode?: boolean;
|
|
9
|
+
isTocEnabled?: boolean;
|
|
9
10
|
}
|
|
10
11
|
|
|
11
|
-
const BlogStatic = ({ children, jsonLd, increasedWidthMode = false }: BlogStaticProperties) => {
|
|
12
|
+
const BlogStatic = ({ children, jsonLd, increasedWidthMode = false, isTocEnabled = true }: BlogStaticProperties) => {
|
|
12
13
|
return (
|
|
13
|
-
<div
|
|
14
|
+
<div
|
|
15
|
+
className={`${styles.blog} ${increasedWidthMode ? styles['blog--increased-width'] : ''} ${
|
|
16
|
+
isTocEnabled ? '' : styles['blog--no-toc']
|
|
17
|
+
}`}
|
|
18
|
+
>
|
|
14
19
|
|
|
15
20
|
{jsonLd && (
|
|
16
21
|
<script
|
|
@@ -41,6 +41,15 @@ $total-width: calc(#{$content-width} + #{styles.space(8)} + #{$sidebar-width});
|
|
|
41
41
|
min-width: 0;
|
|
42
42
|
}
|
|
43
43
|
}
|
|
44
|
+
|
|
45
|
+
&--no-toc {
|
|
46
|
+
grid-template-columns: minmax(0, 1fr);
|
|
47
|
+
max-width: $content-width;
|
|
48
|
+
|
|
49
|
+
&.blog--increased-width {
|
|
50
|
+
max-width: 100%;
|
|
51
|
+
}
|
|
52
|
+
}
|
|
44
53
|
}
|
|
45
54
|
|
|
46
55
|
$breakpoint: calc(
|