@san-siva/blogkit 1.0.12 → 1.1.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 +64 -13
- package/dist/cjs/components/Blog.js +3 -118
- package/dist/cjs/components/Blog.js.map +1 -1
- package/dist/cjs/components/BlogHeader.js +4 -4
- package/dist/cjs/components/BlogHeader.js.map +1 -1
- package/dist/cjs/components/BlogLink.js +4 -23
- package/dist/cjs/components/BlogLink.js.map +1 -1
- package/dist/cjs/components/BlogSection.js +4 -29
- package/dist/cjs/components/BlogSection.js.map +1 -1
- package/dist/cjs/components/Callout.js +3 -4
- package/dist/cjs/components/Callout.js.map +1 -1
- package/dist/cjs/components/CodeBlock.js +3 -25
- package/dist/cjs/components/CodeBlock.js.map +1 -1
- package/dist/cjs/components/Mermaid.js +3 -46
- package/dist/cjs/components/Mermaid.js.map +1 -1
- package/dist/cjs/components/Table.js +2 -7
- package/dist/cjs/components/Table.js.map +1 -1
- package/dist/cjs/dynamicComponents/BlogDynamic.js +167 -0
- package/dist/cjs/dynamicComponents/BlogDynamic.js.map +1 -0
- package/dist/cjs/dynamicComponents/BlogHeaderDynamic.js +13 -0
- package/dist/cjs/dynamicComponents/BlogHeaderDynamic.js.map +1 -0
- package/dist/cjs/dynamicComponents/BlogLinkDynamic.js +35 -0
- package/dist/cjs/dynamicComponents/BlogLinkDynamic.js.map +1 -0
- package/dist/cjs/dynamicComponents/BlogSectionDynamic.js +50 -0
- package/dist/cjs/dynamicComponents/BlogSectionDynamic.js.map +1 -0
- package/dist/cjs/dynamicComponents/CalloutDynamic.js +14 -0
- package/dist/cjs/dynamicComponents/CalloutDynamic.js.map +1 -0
- package/dist/cjs/dynamicComponents/CodeBlockDynamic.js +38 -0
- package/dist/cjs/dynamicComponents/CodeBlockDynamic.js.map +1 -0
- package/dist/cjs/dynamicComponents/MermaidDynamic.js +59 -0
- package/dist/cjs/dynamicComponents/MermaidDynamic.js.map +1 -0
- package/dist/cjs/dynamicComponents/TableDynamic.js +18 -0
- package/dist/cjs/dynamicComponents/TableDynamic.js.map +1 -0
- package/dist/cjs/index.css +2 -0
- package/dist/cjs/index.css.map +1 -0
- package/dist/cjs/staticComponents/BlogLinkStatic.js +17 -0
- package/dist/cjs/staticComponents/BlogLinkStatic.js.map +1 -0
- package/dist/cjs/staticComponents/BlogSectionStatic.js +19 -0
- package/dist/cjs/staticComponents/BlogSectionStatic.js.map +1 -0
- package/dist/cjs/staticComponents/BlogStatic.js +13 -0
- package/dist/cjs/staticComponents/BlogStatic.js.map +1 -0
- package/dist/cjs/staticComponents/CodeBlockStatic.js +13 -0
- package/dist/cjs/staticComponents/CodeBlockStatic.js.map +1 -0
- package/dist/cjs/staticComponents/MermaidStatic.js +13 -0
- package/dist/cjs/staticComponents/MermaidStatic.js.map +1 -0
- package/dist/cjs/styles/Blog.module.scss.js +0 -4
- package/dist/cjs/styles/Blog.module.scss.js.map +1 -1
- package/dist/cjs/styles/BlogHeader.module.scss.js +0 -4
- package/dist/cjs/styles/BlogHeader.module.scss.js.map +1 -1
- package/dist/cjs/styles/BlogLink.module.scss.js +0 -4
- package/dist/cjs/styles/BlogLink.module.scss.js.map +1 -1
- package/dist/cjs/styles/BlogSection.module.scss.js +0 -4
- package/dist/cjs/styles/BlogSection.module.scss.js.map +1 -1
- package/dist/cjs/styles/Callout.module.scss.js +0 -4
- package/dist/cjs/styles/Callout.module.scss.js.map +1 -1
- package/dist/cjs/styles/CodeBlock.module.scss.js +1 -5
- package/dist/cjs/styles/CodeBlock.module.scss.js.map +1 -1
- package/dist/cjs/styles/Mermaid.module.scss.js +0 -4
- package/dist/cjs/styles/Mermaid.module.scss.js.map +1 -1
- package/dist/cjs/styles/Table.module.scss.js +0 -4
- package/dist/cjs/styles/Table.module.scss.js.map +1 -1
- package/dist/esm/components/Blog.js +5 -120
- package/dist/esm/components/Blog.js.map +1 -1
- package/dist/esm/components/BlogHeader.js +5 -5
- package/dist/esm/components/BlogHeader.js.map +1 -1
- package/dist/esm/components/BlogLink.js +6 -25
- package/dist/esm/components/BlogLink.js.map +1 -1
- package/dist/esm/components/BlogSection.js +6 -31
- package/dist/esm/components/BlogSection.js.map +1 -1
- package/dist/esm/components/Callout.js +4 -5
- package/dist/esm/components/Callout.js.map +1 -1
- package/dist/esm/components/CodeBlock.js +5 -27
- package/dist/esm/components/CodeBlock.js.map +1 -1
- package/dist/esm/components/Mermaid.js +5 -48
- package/dist/esm/components/Mermaid.js.map +1 -1
- package/dist/esm/components/Table.js +3 -8
- package/dist/esm/components/Table.js.map +1 -1
- package/dist/esm/dynamicComponents/BlogDynamic.js +163 -0
- package/dist/esm/dynamicComponents/BlogDynamic.js.map +1 -0
- package/dist/esm/dynamicComponents/BlogHeaderDynamic.js +9 -0
- package/dist/esm/dynamicComponents/BlogHeaderDynamic.js.map +1 -0
- package/dist/esm/dynamicComponents/BlogLinkDynamic.js +31 -0
- package/dist/esm/dynamicComponents/BlogLinkDynamic.js.map +1 -0
- package/dist/esm/dynamicComponents/BlogSectionDynamic.js +46 -0
- package/dist/esm/dynamicComponents/BlogSectionDynamic.js.map +1 -0
- package/dist/esm/dynamicComponents/CalloutDynamic.js +10 -0
- package/dist/esm/dynamicComponents/CalloutDynamic.js.map +1 -0
- package/dist/esm/dynamicComponents/CodeBlockDynamic.js +34 -0
- package/dist/esm/dynamicComponents/CodeBlockDynamic.js.map +1 -0
- package/dist/esm/dynamicComponents/MermaidDynamic.js +55 -0
- package/dist/esm/dynamicComponents/MermaidDynamic.js.map +1 -0
- package/dist/esm/dynamicComponents/TableDynamic.js +14 -0
- package/dist/esm/dynamicComponents/TableDynamic.js.map +1 -0
- package/dist/esm/index.css +2 -0
- package/dist/esm/index.css.map +1 -0
- package/dist/esm/staticComponents/BlogLinkStatic.js +13 -0
- package/dist/esm/staticComponents/BlogLinkStatic.js.map +1 -0
- package/dist/esm/staticComponents/BlogSectionStatic.js +15 -0
- package/dist/esm/staticComponents/BlogSectionStatic.js.map +1 -0
- package/dist/esm/staticComponents/BlogStatic.js +9 -0
- package/dist/esm/staticComponents/BlogStatic.js.map +1 -0
- package/dist/esm/staticComponents/CodeBlockStatic.js +9 -0
- package/dist/esm/staticComponents/CodeBlockStatic.js.map +1 -0
- package/dist/esm/staticComponents/MermaidStatic.js +9 -0
- package/dist/esm/staticComponents/MermaidStatic.js.map +1 -0
- package/dist/esm/styles/Blog.module.scss.js +0 -4
- package/dist/esm/styles/Blog.module.scss.js.map +1 -1
- package/dist/esm/styles/BlogHeader.module.scss.js +0 -4
- package/dist/esm/styles/BlogHeader.module.scss.js.map +1 -1
- package/dist/esm/styles/BlogLink.module.scss.js +0 -4
- package/dist/esm/styles/BlogLink.module.scss.js.map +1 -1
- package/dist/esm/styles/BlogSection.module.scss.js +0 -4
- package/dist/esm/styles/BlogSection.module.scss.js.map +1 -1
- package/dist/esm/styles/Callout.module.scss.js +0 -4
- package/dist/esm/styles/Callout.module.scss.js.map +1 -1
- package/dist/esm/styles/CodeBlock.module.scss.js +1 -5
- package/dist/esm/styles/CodeBlock.module.scss.js.map +1 -1
- package/dist/esm/styles/Mermaid.module.scss.js +0 -4
- package/dist/esm/styles/Mermaid.module.scss.js.map +1 -1
- package/dist/esm/styles/Table.module.scss.js +0 -4
- package/dist/esm/styles/Table.module.scss.js.map +1 -1
- package/dist/types/components/Blog.d.ts +0 -4
- package/dist/types/components/Blog.d.ts.map +1 -1
- package/dist/types/components/BlogHeader.d.ts +2 -2
- package/dist/types/components/BlogHeader.d.ts.map +1 -1
- package/dist/types/components/BlogLink.d.ts +2 -2
- package/dist/types/components/BlogLink.d.ts.map +1 -1
- package/dist/types/components/BlogSection.d.ts +5 -4
- package/dist/types/components/BlogSection.d.ts.map +1 -1
- package/dist/types/components/Callout.d.ts +1 -1
- package/dist/types/components/Callout.d.ts.map +1 -1
- package/dist/types/components/CodeBlock.d.ts +2 -3
- package/dist/types/components/CodeBlock.d.ts.map +1 -1
- package/dist/types/components/Mermaid.d.ts.map +1 -1
- package/dist/types/components/Table.d.ts.map +1 -1
- package/dist/types/components/index.d.ts +0 -1
- package/dist/types/components/index.d.ts.map +1 -1
- package/dist/types/dynamicComponents/BlogDynamic.d.ts +12 -0
- package/dist/types/dynamicComponents/BlogDynamic.d.ts.map +1 -0
- package/dist/types/dynamicComponents/BlogHeaderDynamic.d.ts +8 -0
- package/dist/types/dynamicComponents/BlogHeaderDynamic.d.ts.map +1 -0
- package/dist/types/dynamicComponents/BlogLinkDynamic.d.ts +9 -0
- package/dist/types/dynamicComponents/BlogLinkDynamic.d.ts.map +1 -0
- package/dist/types/dynamicComponents/BlogSectionDynamic.d.ts +11 -0
- package/dist/types/dynamicComponents/BlogSectionDynamic.d.ts.map +1 -0
- package/dist/types/dynamicComponents/CalloutDynamic.d.ts +10 -0
- package/dist/types/dynamicComponents/CalloutDynamic.d.ts.map +1 -0
- package/dist/types/dynamicComponents/CodeBlockDynamic.d.ts +10 -0
- package/dist/types/dynamicComponents/CodeBlockDynamic.d.ts.map +1 -0
- package/dist/types/dynamicComponents/MermaidDynamic.d.ts +9 -0
- package/dist/types/dynamicComponents/MermaidDynamic.d.ts.map +1 -0
- package/dist/types/dynamicComponents/TableDynamic.d.ts +10 -0
- package/dist/types/dynamicComponents/TableDynamic.d.ts.map +1 -0
- package/dist/types/index.d.ts +0 -1
- package/dist/types/index.d.ts.map +1 -1
- package/dist/types/staticComponents/BlogLinkStatic.d.ts +9 -0
- package/dist/types/staticComponents/BlogLinkStatic.d.ts.map +1 -0
- package/dist/types/staticComponents/BlogSectionStatic.d.ts +10 -0
- package/dist/types/staticComponents/BlogSectionStatic.d.ts.map +1 -0
- package/dist/types/staticComponents/BlogStatic.d.ts +7 -0
- package/dist/types/staticComponents/BlogStatic.d.ts.map +1 -0
- package/dist/types/staticComponents/CodeBlockStatic.d.ts +9 -0
- package/dist/types/staticComponents/CodeBlockStatic.d.ts.map +1 -0
- package/dist/types/staticComponents/MermaidStatic.d.ts +9 -0
- package/dist/types/staticComponents/MermaidStatic.d.ts.map +1 -0
- package/package.json +8 -2
- package/src/components/Blog.tsx +7 -195
- package/src/components/BlogHeader.tsx +10 -23
- package/src/components/BlogLink.tsx +28 -58
- package/src/components/BlogSection.tsx +32 -57
- package/src/components/Callout.tsx +12 -11
- package/src/components/CodeBlock.tsx +23 -55
- package/src/components/Mermaid.tsx +21 -55
- package/src/components/Table.tsx +7 -34
- package/src/components/index.ts +0 -2
- package/src/dynamicComponents/BlogDynamic.tsx +257 -0
- package/src/dynamicComponents/BlogHeaderDynamic.tsx +32 -0
- package/src/dynamicComponents/BlogLinkDynamic.tsx +74 -0
- package/src/dynamicComponents/BlogSectionDynamic.tsx +90 -0
- package/src/dynamicComponents/CalloutDynamic.tsx +27 -0
- package/src/dynamicComponents/CodeBlockDynamic.tsx +76 -0
- package/src/dynamicComponents/MermaidDynamic.tsx +78 -0
- package/src/dynamicComponents/TableDynamic.tsx +54 -0
- package/src/index.ts +0 -3
- package/src/staticComponents/BlogLinkStatic.tsx +45 -0
- package/src/staticComponents/BlogSectionStatic.tsx +40 -0
- package/src/staticComponents/BlogStatic.tsx +16 -0
- package/src/staticComponents/CodeBlockStatic.tsx +34 -0
- package/src/staticComponents/MermaidStatic.tsx +26 -0
- package/src/styles/Blog.module.scss +17 -7
- package/src/styles/CodeBlock.module.scss +46 -41
- package/src/styles/CodeBlock.module.scss.d.ts +1 -0
- package/dist/cjs/node_modules/style-inject/dist/style-inject.es.js +0 -33
- package/dist/cjs/node_modules/style-inject/dist/style-inject.es.js.map +0 -1
- package/dist/esm/node_modules/style-inject/dist/style-inject.es.js +0 -29
- package/dist/esm/node_modules/style-inject/dist/style-inject.es.js.map +0 -1
package/README.md
CHANGED
|
@@ -1,23 +1,36 @@
|
|
|
1
1
|
# Blogkit
|
|
2
2
|
|
|
3
|
-
A
|
|
3
|
+
A comprehensive, production-ready blog component library for React and Next.js applications. Built with TypeScript and SCSS modules, Blogkit provides a complete suite of components for creating professional, interactive blog posts with advanced features including syntax highlighting, diagram rendering, callouts, and more.
|
|
4
4
|
|
|
5
|
-
**[
|
|
5
|
+
**[View Full Documentation](https://blogkit-c367c.web.app/)** | **[Live Demo](https://santhoshsiva.dev)**
|
|
6
6
|
|
|
7
|
-
##
|
|
7
|
+
## Overview
|
|
8
8
|
|
|
9
|
-
|
|
9
|
+
Blogkit is designed to streamline the development of content-rich blog applications by providing a modular, customizable component library. It supports modern React patterns, offers full TypeScript support, and includes responsive design out of the box.
|
|
10
|
+
|
|
11
|
+
## Features
|
|
12
|
+
|
|
13
|
+
- **Blog Layout System**: Pre-built layout components with table of contents navigation
|
|
14
|
+
- **Syntax Highlighting**: Code block components with multi-language support via Prism.js
|
|
15
|
+
- **Diagram Rendering**: Integrated Mermaid.js support for flowcharts, sequence diagrams, and more
|
|
16
|
+
- **Content Components**: Callouts, data tables, and specialized blog link components
|
|
17
|
+
- **TypeScript Support**: Fully typed API for enhanced developer experience
|
|
18
|
+
- **Responsive Design**: Mobile-first design with SCSS modules
|
|
19
|
+
- **React 19 Compatible**: Built to work seamlessly with the latest React version
|
|
20
|
+
- **Next.js Optimized**: Designed for optimal performance in Next.js applications
|
|
10
21
|
|
|
11
22
|
## Installation
|
|
12
23
|
|
|
13
24
|
```bash
|
|
14
|
-
npm install @san-siva/blogkit
|
|
25
|
+
npm install @san-siva/blogkit
|
|
15
26
|
# or
|
|
16
|
-
yarn add @san-siva/blogkit
|
|
27
|
+
yarn add @san-siva/blogkit
|
|
17
28
|
# or
|
|
18
|
-
pnpm add @san-siva/blogkit
|
|
29
|
+
pnpm add @san-siva/blogkit
|
|
19
30
|
```
|
|
20
31
|
|
|
32
|
+
> **Note:** The required `@san-siva/stylekit` package is automatically installed as a dependency.
|
|
33
|
+
|
|
21
34
|
### Peer Dependencies
|
|
22
35
|
|
|
23
36
|
Blogkit requires the following peer dependencies:
|
|
@@ -31,6 +44,7 @@ npm install react@^19.0.0 react-dom@^19.0.0 next@^16.0.10 @react-spring/web@^10.
|
|
|
31
44
|
```tsx
|
|
32
45
|
import { Blog, BlogHeader, BlogSection, CodeBlock, Callout } from '@san-siva/blogkit';
|
|
33
46
|
import '@san-siva/stylekit/index.module.scss';
|
|
47
|
+
import '@san-siva/blogkit/styles.css';
|
|
34
48
|
|
|
35
49
|
export default function MyBlogPost() {
|
|
36
50
|
return (
|
|
@@ -60,22 +74,59 @@ export default function MyBlogPost() {
|
|
|
60
74
|
|
|
61
75
|
## Documentation
|
|
62
76
|
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
👉 **[Visit the Full Documentation](https://blogkit-c367c.web.app/)**
|
|
77
|
+
Comprehensive documentation is available at [https://blogkit-c367c.web.app/](https://blogkit-c367c.web.app/)
|
|
66
78
|
|
|
67
79
|
The documentation includes:
|
|
68
80
|
|
|
69
81
|
- Complete component API reference
|
|
70
82
|
- Interactive live examples
|
|
83
|
+
- Implementation guides and best practices
|
|
71
84
|
- Code snippets for all components
|
|
72
|
-
- Customization guide
|
|
73
|
-
- TypeScript usage examples
|
|
85
|
+
- Customization and theming guide
|
|
86
|
+
- TypeScript usage examples and type definitions
|
|
87
|
+
|
|
88
|
+
## Examples
|
|
89
|
+
|
|
90
|
+
See Blogkit in action in these blogs and documentation sites:
|
|
91
|
+
|
|
92
|
+
- **[Gitsy](https://gitsy-56895.web.app/)** - A blog built with Blogkit showcasing various components
|
|
93
|
+
- **[Optimizing Background Tasks with requestIdleCallback](https://santhoshsiva.dev/blog/optimizing-background-tasks-with-requestidlecallback-advanced-scheduling-in-the-javascript-event-loop/)** - Advanced scheduling in the JavaScript event loop
|
|
94
|
+
- **[Linting at Scale](https://santhoshsiva.dev/blog/linting-at-scale-strategies-for-updating-eslint-configs-in-large-applications/)** - Strategies for updating ESLint configs in large applications
|
|
95
|
+
|
|
96
|
+
## Requirements
|
|
97
|
+
|
|
98
|
+
- React ^19.0.0
|
|
99
|
+
- Next.js ^16.0.10
|
|
100
|
+
- Node.js 18+ recommended
|
|
101
|
+
|
|
102
|
+
## Browser Support
|
|
103
|
+
|
|
104
|
+
Blogkit supports all modern browsers:
|
|
105
|
+
- Chrome (latest)
|
|
106
|
+
- Firefox (latest)
|
|
107
|
+
- Safari (latest)
|
|
108
|
+
- Edge (latest)
|
|
74
109
|
|
|
75
110
|
## Contributing
|
|
76
111
|
|
|
77
|
-
Contributions are welcome
|
|
112
|
+
Contributions are welcome and appreciated. To contribute:
|
|
113
|
+
|
|
114
|
+
1. Fork the repository
|
|
115
|
+
2. Create a feature branch (`git checkout -b feature/improvement`)
|
|
116
|
+
3. Commit your changes (`git commit -am 'Add new feature'`)
|
|
117
|
+
4. Push to the branch (`git push origin feature/improvement`)
|
|
118
|
+
5. Open a Pull Request
|
|
119
|
+
|
|
120
|
+
Please ensure your code follows the existing style conventions and includes appropriate tests.
|
|
121
|
+
|
|
122
|
+
For bug reports and feature requests, please [open an issue](https://github.com/san-siva/blogkit/issues) on GitHub.
|
|
78
123
|
|
|
79
124
|
## License
|
|
80
125
|
|
|
81
126
|
MIT © [Santhosh Siva](https://santhoshsiva.dev)
|
|
127
|
+
|
|
128
|
+
## Author
|
|
129
|
+
|
|
130
|
+
**Santhosh Siva**
|
|
131
|
+
- Website: [https://santhoshsiva.dev](https://santhoshsiva.dev)
|
|
132
|
+
- GitHub: [@san-siva](https://github.com/san-siva)
|
|
@@ -5,126 +5,11 @@ Object.defineProperty(exports, '__esModule', { value: true });
|
|
|
5
5
|
|
|
6
6
|
var jsxRuntime = require('react/jsx-runtime');
|
|
7
7
|
var react = require('react');
|
|
8
|
-
var
|
|
8
|
+
var BlogStatic = require('../staticComponents/BlogStatic.js');
|
|
9
9
|
|
|
10
|
+
const BlogDynamic = react.lazy(() => Promise.resolve().then(function () { return require('../dynamicComponents/BlogDynamic.js'); }));
|
|
10
11
|
const Blog = ({ children, title = 'In this article' }) => {
|
|
11
|
-
|
|
12
|
-
const highlightCategoryTimerReference = react.useRef(null);
|
|
13
|
-
const clearTimers = (addPaddingTopTimerReference_, highlightCategoryTimerReference_) => {
|
|
14
|
-
if (addPaddingTopTimerReference_) {
|
|
15
|
-
clearTimeout(addPaddingTopTimerReference_);
|
|
16
|
-
}
|
|
17
|
-
if (highlightCategoryTimerReference_) {
|
|
18
|
-
clearTimeout(highlightCategoryTimerReference_);
|
|
19
|
-
}
|
|
20
|
-
};
|
|
21
|
-
const sectionReferences = react.useRef(new Map());
|
|
22
|
-
const [categoryTitles, setCategoryTitles] = react.useState(new Map());
|
|
23
|
-
const [visibleTitle, setVisibleTitle] = react.useState(null);
|
|
24
|
-
react.useEffect(() => {
|
|
25
|
-
let firstSectionId = null;
|
|
26
|
-
const now = Date.now();
|
|
27
|
-
for (const [id, { title, el, isSubSection }] of sectionReferences.current) {
|
|
28
|
-
if (!firstSectionId) {
|
|
29
|
-
firstSectionId = id;
|
|
30
|
-
}
|
|
31
|
-
setCategoryTitles((previous) => {
|
|
32
|
-
const newState = new Map(previous);
|
|
33
|
-
newState.set(id, {
|
|
34
|
-
el,
|
|
35
|
-
title,
|
|
36
|
-
lastUpdatedAt: now,
|
|
37
|
-
isSubSection,
|
|
38
|
-
});
|
|
39
|
-
return newState;
|
|
40
|
-
});
|
|
41
|
-
}
|
|
42
|
-
setVisibleTitle(firstSectionId);
|
|
43
|
-
}, []);
|
|
44
|
-
react.useEffect(() => {
|
|
45
|
-
const observers = new Map();
|
|
46
|
-
for (const [id, { el }] of categoryTitles) {
|
|
47
|
-
const observer = new IntersectionObserver(([entry]) => {
|
|
48
|
-
if (!entry.isIntersecting)
|
|
49
|
-
return;
|
|
50
|
-
setVisibleTitle(visibleId => {
|
|
51
|
-
if (visibleId === id && !entry.isIntersecting)
|
|
52
|
-
return null;
|
|
53
|
-
if (entry.isIntersecting)
|
|
54
|
-
return id;
|
|
55
|
-
return visibleId;
|
|
56
|
-
});
|
|
57
|
-
}, { threshold: 0.1 });
|
|
58
|
-
observers.set(id, observer);
|
|
59
|
-
observer.observe(el);
|
|
60
|
-
}
|
|
61
|
-
return () => {
|
|
62
|
-
for (const observer of observers.values()) {
|
|
63
|
-
observer.disconnect();
|
|
64
|
-
}
|
|
65
|
-
};
|
|
66
|
-
}, [categoryTitles.size]);
|
|
67
|
-
react.useEffect(() => clearTimers(addPaddingTopTimerReference.current, highlightCategoryTimerReference.current), [addPaddingTopTimerReference, highlightCategoryTimerReference]);
|
|
68
|
-
const addSectionReferences = (element, isSubSection = false) => {
|
|
69
|
-
if (!element)
|
|
70
|
-
return;
|
|
71
|
-
const id = element.dataset.id;
|
|
72
|
-
if (!id)
|
|
73
|
-
return;
|
|
74
|
-
const title = element.dataset.title;
|
|
75
|
-
if (!title)
|
|
76
|
-
return;
|
|
77
|
-
sectionReferences.current.set(id, {
|
|
78
|
-
el: element,
|
|
79
|
-
title,
|
|
80
|
-
isSubSection,
|
|
81
|
-
});
|
|
82
|
-
};
|
|
83
|
-
const handleSectionReference = (element) => {
|
|
84
|
-
if (!element)
|
|
85
|
-
return;
|
|
86
|
-
const { parentRef, childRefs } = element;
|
|
87
|
-
if (!parentRef)
|
|
88
|
-
return;
|
|
89
|
-
addSectionReferences(parentRef);
|
|
90
|
-
if (!Array.isArray(childRefs))
|
|
91
|
-
return;
|
|
92
|
-
for (const childReference of childRefs) {
|
|
93
|
-
if (!childReference)
|
|
94
|
-
continue;
|
|
95
|
-
addSectionReferences(childReference, true);
|
|
96
|
-
}
|
|
97
|
-
};
|
|
98
|
-
const handleClickCategoryTitle = (error) => {
|
|
99
|
-
const id = error.currentTarget.dataset.id;
|
|
100
|
-
const index = error.currentTarget.dataset.idx;
|
|
101
|
-
if (!id || !index)
|
|
102
|
-
return;
|
|
103
|
-
const { el } = categoryTitles.get(id) || {};
|
|
104
|
-
if (!el)
|
|
105
|
-
return;
|
|
106
|
-
const top = el.getBoundingClientRect().top + document.body.scrollTop - 100;
|
|
107
|
-
document.body.scrollTo({
|
|
108
|
-
top,
|
|
109
|
-
behavior: 'smooth',
|
|
110
|
-
});
|
|
111
|
-
const timer = setTimeout(() => {
|
|
112
|
-
setVisibleTitle(id);
|
|
113
|
-
clearTimeout(timer);
|
|
114
|
-
}, 1000);
|
|
115
|
-
};
|
|
116
|
-
return (jsxRuntime.jsxs("div", { className: Blog_module.default.blog, children: [jsxRuntime.jsx("div", { className: Blog_module.default['blog__content'], children: react.Children.map(children, child => {
|
|
117
|
-
if (!react.isValidElement(child))
|
|
118
|
-
return child;
|
|
119
|
-
return react.cloneElement(child, {
|
|
120
|
-
ref: handleSectionReference,
|
|
121
|
-
});
|
|
122
|
-
}) }), jsxRuntime.jsxs("div", { className: Blog_module.default['blog__sidebar'], children: [jsxRuntime.jsx("p", { className: `${Blog_module.default['margin-bottom--3']} ${Blog_module.default['category__header']}`, children: title }), [...categoryTitles].map(([id, { title, isSubSection }], index, array) => {
|
|
123
|
-
const isNextSectionSubSection = array[index + 1]?.[1]?.isSubSection;
|
|
124
|
-
return (jsxRuntime.jsx("p", { "data-idx": index, "data-id": id, className: `${Blog_module.default['category__title']} ${id === visibleTitle ? Blog_module.default['category__title--active'] : ''} ${isSubSection ? Blog_module.default['category__title--sub'] : ''} ${isSubSection && !isNextSectionSubSection
|
|
125
|
-
? Blog_module.default['margin-bottom-imp--2']
|
|
126
|
-
: ''}`, onClick: handleClickCategoryTitle, children: title }, id));
|
|
127
|
-
})] })] }));
|
|
12
|
+
return (jsxRuntime.jsx(react.Suspense, { fallback: jsxRuntime.jsx(BlogStatic.default, { children: children }), children: jsxRuntime.jsx(BlogDynamic, { title: title, children: children }) }));
|
|
128
13
|
};
|
|
129
14
|
|
|
130
15
|
exports.default = Blog;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Blog.js","sources":["../../../src/components/Blog.tsx"],"sourcesContent":["'use client';\n\nimport {\n\tChildren,\n\tcloneElement,\n\tisValidElement,\n\tuseEffect,\n\tuseRef,\n\tuseState,\n} from 'react';\n\nimport type { MouseEvent, ReactNode, RefAttributes } from 'react';\n\nimport styles from '../styles/Blog.module.scss';\n\ninterface BlogProperties {\n\tchildren: ReactNode;\n\ttitle?: string;\n}\n\nexport interface ForwardedReference {\n\tparentRef: HTMLDivElement;\n\tchildRefs: HTMLDivElement[];\n}\n\ninterface SectionReferenceValue {\n\tel: HTMLElement;\n\ttitle: string;\n\tisSubSection: boolean;\n}\n\ntype SectionReference = Map<string, SectionReferenceValue>;\n\ninterface CategoryTitleValue extends SectionReferenceValue {\n\tlastUpdatedAt: number;\n}\n\ntype CategoryTitle = Map<string, CategoryTitleValue>;\n\ntype AddPaddingTopTimerReference = ReturnType<typeof setTimeout> | null;\n\nconst Blog = ({ children, title = 'In this article' }: BlogProperties) => {\n\tconst addPaddingTopTimerReference = useRef<AddPaddingTopTimerReference>(null);\n\tconst highlightCategoryTimerReference =\n\t\tuseRef<AddPaddingTopTimerReference>(null);\n\n\tconst clearTimers = (\n\t\taddPaddingTopTimerReference_: AddPaddingTopTimerReference,\n\t\thighlightCategoryTimerReference_: AddPaddingTopTimerReference\n\t) => {\n\t\tif (addPaddingTopTimerReference_) {\n\t\t\tclearTimeout(addPaddingTopTimerReference_);\n\t\t}\n\t\tif (highlightCategoryTimerReference_) {\n\t\t\tclearTimeout(highlightCategoryTimerReference_);\n\t\t}\n\t};\n\n\tconst sectionReferences = useRef<SectionReference>(new Map());\n\tconst [categoryTitles, setCategoryTitles] = useState<CategoryTitle>(\n\t\tnew Map()\n\t);\n\tconst [visibleTitle, setVisibleTitle] = useState<string | null>(null);\n\n\tuseEffect(() => {\n\t\tlet firstSectionId: string | null = null;\n\t\tconst now = Date.now();\n\t\tfor (const [id, { title, el, isSubSection }] of sectionReferences.current) {\n\t\t\tif (!firstSectionId) {\n\t\t\t\tfirstSectionId = id;\n\t\t\t}\n\t\t\tsetCategoryTitles((previous: CategoryTitle) => {\n\t\t\t\tconst newState = new Map(previous);\n\t\t\t\tnewState.set(id, {\n\t\t\t\t\tel,\n\t\t\t\t\ttitle,\n\t\t\t\t\tlastUpdatedAt: now,\n\t\t\t\t\tisSubSection,\n\t\t\t\t});\n\t\t\t\treturn newState;\n\t\t\t});\n\t\t}\n\t\tsetVisibleTitle(firstSectionId);\n\t}, []);\n\n\tuseEffect(() => {\n\t\tconst observers = new Map<string, IntersectionObserver>();\n\t\tfor (const [id, { el }] of categoryTitles) {\n\t\t\tconst observer = new IntersectionObserver(\n\t\t\t\t([entry]) => {\n\t\t\t\t\tif (!entry.isIntersecting) return;\n\t\t\t\t\tsetVisibleTitle(visibleId => {\n\t\t\t\t\t\tif (visibleId === id && !entry.isIntersecting) return null;\n\t\t\t\t\t\tif (entry.isIntersecting) return id;\n\t\t\t\t\t\treturn visibleId;\n\t\t\t\t\t});\n\t\t\t\t},\n\t\t\t\t{ threshold: 0.1 }\n\t\t\t);\n\t\t\tobservers.set(id, observer);\n\t\t\tobserver.observe(el);\n\t\t}\n\t\treturn () => {\n\t\t\tfor (const observer of observers.values()) {\n\t\t\t\tobserver.disconnect();\n\t\t\t}\n\t\t};\n\t}, [categoryTitles.size]);\n\n\tuseEffect(\n\t\t() =>\n\t\t\tclearTimers(\n\t\t\t\taddPaddingTopTimerReference.current,\n\t\t\t\thighlightCategoryTimerReference.current\n\t\t\t),\n\t\t[addPaddingTopTimerReference, highlightCategoryTimerReference]\n\t);\n\n\tconst addSectionReferences = (element: HTMLElement, isSubSection = false) => {\n\t\tif (!element) return;\n\t\tconst id = element.dataset.id;\n\t\tif (!id) return;\n\t\tconst title = element.dataset.title;\n\t\tif (!title) return;\n\n\t\tsectionReferences.current.set(id, {\n\t\t\tel: element,\n\t\t\ttitle,\n\t\t\tisSubSection,\n\t\t});\n\t};\n\n\tconst handleSectionReference = (element: ForwardedReference) => {\n\t\tif (!element) return;\n\t\tconst { parentRef, childRefs } = element;\n\t\tif (!parentRef) return;\n\t\taddSectionReferences(parentRef);\n\t\tif (!Array.isArray(childRefs)) return;\n\t\tfor (const childReference of childRefs) {\n\t\t\tif (!childReference) continue;\n\t\t\taddSectionReferences(childReference, true);\n\t\t}\n\t};\n\n\tconst handleClickCategoryTitle = (\n\t\terror: MouseEvent<HTMLParagraphElement>\n\t) => {\n\t\tconst id = error.currentTarget.dataset.id;\n\t\tconst index = error.currentTarget.dataset.idx;\n\t\tif (!id || !index) return;\n\n\t\tconst { el } = categoryTitles.get(id) || {};\n\t\tif (!el) return;\n\n\t\tconst top = el.getBoundingClientRect().top + document.body.scrollTop - 100;\n\t\tdocument.body.scrollTo({\n\t\t\ttop,\n\t\t\tbehavior: 'smooth',\n\t\t});\n\n\t\tconst timer = setTimeout(() => {\n\t\t\tsetVisibleTitle(id);\n\t\t\tclearTimeout(timer);\n\t\t}, 1000);\n\t};\n\n\treturn (\n\t\t<div className={styles.blog}>\n\t\t\t<div className={styles['blog__content']}>\n\t\t\t\t{Children.map(children, child => {\n\t\t\t\t\tif (!isValidElement(child)) return child;\n\t\t\t\t\treturn cloneElement(child, {\n\t\t\t\t\t\tref: handleSectionReference,\n\t\t\t\t\t} as RefAttributes<ForwardedReference>);\n\t\t\t\t})}\n\t\t\t</div>\n\t\t\t<div className={styles['blog__sidebar']}>\n\t\t\t\t<p\n\t\t\t\t\tclassName={`${styles['margin-bottom--3']} ${styles['category__header']}`}\n\t\t\t\t>\n\t\t\t\t\t{title}\n\t\t\t\t</p>\n\t\t\t\t{[...categoryTitles].map(\n\t\t\t\t\t([id, { title, isSubSection }], index, array) => {\n\t\t\t\t\t\tconst isNextSectionSubSection = array[index + 1]?.[1]?.isSubSection;\n\t\t\t\t\t\treturn (\n\t\t\t\t\t\t\t<p\n\t\t\t\t\t\t\t\tkey={id}\n\t\t\t\t\t\t\t\tdata-idx={index}\n\t\t\t\t\t\t\t\tdata-id={id}\n\t\t\t\t\t\t\t\tclassName={`${styles['category__title']} ${\n\t\t\t\t\t\t\t\t\tid === visibleTitle ? styles['category__title--active'] : ''\n\t\t\t\t\t\t\t\t} ${isSubSection ? styles['category__title--sub'] : ''} ${\n\t\t\t\t\t\t\t\t\tisSubSection && !isNextSectionSubSection\n\t\t\t\t\t\t\t\t\t\t? styles['margin-bottom-imp--2']\n\t\t\t\t\t\t\t\t\t\t: ''\n\t\t\t\t\t\t\t\t}`}\n\t\t\t\t\t\t\t\tonClick={handleClickCategoryTitle}\n\t\t\t\t\t\t\t>\n\t\t\t\t\t\t\t\t{title}\n\t\t\t\t\t\t\t</p>\n\t\t\t\t\t\t);\n\t\t\t\t\t}\n\t\t\t\t)}\n\t\t\t</div>\n\t\t</div>\n\t);\n};\n\nexport default Blog;\n"],"names":["useRef","useState","useEffect","_jsxs","styles","_jsx","Children","isValidElement","cloneElement"],"mappings":"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"}
|
|
1
|
+
{"version":3,"file":"Blog.js","sources":["../../../src/components/Blog.tsx"],"sourcesContent":["'use client';\n\nimport { lazy, Suspense } from 'react';\nimport type { ReactNode } from 'react';\nimport BlogStatic from '../staticComponents/BlogStatic';\n\nconst BlogDynamic = lazy(() => import('../dynamicComponents/BlogDynamic'));\n\ninterface BlogProperties {\n\tchildren: ReactNode;\n\ttitle?: string;\n}\n\nconst Blog = ({ children, title = 'In this article' }: BlogProperties) => {\n\treturn (\n\t\t<Suspense fallback={<BlogStatic>{children}</BlogStatic>}>\n\t\t\t<BlogDynamic title={title}>{children}</BlogDynamic>\n\t\t</Suspense>\n\t);\n};\n\nexport default Blog;\n"],"names":["lazy","_jsx","Suspense","BlogStatic"],"mappings":";;;;;;;;AAMA,MAAM,WAAW,GAAGA,UAAI,CAAC,MAAM,oDAAO,qCAAkC,KAAC,CAAC;AAO1E,MAAM,IAAI,GAAG,CAAC,EAAE,QAAQ,EAAE,KAAK,GAAG,iBAAiB,EAAkB,KAAI;IACxE,QACCC,eAACC,cAAQ,EAAA,EAAC,QAAQ,EAAED,cAAA,CAACE,kBAAU,EAAA,EAAA,QAAA,EAAE,QAAQ,EAAA,CAAc,YACtDF,cAAA,CAAC,WAAW,EAAA,EAAC,KAAK,EAAE,KAAK,YAAG,QAAQ,EAAA,CAAe,EAAA,CACzC;AAEb;;;;"}
|
|
@@ -3,11 +3,11 @@
|
|
|
3
3
|
Object.defineProperty(exports, '__esModule', { value: true });
|
|
4
4
|
|
|
5
5
|
var jsxRuntime = require('react/jsx-runtime');
|
|
6
|
-
var
|
|
7
|
-
var BlogHeader_module = require('../styles/BlogHeader.module.scss.js');
|
|
6
|
+
var BlogHeaderDynamic = require('../dynamicComponents/BlogHeaderDynamic.js');
|
|
8
7
|
|
|
9
|
-
const
|
|
10
|
-
|
|
8
|
+
const BlogHeader = ({ title, desc, isDescCite = true, }) => {
|
|
9
|
+
return (jsxRuntime.jsx(BlogHeaderDynamic.default, { title: title, desc: desc, isDescCite: isDescCite }));
|
|
10
|
+
};
|
|
11
11
|
|
|
12
12
|
exports.default = BlogHeader;
|
|
13
13
|
//# sourceMappingURL=BlogHeader.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"BlogHeader.js","sources":["../../../src/components/BlogHeader.tsx"],"sourcesContent":["import
|
|
1
|
+
{"version":3,"file":"BlogHeader.js","sources":["../../../src/components/BlogHeader.tsx"],"sourcesContent":["import BlogHeaderDynamic from '../dynamicComponents/BlogHeaderDynamic';\n\ninterface BlogHeaderProperties {\n\ttitle: string[];\n\tdesc: string[];\n\tisDescCite?: boolean;\n}\n\nconst BlogHeader = ({\n\ttitle,\n\tdesc,\n\tisDescCite = true,\n}: BlogHeaderProperties) => {\n\treturn (\n\t\t<BlogHeaderDynamic title={title} desc={desc} isDescCite={isDescCite} />\n\t);\n};\n\nexport default BlogHeader;\n"],"names":["_jsx","BlogHeaderDynamic"],"mappings":";;;;;;;AAQA,MAAM,UAAU,GAAG,CAAC,EACnB,KAAK,EACL,IAAI,EACJ,UAAU,GAAG,IAAI,GACK,KAAI;AAC1B,IAAA,QACCA,cAAA,CAACC,yBAAiB,EAAA,EAAC,KAAK,EAAE,KAAK,EAAE,IAAI,EAAE,IAAI,EAAE,UAAU,EAAE,UAAU,EAAA,CAAI;AAEzE;;;;"}
|
|
@@ -5,30 +5,11 @@ Object.defineProperty(exports, '__esModule', { value: true });
|
|
|
5
5
|
|
|
6
6
|
var jsxRuntime = require('react/jsx-runtime');
|
|
7
7
|
var react = require('react');
|
|
8
|
-
var
|
|
9
|
-
var BlogLink_module = require('../styles/BlogLink.module.scss.js');
|
|
10
|
-
var index = require('../utils/index.js');
|
|
8
|
+
var BlogLinkStatic = require('../staticComponents/BlogLinkStatic.js');
|
|
11
9
|
|
|
12
|
-
const
|
|
13
|
-
const
|
|
14
|
-
|
|
15
|
-
const BlogLink = ({ title = '', desc = '', isInProgress = false, href }) => {
|
|
16
|
-
const [isHovered, setIsHovered] = react.useState(false);
|
|
17
|
-
const link = href || `/blog/${index.generateUrlForBlogTitle(title)}`;
|
|
18
|
-
const svgColor = web.useSpring({
|
|
19
|
-
stroke: isHovered ? '#4242fa' : 'transparent',
|
|
20
|
-
});
|
|
21
|
-
const polyLine = web.useSpring({
|
|
22
|
-
points: isHovered ? MOVED_POLYLINE_POINTS : DEFAULT_POLYLINE_POINTS,
|
|
23
|
-
config: { duration: 200 },
|
|
24
|
-
});
|
|
25
|
-
const lineEnd = web.useSpring({
|
|
26
|
-
x2: isHovered ? `${DEFAULT_LINE_END + 2}` : `${DEFAULT_LINE_END}`,
|
|
27
|
-
config: { duration: 200 },
|
|
28
|
-
});
|
|
29
|
-
if (isInProgress)
|
|
30
|
-
return null;
|
|
31
|
-
return (jsxRuntime.jsxs("a", { className: BlogLink_module.default['blog-link'], onMouseEnter: () => setIsHovered(true), onMouseLeave: () => setIsHovered(false), href: link, rel: "noopener noreferrer", children: [jsxRuntime.jsx("h6", { className: BlogLink_module.default['blog-link__title'], children: title }), jsxRuntime.jsx("p", { className: BlogLink_module.default['blog-link__description'], children: desc }), jsxRuntime.jsxs("div", { className: BlogLink_module.default['blog-link__read-more'], children: [jsxRuntime.jsx("p", { children: "Read More" }), jsxRuntime.jsxs(web.animated.svg, { xmlns: "http://www.w3.org/2000/svg", width: "18px", height: "18px", viewBox: "0 0 24 24", fill: "none", strokeWidth: "2", strokeLinecap: "round", strokeLinejoin: "round", style: svgColor, children: [jsxRuntime.jsx(web.animated.line, { x1: "5", y1: "12", y2: "12", x2: lineEnd.x2 }), jsxRuntime.jsx(web.animated.polyline, { points: polyLine.points })] })] })] }));
|
|
10
|
+
const BlogLinkDynamic = react.lazy(() => Promise.resolve().then(function () { return require('../dynamicComponents/BlogLinkDynamic.js'); }));
|
|
11
|
+
const BlogLink = ({ title = '', desc = '', isInProgress = false, href, }) => {
|
|
12
|
+
return (jsxRuntime.jsx(react.Suspense, { fallback: jsxRuntime.jsx(BlogLinkStatic.default, { title: title, desc: desc, isInProgress: isInProgress, href: href }), children: jsxRuntime.jsx(BlogLinkDynamic, { title: title, desc: desc, isInProgress: isInProgress, href: href }) }));
|
|
32
13
|
};
|
|
33
14
|
|
|
34
15
|
exports.default = BlogLink;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"BlogLink.js","sources":["../../../src/components/BlogLink.tsx"],"sourcesContent":["'use client';\n\nimport {
|
|
1
|
+
{"version":3,"file":"BlogLink.js","sources":["../../../src/components/BlogLink.tsx"],"sourcesContent":["'use client';\n\nimport { lazy, Suspense } from 'react';\nimport BlogLinkStatic from '../staticComponents/BlogLinkStatic';\n\nconst BlogLinkDynamic = lazy(\n\t() => import('../dynamicComponents/BlogLinkDynamic')\n);\n\ninterface BlogLinkProperties {\n\ttitle: string;\n\tdesc?: string;\n\tisInProgress?: boolean;\n\thref?: string;\n}\n\nconst BlogLink = ({\n\ttitle = '',\n\tdesc = '',\n\tisInProgress = false,\n\thref,\n}: BlogLinkProperties) => {\n\treturn (\n\t\t<Suspense\n\t\t\tfallback={\n\t\t\t\t<BlogLinkStatic\n\t\t\t\t\ttitle={title}\n\t\t\t\t\tdesc={desc}\n\t\t\t\t\tisInProgress={isInProgress}\n\t\t\t\t\thref={href}\n\t\t\t\t/>\n\t\t\t}\n\t\t>\n\t\t\t<BlogLinkDynamic\n\t\t\t\ttitle={title}\n\t\t\t\tdesc={desc}\n\t\t\t\tisInProgress={isInProgress}\n\t\t\t\thref={href}\n\t\t\t/>\n\t\t</Suspense>\n\t);\n};\n\nexport default BlogLink;\n"],"names":["lazy","_jsx","Suspense","BlogLinkStatic"],"mappings":";;;;;;;;AAKA,MAAM,eAAe,GAAGA,UAAI,CAC3B,MAAM,oDAAO,yCAAsC,KAAC,CACpD;AASD,MAAM,QAAQ,GAAG,CAAC,EACjB,KAAK,GAAG,EAAE,EACV,IAAI,GAAG,EAAE,EACT,YAAY,GAAG,KAAK,EACpB,IAAI,GACgB,KAAI;IACxB,QACCC,eAACC,cAAQ,EAAA,EACR,QAAQ,EACPD,cAAA,CAACE,sBAAc,EAAA,EACd,KAAK,EAAE,KAAK,EACZ,IAAI,EAAE,IAAI,EACV,YAAY,EAAE,YAAY,EAC1B,IAAI,EAAE,IAAI,EAAA,CACT,EAAA,QAAA,EAGHF,eAAC,eAAe,EAAA,EACf,KAAK,EAAE,KAAK,EACZ,IAAI,EAAE,IAAI,EACV,YAAY,EAAE,YAAY,EAC1B,IAAI,EAAE,IAAI,EAAA,CACT,EAAA,CACQ;AAEb;;;;"}
|
|
@@ -5,36 +5,11 @@ Object.defineProperty(exports, '__esModule', { value: true });
|
|
|
5
5
|
|
|
6
6
|
var jsxRuntime = require('react/jsx-runtime');
|
|
7
7
|
var react = require('react');
|
|
8
|
-
var
|
|
9
|
-
var index = require('../utils/index.js');
|
|
8
|
+
var BlogSectionStatic = require('../staticComponents/BlogSectionStatic.js');
|
|
10
9
|
|
|
11
|
-
const
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
const parentReference = react.useRef(null);
|
|
15
|
-
const childReferences = react.useRef([]);
|
|
16
|
-
react.useImperativeHandle(forwardedReference, () => ({
|
|
17
|
-
parentRef: parentReference.current,
|
|
18
|
-
childRefs: childReferences.current,
|
|
19
|
-
}));
|
|
20
|
-
const handleChildReferences = (element) => {
|
|
21
|
-
if (!element)
|
|
22
|
-
return;
|
|
23
|
-
const { parentRef: subParentReference } = element;
|
|
24
|
-
if (!subParentReference)
|
|
25
|
-
return;
|
|
26
|
-
childReferences.current.push(subParentReference);
|
|
27
|
-
};
|
|
28
|
-
return (jsxRuntime.jsxs("div", { className: `${BlogSection_module.default['blog-section']}
|
|
29
|
-
${increaseMarginBottom
|
|
30
|
-
? BlogSection_module.default['margin-bottom--9']
|
|
31
|
-
: BlogSection_module.default['margin-bottom--6']}`, "data-title": title, "data-id": id, ref: parentReference, children: [title ? (jsxRuntime.jsx("h4", { className: BlogSection_module.default['blog-section__title'], children: title })) : null, react.Children.map(children, child => {
|
|
32
|
-
if (!react.isValidElement(child))
|
|
33
|
-
return child;
|
|
34
|
-
return react.cloneElement(child, {
|
|
35
|
-
ref: handleChildReferences,
|
|
36
|
-
});
|
|
37
|
-
})] }));
|
|
10
|
+
const BlogSectionDynamic = react.lazy(() => Promise.resolve().then(function () { return require('../dynamicComponents/BlogSectionDynamic.js'); }));
|
|
11
|
+
const BlogSection = react.forwardRef(({ title = '', category = '', children = null, increaseMarginBottom = false, }, ref) => {
|
|
12
|
+
return (jsxRuntime.jsx(react.Suspense, { fallback: jsxRuntime.jsx(BlogSectionStatic.default, { title: title, category: category, increaseMarginBottom: increaseMarginBottom, children: children }), children: jsxRuntime.jsx(BlogSectionDynamic, { ref: ref, title: title, category: category, increaseMarginBottom: increaseMarginBottom, children: children }) }));
|
|
38
13
|
});
|
|
39
14
|
BlogSection.displayName = 'BlogSection';
|
|
40
15
|
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"BlogSection.js","sources":["../../../src/components/BlogSection.tsx"],"sourcesContent":["'use client';\n\nimport {
|
|
1
|
+
{"version":3,"file":"BlogSection.js","sources":["../../../src/components/BlogSection.tsx"],"sourcesContent":["'use client';\n\nimport { forwardRef, lazy, Suspense } from 'react';\nimport type { ReactNode } from 'react';\nimport BlogSectionStatic from '../staticComponents/BlogSectionStatic';\nimport type { ForwardedReference } from '../dynamicComponents/BlogDynamic';\nexport type { ForwardedReference };\n\nconst BlogSectionDynamic = lazy(\n\t() => import('../dynamicComponents/BlogSectionDynamic')\n);\n\ninterface BlogSectionProperties {\n\ttitle?: string;\n\tcategory?: string;\n\tchildren?: ReactNode;\n\tincreaseMarginBottom?: boolean;\n}\n\nconst BlogSection = forwardRef<ForwardedReference, BlogSectionProperties>(\n\t(\n\t\t{\n\t\t\ttitle = '',\n\t\t\tcategory = '',\n\t\t\tchildren = null,\n\t\t\tincreaseMarginBottom = false,\n\t\t},\n\t\tref\n\t) => {\n\t\treturn (\n\t\t\t<Suspense\n\t\t\t\tfallback={\n\t\t\t\t\t<BlogSectionStatic\n\t\t\t\t\t\ttitle={title}\n\t\t\t\t\t\tcategory={category}\n\t\t\t\t\t\tincreaseMarginBottom={increaseMarginBottom}\n\t\t\t\t\t>\n\t\t\t\t\t\t{children}\n\t\t\t\t\t</BlogSectionStatic>\n\t\t\t\t}\n\t\t\t>\n\t\t\t\t<BlogSectionDynamic\n\t\t\t\t\tref={ref}\n\t\t\t\t\ttitle={title}\n\t\t\t\t\tcategory={category}\n\t\t\t\t\tincreaseMarginBottom={increaseMarginBottom}\n\t\t\t\t>\n\t\t\t\t\t{children}\n\t\t\t\t</BlogSectionDynamic>\n\t\t\t</Suspense>\n\t\t);\n\t}\n);\n\nBlogSection.displayName = 'BlogSection';\n\nexport default BlogSection;\n"],"names":["lazy","forwardRef","_jsx","Suspense","BlogSectionStatic"],"mappings":";;;;;;;;AAQA,MAAM,kBAAkB,GAAGA,UAAI,CAC9B,MAAM,oDAAO,4CAAyC,KAAC,CACvD;AASD,MAAM,WAAW,GAAGC,gBAAU,CAC7B,CACC,EACC,KAAK,GAAG,EAAE,EACV,QAAQ,GAAG,EAAE,EACb,QAAQ,GAAG,IAAI,EACf,oBAAoB,GAAG,KAAK,GAC5B,EACD,GAAG,KACA;IACH,QACCC,eAACC,cAAQ,EAAA,EACR,QAAQ,EACPD,cAAA,CAACE,yBAAiB,EAAA,EACjB,KAAK,EAAE,KAAK,EACZ,QAAQ,EAAE,QAAQ,EAClB,oBAAoB,EAAE,oBAAoB,EAAA,QAAA,EAEzC,QAAQ,EAAA,CACU,YAGrBF,cAAA,CAAC,kBAAkB,IAClB,GAAG,EAAE,GAAG,EACR,KAAK,EAAE,KAAK,EACZ,QAAQ,EAAE,QAAQ,EAClB,oBAAoB,EAAE,oBAAoB,YAEzC,QAAQ,EAAA,CACW,EAAA,CACX;AAEb,CAAC;AAGF,WAAW,CAAC,WAAW,GAAG,aAAa;;;;"}
|
|
@@ -3,11 +3,10 @@
|
|
|
3
3
|
Object.defineProperty(exports, '__esModule', { value: true });
|
|
4
4
|
|
|
5
5
|
var jsxRuntime = require('react/jsx-runtime');
|
|
6
|
-
var
|
|
6
|
+
var CalloutDynamic = require('../dynamicComponents/CalloutDynamic.js');
|
|
7
7
|
|
|
8
|
-
const Callout = ({ children, type = 'info', hasMarginUp = false, hasMarginDown = false }) => {
|
|
9
|
-
|
|
10
|
-
return (jsxRuntime.jsxs("div", { className: className, children: [jsxRuntime.jsx("div", { className: Callout_module.default.callout__icon }), jsxRuntime.jsx("div", { className: Callout_module.default.callout__wrapper, children: children })] }));
|
|
8
|
+
const Callout = ({ children, type = 'info', hasMarginUp = false, hasMarginDown = false, }) => {
|
|
9
|
+
return (jsxRuntime.jsx(CalloutDynamic.default, { type: type, hasMarginUp: hasMarginUp, hasMarginDown: hasMarginDown, children: children }));
|
|
11
10
|
};
|
|
12
11
|
|
|
13
12
|
exports.default = Callout;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Callout.js","sources":["../../../src/components/Callout.tsx"],"sourcesContent":["import type { ReactNode } from 'react';\
|
|
1
|
+
{"version":3,"file":"Callout.js","sources":["../../../src/components/Callout.tsx"],"sourcesContent":["import type { ReactNode } from 'react';\nimport CalloutDynamic from '../dynamicComponents/CalloutDynamic';\n\ninterface CalloutProperties {\n\tchildren?: ReactNode;\n\ttype: 'info' | 'warning' | 'error' | 'success';\n\thasMarginUp?: boolean;\n\thasMarginDown?: boolean;\n}\n\nconst Callout = ({\n\tchildren,\n\ttype = 'info',\n\thasMarginUp = false,\n\thasMarginDown = false,\n}: CalloutProperties) => {\n\treturn (\n\t\t<CalloutDynamic\n\t\t\ttype={type}\n\t\t\thasMarginUp={hasMarginUp}\n\t\t\thasMarginDown={hasMarginDown}\n\t\t>\n\t\t\t{children}\n\t\t</CalloutDynamic>\n\t);\n};\n\nexport default Callout;\n"],"names":["_jsx","CalloutDynamic"],"mappings":";;;;;;;AAUA,MAAM,OAAO,GAAG,CAAC,EAChB,QAAQ,EACR,IAAI,GAAG,MAAM,EACb,WAAW,GAAG,KAAK,EACnB,aAAa,GAAG,KAAK,GACF,KAAI;AACvB,IAAA,QACCA,cAAA,CAACC,sBAAc,IACd,IAAI,EAAE,IAAI,EACV,WAAW,EAAE,WAAW,EACxB,aAAa,EAAE,aAAa,YAE3B,QAAQ,EAAA,CACO;AAEnB;;;;"}
|
|
@@ -5,33 +5,11 @@ Object.defineProperty(exports, '__esModule', { value: true });
|
|
|
5
5
|
|
|
6
6
|
var jsxRuntime = require('react/jsx-runtime');
|
|
7
7
|
var react = require('react');
|
|
8
|
-
var
|
|
9
|
-
var prism = require('react-syntax-highlighter/dist/esm/styles/prism');
|
|
10
|
-
require('prismjs/themes/prism-tomorrow.css');
|
|
11
|
-
var CodeBlock_module = require('../styles/CodeBlock.module.scss.js');
|
|
8
|
+
var CodeBlockStatic = require('../staticComponents/CodeBlockStatic.js');
|
|
12
9
|
|
|
13
|
-
const
|
|
10
|
+
const CodeBlockDynamic = react.lazy(() => Promise.resolve().then(function () { return require('../dynamicComponents/CodeBlockDynamic.js'); }));
|
|
14
11
|
const CodeBlock = ({ language = 'javascript', code = '', hasMarginUp = false, hasMarginDown = false, }) => {
|
|
15
|
-
|
|
16
|
-
const copyToClipboard = async () => {
|
|
17
|
-
try {
|
|
18
|
-
await navigator.clipboard.writeText(code);
|
|
19
|
-
setCopyMode(true);
|
|
20
|
-
setTimeout(() => {
|
|
21
|
-
setCopyMode(false);
|
|
22
|
-
}, 1000);
|
|
23
|
-
}
|
|
24
|
-
catch (error) {
|
|
25
|
-
console.error('Failed to copy:', error);
|
|
26
|
-
}
|
|
27
|
-
};
|
|
28
|
-
const lineNumberStyle = {
|
|
29
|
-
color: '#95a1b1',
|
|
30
|
-
fontSize: '0.9em',
|
|
31
|
-
paddingRight: '1em',
|
|
32
|
-
marginRight: '8px',
|
|
33
|
-
};
|
|
34
|
-
return (jsxRuntime.jsxs("div", { className: `${CodeBlock_module.default['code-block']} ${hasMarginUp ? CodeBlock_module.default['margin-top--1'] : ''} ${hasMarginDown ? CodeBlock_module.default['margin-bottom--2'] : ''}`, children: [jsxRuntime.jsxs("div", { className: CodeBlock_module.default['code-block__header'], children: [jsxRuntime.jsx("div", { className: CodeBlock_module.default['code-block__header__title'], children: language }), jsxRuntime.jsx("div", { className: `${CodeBlock_module.default['code-block__header__copy']} ${isCopyMode ? CodeBlock_module.default['code-block__header__copy--active'] : ''}`, onClick: copyToClipboard })] }), jsxRuntime.jsx("div", { className: CodeBlock_module.default['code-block__wrapper'], children: jsxRuntime.jsx(SH, { language: language, style: prism.dracula, showLineNumbers: true, lineNumberStyle: lineNumberStyle, children: code }) })] }));
|
|
12
|
+
return (jsxRuntime.jsx(react.Suspense, { fallback: jsxRuntime.jsx(CodeBlockStatic.default, { language: language, code: code, hasMarginUp: hasMarginUp, hasMarginDown: hasMarginDown }), children: jsxRuntime.jsx(CodeBlockDynamic, { language: language, code: code, hasMarginUp: hasMarginUp, hasMarginDown: hasMarginDown }) }));
|
|
35
13
|
};
|
|
36
14
|
|
|
37
15
|
exports.default = CodeBlock;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"CodeBlock.js","sources":["../../../src/components/CodeBlock.tsx"],"sourcesContent":["'use client';\n\nimport {
|
|
1
|
+
{"version":3,"file":"CodeBlock.js","sources":["../../../src/components/CodeBlock.tsx"],"sourcesContent":["'use client';\n\nimport { lazy, Suspense } from 'react';\nimport CodeBlockStatic from '../staticComponents/CodeBlockStatic';\n\nconst CodeBlockDynamic = lazy(\n\t() => import('../dynamicComponents/CodeBlockDynamic')\n);\n\ninterface CodeBlockProperties {\n\thasMarginUp?: boolean;\n\thasMarginDown?: boolean;\n\tlanguage?: string;\n\tcode?: string;\n}\n\nconst CodeBlock = ({\n\tlanguage = 'javascript',\n\tcode = '',\n\thasMarginUp = false,\n\thasMarginDown = false,\n}: CodeBlockProperties) => {\n\treturn (\n\t\t<Suspense\n\t\t\tfallback={\n\t\t\t\t<CodeBlockStatic\n\t\t\t\t\tlanguage={language}\n\t\t\t\t\tcode={code}\n\t\t\t\t\thasMarginUp={hasMarginUp}\n\t\t\t\t\thasMarginDown={hasMarginDown}\n\t\t\t\t/>\n\t\t\t}\n\t\t>\n\t\t\t<CodeBlockDynamic\n\t\t\t\tlanguage={language}\n\t\t\t\tcode={code}\n\t\t\t\thasMarginUp={hasMarginUp}\n\t\t\t\thasMarginDown={hasMarginDown}\n\t\t\t/>\n\t\t</Suspense>\n\t);\n};\n\nexport default CodeBlock;\n"],"names":["lazy","_jsx","Suspense","CodeBlockStatic"],"mappings":";;;;;;;;AAKA,MAAM,gBAAgB,GAAGA,UAAI,CAC5B,MAAM,oDAAO,0CAAuC,KAAC,CACrD;AASD,MAAM,SAAS,GAAG,CAAC,EAClB,QAAQ,GAAG,YAAY,EACvB,IAAI,GAAG,EAAE,EACT,WAAW,GAAG,KAAK,EACnB,aAAa,GAAG,KAAK,GACA,KAAI;IACzB,QACCC,eAACC,cAAQ,EAAA,EACR,QAAQ,EACPD,cAAA,CAACE,uBAAe,EAAA,EACf,QAAQ,EAAE,QAAQ,EAClB,IAAI,EAAE,IAAI,EACV,WAAW,EAAE,WAAW,EACxB,aAAa,EAAE,aAAa,EAAA,CAC3B,EAAA,QAAA,EAGHF,eAAC,gBAAgB,EAAA,EAChB,QAAQ,EAAE,QAAQ,EAClB,IAAI,EAAE,IAAI,EACV,WAAW,EAAE,WAAW,EACxB,aAAa,EAAE,aAAa,EAAA,CAC3B,EAAA,CACQ;AAEb;;;;"}
|
|
@@ -5,54 +5,11 @@ Object.defineProperty(exports, '__esModule', { value: true });
|
|
|
5
5
|
|
|
6
6
|
var jsxRuntime = require('react/jsx-runtime');
|
|
7
7
|
var react = require('react');
|
|
8
|
-
var
|
|
9
|
-
var Mermaid_module = require('../styles/Mermaid.module.scss.js');
|
|
8
|
+
var MermaidStatic = require('../staticComponents/MermaidStatic.js');
|
|
10
9
|
|
|
11
|
-
|
|
12
|
-
startOnLoad: false,
|
|
13
|
-
theme: 'default',
|
|
14
|
-
timeline: {
|
|
15
|
-
useMaxWidth: true,
|
|
16
|
-
diagramMarginX: 0,
|
|
17
|
-
},
|
|
18
|
-
flowchart: {
|
|
19
|
-
useMaxWidth: true,
|
|
20
|
-
diagramPadding: 0,
|
|
21
|
-
},
|
|
22
|
-
sequence: {
|
|
23
|
-
useMaxWidth: true,
|
|
24
|
-
diagramMarginX: 0,
|
|
25
|
-
},
|
|
26
|
-
});
|
|
10
|
+
const MermaidDynamic = react.lazy(() => Promise.resolve().then(function () { return require('../dynamicComponents/MermaidDynamic.js'); }));
|
|
27
11
|
const Mermaid = ({ code = '', id = '', hasMarginUp = false, hasMarginDown = false, }) => {
|
|
28
|
-
|
|
29
|
-
const mermaidReference = react.useRef(null);
|
|
30
|
-
const initializeMermaid = react.useCallback(async () => {
|
|
31
|
-
try {
|
|
32
|
-
if (!mermaidReference.current || !code)
|
|
33
|
-
return;
|
|
34
|
-
const { svg, bindFunctions } = await mermaid.render(`mermaid-diagram-${id}`, code);
|
|
35
|
-
if (!svg)
|
|
36
|
-
return;
|
|
37
|
-
mermaidReference.current.innerHTML = svg || '';
|
|
38
|
-
bindFunctions?.(mermaidReference.current);
|
|
39
|
-
setEnabled(true);
|
|
40
|
-
}
|
|
41
|
-
catch (error) {
|
|
42
|
-
console.error('Failed to render Mermaid diagram:', error);
|
|
43
|
-
}
|
|
44
|
-
}, [code, id]);
|
|
45
|
-
react.useEffect(() => {
|
|
46
|
-
if (!code || !mermaidReference.current)
|
|
47
|
-
return;
|
|
48
|
-
const timer = setTimeout(async () => {
|
|
49
|
-
await initializeMermaid();
|
|
50
|
-
}, 100);
|
|
51
|
-
return () => clearTimeout(timer);
|
|
52
|
-
}, [code, initializeMermaid]);
|
|
53
|
-
return (jsxRuntime.jsxs("div", { className: `${Mermaid_module.default.mermaid}
|
|
54
|
-
${hasMarginUp ? Mermaid_module.default['margin-top--1'] : ''}
|
|
55
|
-
${hasMarginDown ? Mermaid_module.default['margin-bottom--2'] : ''}`, children: [enabled ? null : jsxRuntime.jsx("p", { children: "Diagram Loading..." }), jsxRuntime.jsx("div", { ref: mermaidReference, id: id })] }));
|
|
12
|
+
return (jsxRuntime.jsx(react.Suspense, { fallback: jsxRuntime.jsx(MermaidStatic.default, { code: code, id: id, hasMarginUp: hasMarginUp, hasMarginDown: hasMarginDown }), children: jsxRuntime.jsx(MermaidDynamic, { code: code, id: id, hasMarginUp: hasMarginUp, hasMarginDown: hasMarginDown }) }));
|
|
56
13
|
};
|
|
57
14
|
|
|
58
15
|
exports.default = Mermaid;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Mermaid.js","sources":["../../../src/components/Mermaid.tsx"],"sourcesContent":["'use client';\n\nimport {
|
|
1
|
+
{"version":3,"file":"Mermaid.js","sources":["../../../src/components/Mermaid.tsx"],"sourcesContent":["'use client';\n\nimport { lazy, Suspense } from 'react';\nimport MermaidStatic from '../staticComponents/MermaidStatic';\n\nconst MermaidDynamic = lazy(\n\t() => import('../dynamicComponents/MermaidDynamic')\n);\n\ninterface MermaidProperties {\n\tcode: string;\n\tid: string;\n\thasMarginUp?: boolean;\n\thasMarginDown?: boolean;\n}\n\nconst Mermaid = ({\n\tcode = '',\n\tid = '',\n\thasMarginUp = false,\n\thasMarginDown = false,\n}: MermaidProperties) => {\n\treturn (\n\t\t<Suspense\n\t\t\tfallback={\n\t\t\t\t<MermaidStatic\n\t\t\t\t\tcode={code}\n\t\t\t\t\tid={id}\n\t\t\t\t\thasMarginUp={hasMarginUp}\n\t\t\t\t\thasMarginDown={hasMarginDown}\n\t\t\t\t/>\n\t\t\t}\n\t\t>\n\t\t\t<MermaidDynamic\n\t\t\t\tcode={code}\n\t\t\t\tid={id}\n\t\t\t\thasMarginUp={hasMarginUp}\n\t\t\t\thasMarginDown={hasMarginDown}\n\t\t\t/>\n\t\t</Suspense>\n\t);\n};\n\nexport default Mermaid;\n"],"names":["lazy","_jsx","Suspense","MermaidStatic"],"mappings":";;;;;;;;AAKA,MAAM,cAAc,GAAGA,UAAI,CAC1B,MAAM,oDAAO,wCAAqC,KAAC,CACnD;AASD,MAAM,OAAO,GAAG,CAAC,EAChB,IAAI,GAAG,EAAE,EACT,EAAE,GAAG,EAAE,EACP,WAAW,GAAG,KAAK,EACnB,aAAa,GAAG,KAAK,GACF,KAAI;IACvB,QACCC,eAACC,cAAQ,EAAA,EACR,QAAQ,EACPD,cAAA,CAACE,qBAAa,EAAA,EACb,IAAI,EAAE,IAAI,EACV,EAAE,EAAE,EAAE,EACN,WAAW,EAAE,WAAW,EACxB,aAAa,EAAE,aAAa,EAAA,CAC3B,EAAA,QAAA,EAGHF,eAAC,cAAc,EAAA,EACd,IAAI,EAAE,IAAI,EACV,EAAE,EAAE,EAAE,EACN,WAAW,EAAE,WAAW,EACxB,aAAa,EAAE,aAAa,EAAA,CAC3B,EAAA,CACQ;AAEb;;;;"}
|