@san-siva/blogkit 1.1.41 → 1.1.43
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 +2 -2
- package/dist/cjs/components/Blog.js.map +1 -1
- package/dist/cjs/components/MermaidViewport.js.map +1 -1
- package/dist/cjs/dynamicComponents/BlogDynamic.js +2 -2
- package/dist/cjs/dynamicComponents/BlogDynamic.js.map +1 -1
- package/dist/cjs/hooks/useCategoryTitles.js +8 -14
- package/dist/cjs/hooks/useCategoryTitles.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/staticComponents/TocNodeStatic.js +1 -1
- package/dist/cjs/staticComponents/TocNodeStatic.js.map +1 -1
- package/dist/cjs/styles/Blog.module.scss.js +1 -1
- package/dist/esm/components/Blog.js +2 -2
- package/dist/esm/components/Blog.js.map +1 -1
- package/dist/esm/components/MermaidViewport.js.map +1 -1
- package/dist/esm/dynamicComponents/BlogDynamic.js +2 -2
- package/dist/esm/dynamicComponents/BlogDynamic.js.map +1 -1
- package/dist/esm/hooks/useCategoryTitles.js +8 -14
- package/dist/esm/hooks/useCategoryTitles.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/staticComponents/TocNodeStatic.js +1 -1
- package/dist/esm/staticComponents/TocNodeStatic.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/BlogHeader.d.ts +1 -1
- package/dist/types/components/BlogHeader.d.ts.map +1 -1
- package/dist/types/components/BlogLink.d.ts +1 -1
- package/dist/types/components/BlogLink.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/CheckList.d.ts +1 -1
- package/dist/types/components/CheckList.d.ts.map +1 -1
- package/dist/types/components/CodeBlock.d.ts +1 -1
- package/dist/types/components/CodeBlock.d.ts.map +1 -1
- package/dist/types/components/Mermaid.d.ts +1 -1
- package/dist/types/components/Mermaid.d.ts.map +1 -1
- package/dist/types/components/MermaidControls.d.ts +1 -1
- package/dist/types/components/MermaidControls.d.ts.map +1 -1
- package/dist/types/components/MermaidViewport.d.ts +2 -2
- package/dist/types/components/MermaidViewport.d.ts.map +1 -1
- package/dist/types/components/Table.d.ts +1 -1
- package/dist/types/components/Table.d.ts.map +1 -1
- package/dist/types/dynamicComponents/BlogDynamic.d.ts +2 -1
- package/dist/types/dynamicComponents/BlogDynamic.d.ts.map +1 -1
- package/dist/types/dynamicComponents/BlogLinkDynamic.d.ts +1 -1
- package/dist/types/dynamicComponents/BlogLinkDynamic.d.ts.map +1 -1
- package/dist/types/dynamicComponents/CodeBlockDynamic.d.ts +1 -1
- package/dist/types/dynamicComponents/CodeBlockDynamic.d.ts.map +1 -1
- package/dist/types/dynamicComponents/MermaidDynamic.d.ts +1 -1
- package/dist/types/dynamicComponents/MermaidDynamic.d.ts.map +1 -1
- package/dist/types/hooks/useCategoryTitles.d.ts.map +1 -1
- package/dist/types/staticComponents/BlogHeaderStatic.d.ts +1 -1
- package/dist/types/staticComponents/BlogHeaderStatic.d.ts.map +1 -1
- package/dist/types/staticComponents/BlogLinkStatic.d.ts +1 -1
- package/dist/types/staticComponents/BlogLinkStatic.d.ts.map +1 -1
- package/dist/types/staticComponents/BlogSectionStatic.d.ts +1 -1
- package/dist/types/staticComponents/BlogSectionStatic.d.ts.map +1 -1
- package/dist/types/staticComponents/BlogStatic.d.ts +2 -1
- package/dist/types/staticComponents/BlogStatic.d.ts.map +1 -1
- package/dist/types/staticComponents/CalloutStatic.d.ts +1 -1
- package/dist/types/staticComponents/CalloutStatic.d.ts.map +1 -1
- package/dist/types/staticComponents/CheckListStatic.d.ts +1 -1
- package/dist/types/staticComponents/CheckListStatic.d.ts.map +1 -1
- package/dist/types/staticComponents/CodeBlockStatic.d.ts +1 -1
- package/dist/types/staticComponents/CodeBlockStatic.d.ts.map +1 -1
- package/dist/types/staticComponents/MermaidStatic.d.ts +1 -1
- package/dist/types/staticComponents/MermaidStatic.d.ts.map +1 -1
- package/dist/types/staticComponents/TableStatic.d.ts +1 -1
- package/dist/types/staticComponents/TableStatic.d.ts.map +1 -1
- package/dist/types/staticComponents/TocNodeStatic.d.ts +1 -1
- package/dist/types/staticComponents/TocNodeStatic.d.ts.map +1 -1
- package/package.json +4 -4
- package/src/components/Blog.tsx +4 -3
- package/src/components/MermaidViewport.tsx +1 -1
- package/src/dynamicComponents/BlogDynamic.tsx +3 -1
- package/src/hooks/useCategoryTitles.ts +16 -18
- package/src/staticComponents/BlogStatic.tsx +4 -2
- package/src/staticComponents/TocNodeStatic.tsx +1 -1
- package/src/styles/Blog.module.scss +22 -4
- package/src/styles/Blog.module.scss.d.ts +1 -0
|
@@ -18,7 +18,11 @@ export interface CategoryTitleValue extends SectionReferenceValue {
|
|
|
18
18
|
|
|
19
19
|
export type CategoryTitle = Map<string, CategoryTitleValue>;
|
|
20
20
|
|
|
21
|
-
|
|
21
|
+
interface SectionReferenceEntry extends SectionReferenceValue {
|
|
22
|
+
baseId: string;
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
type SectionReference = Map<HTMLElement, SectionReferenceEntry>;
|
|
22
26
|
|
|
23
27
|
interface Options {
|
|
24
28
|
visibleTitle: string | null;
|
|
@@ -39,8 +43,8 @@ export function useCategoryTitles({
|
|
|
39
43
|
|
|
40
44
|
const sortByDomPosition = useCallback(
|
|
41
45
|
(
|
|
42
|
-
[, a]: [
|
|
43
|
-
[, b]: [
|
|
46
|
+
[, a]: [HTMLElement, SectionReferenceEntry],
|
|
47
|
+
[, b]: [HTMLElement, SectionReferenceEntry]
|
|
44
48
|
) => {
|
|
45
49
|
const position = a.el.compareDocumentPosition(b.el);
|
|
46
50
|
if (position & Node.DOCUMENT_POSITION_FOLLOWING) {
|
|
@@ -61,7 +65,12 @@ export function useCategoryTitles({
|
|
|
61
65
|
sectionsArray.sort(sortByDomPosition);
|
|
62
66
|
|
|
63
67
|
let firstSectionId: string | null = null;
|
|
64
|
-
|
|
68
|
+
const baseIdCounts = new Map<string, number>();
|
|
69
|
+
for (const [, { title, el, depth, baseId }] of sectionsArray) {
|
|
70
|
+
const occurrence = (baseIdCounts.get(baseId) ?? 0) + 1;
|
|
71
|
+
baseIdCounts.set(baseId, occurrence);
|
|
72
|
+
const id = occurrence === 1 ? baseId : `${baseId}-${occurrence}`;
|
|
73
|
+
|
|
65
74
|
if (!firstSectionId) {
|
|
66
75
|
firstSectionId = id;
|
|
67
76
|
}
|
|
@@ -91,20 +100,10 @@ export function useCategoryTitles({
|
|
|
91
100
|
}, 200);
|
|
92
101
|
}, [updateCategoryTitles]);
|
|
93
102
|
|
|
94
|
-
const removeStaleRefs = (ref: HTMLDivElement) => {
|
|
95
|
-
for (const [existingId, { el }] of sectionReferences.current) {
|
|
96
|
-
if (el !== ref) {
|
|
97
|
-
continue;
|
|
98
|
-
}
|
|
99
|
-
sectionReferences.current.delete(existingId);
|
|
100
|
-
break;
|
|
101
|
-
}
|
|
102
|
-
};
|
|
103
|
-
|
|
104
103
|
const handleCategoryTitle = (ref: HTMLDivElement) => {
|
|
105
|
-
const
|
|
104
|
+
const baseId = ref.dataset.id;
|
|
106
105
|
const title = ref.dataset.title;
|
|
107
|
-
if (!
|
|
106
|
+
if (!baseId || !title) return;
|
|
108
107
|
|
|
109
108
|
let depth = 0;
|
|
110
109
|
let parent = ref.parentElement;
|
|
@@ -113,8 +112,7 @@ export function useCategoryTitles({
|
|
|
113
112
|
parent = parent.parentElement;
|
|
114
113
|
}
|
|
115
114
|
|
|
116
|
-
|
|
117
|
-
sectionReferences.current.set(id, { el: ref, title, depth });
|
|
115
|
+
sectionReferences.current.set(ref, { el: ref, title, depth, baseId });
|
|
118
116
|
};
|
|
119
117
|
|
|
120
118
|
const processSection = (element: ForwardedReference) => {
|
|
@@ -5,11 +5,13 @@ import styles from '../styles/Blog.module.scss';
|
|
|
5
5
|
interface BlogStaticProperties {
|
|
6
6
|
children: ReactNode;
|
|
7
7
|
jsonLd?: WithContext<Thing>;
|
|
8
|
+
increasedWidthMode?: boolean;
|
|
8
9
|
}
|
|
9
10
|
|
|
10
|
-
const BlogStatic = ({ children, jsonLd }: BlogStaticProperties) => {
|
|
11
|
+
const BlogStatic = ({ children, jsonLd, increasedWidthMode = false }: BlogStaticProperties) => {
|
|
11
12
|
return (
|
|
12
|
-
<div className={styles.blog}>
|
|
13
|
+
<div className={`${styles.blog} ${increasedWidthMode ? styles['blog--increased-width'] : ''}`}>
|
|
14
|
+
|
|
13
15
|
{jsonLd && (
|
|
14
16
|
<script
|
|
15
17
|
type="application/ld+json"
|
|
@@ -1,10 +1,18 @@
|
|
|
1
|
-
@use '@san-siva/stylekit/styles/
|
|
1
|
+
@use '@san-siva/stylekit/styles/utils.module.scss' as utils;
|
|
2
|
+
@use '@san-siva/stylekit/styles/index.module.scss' as styles with (
|
|
3
|
+
$max-width--page-contents: utils.rem(1200)
|
|
4
|
+
);
|
|
5
|
+
|
|
6
|
+
$sidebar-width: 22rem;
|
|
7
|
+
$content-width: styles.rem(780);
|
|
8
|
+
$total-width: calc(#{$content-width} + #{styles.space(8)} + #{$sidebar-width});
|
|
2
9
|
|
|
3
10
|
.blog {
|
|
4
11
|
width: 100%;
|
|
5
|
-
max-width:
|
|
12
|
+
max-width: $total-width;
|
|
13
|
+
margin: 0 auto;
|
|
6
14
|
display: grid;
|
|
7
|
-
grid-template-columns:
|
|
15
|
+
grid-template-columns: $content-width $sidebar-width;
|
|
8
16
|
grid-gap: styles.space(8);
|
|
9
17
|
|
|
10
18
|
&__content {
|
|
@@ -23,11 +31,21 @@
|
|
|
23
31
|
padding-right: 0;
|
|
24
32
|
border-radius: styles.$border-radius--1;
|
|
25
33
|
}
|
|
34
|
+
|
|
35
|
+
&--increased-width {
|
|
36
|
+
max-width: 100%;
|
|
37
|
+
grid-template-columns: minmax(0, 1fr) $sidebar-width;
|
|
38
|
+
|
|
39
|
+
.blog__content {
|
|
40
|
+
max-width: none;
|
|
41
|
+
min-width: 0;
|
|
42
|
+
}
|
|
43
|
+
}
|
|
26
44
|
}
|
|
27
45
|
|
|
28
46
|
$breakpoint: calc(
|
|
29
47
|
#{styles.rem(120)} + #{styles.rem(780)} + #{styles.space(8)} +
|
|
30
|
-
#{
|
|
48
|
+
#{$sidebar-width} + #{styles.rem(120)}
|
|
31
49
|
);
|
|
32
50
|
|
|
33
51
|
@media (max-width: $breakpoint) {
|