@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.
Files changed (86) hide show
  1. package/dist/cjs/components/Blog.js +2 -2
  2. package/dist/cjs/components/Blog.js.map +1 -1
  3. package/dist/cjs/components/MermaidViewport.js.map +1 -1
  4. package/dist/cjs/dynamicComponents/BlogDynamic.js +2 -2
  5. package/dist/cjs/dynamicComponents/BlogDynamic.js.map +1 -1
  6. package/dist/cjs/hooks/useCategoryTitles.js +8 -14
  7. package/dist/cjs/hooks/useCategoryTitles.js.map +1 -1
  8. package/dist/cjs/index.css +1 -1
  9. package/dist/cjs/index.css.map +1 -1
  10. package/dist/cjs/staticComponents/BlogStatic.js +2 -2
  11. package/dist/cjs/staticComponents/BlogStatic.js.map +1 -1
  12. package/dist/cjs/staticComponents/TocNodeStatic.js +1 -1
  13. package/dist/cjs/staticComponents/TocNodeStatic.js.map +1 -1
  14. package/dist/cjs/styles/Blog.module.scss.js +1 -1
  15. package/dist/esm/components/Blog.js +2 -2
  16. package/dist/esm/components/Blog.js.map +1 -1
  17. package/dist/esm/components/MermaidViewport.js.map +1 -1
  18. package/dist/esm/dynamicComponents/BlogDynamic.js +2 -2
  19. package/dist/esm/dynamicComponents/BlogDynamic.js.map +1 -1
  20. package/dist/esm/hooks/useCategoryTitles.js +8 -14
  21. package/dist/esm/hooks/useCategoryTitles.js.map +1 -1
  22. package/dist/esm/index.css +1 -1
  23. package/dist/esm/index.css.map +1 -1
  24. package/dist/esm/staticComponents/BlogStatic.js +2 -2
  25. package/dist/esm/staticComponents/BlogStatic.js.map +1 -1
  26. package/dist/esm/staticComponents/TocNodeStatic.js +1 -1
  27. package/dist/esm/staticComponents/TocNodeStatic.js.map +1 -1
  28. package/dist/esm/styles/Blog.module.scss.js +1 -1
  29. package/dist/types/components/Blog.d.ts +2 -1
  30. package/dist/types/components/Blog.d.ts.map +1 -1
  31. package/dist/types/components/BlogHeader.d.ts +1 -1
  32. package/dist/types/components/BlogHeader.d.ts.map +1 -1
  33. package/dist/types/components/BlogLink.d.ts +1 -1
  34. package/dist/types/components/BlogLink.d.ts.map +1 -1
  35. package/dist/types/components/Callout.d.ts +1 -1
  36. package/dist/types/components/Callout.d.ts.map +1 -1
  37. package/dist/types/components/CheckList.d.ts +1 -1
  38. package/dist/types/components/CheckList.d.ts.map +1 -1
  39. package/dist/types/components/CodeBlock.d.ts +1 -1
  40. package/dist/types/components/CodeBlock.d.ts.map +1 -1
  41. package/dist/types/components/Mermaid.d.ts +1 -1
  42. package/dist/types/components/Mermaid.d.ts.map +1 -1
  43. package/dist/types/components/MermaidControls.d.ts +1 -1
  44. package/dist/types/components/MermaidControls.d.ts.map +1 -1
  45. package/dist/types/components/MermaidViewport.d.ts +2 -2
  46. package/dist/types/components/MermaidViewport.d.ts.map +1 -1
  47. package/dist/types/components/Table.d.ts +1 -1
  48. package/dist/types/components/Table.d.ts.map +1 -1
  49. package/dist/types/dynamicComponents/BlogDynamic.d.ts +2 -1
  50. package/dist/types/dynamicComponents/BlogDynamic.d.ts.map +1 -1
  51. package/dist/types/dynamicComponents/BlogLinkDynamic.d.ts +1 -1
  52. package/dist/types/dynamicComponents/BlogLinkDynamic.d.ts.map +1 -1
  53. package/dist/types/dynamicComponents/CodeBlockDynamic.d.ts +1 -1
  54. package/dist/types/dynamicComponents/CodeBlockDynamic.d.ts.map +1 -1
  55. package/dist/types/dynamicComponents/MermaidDynamic.d.ts +1 -1
  56. package/dist/types/dynamicComponents/MermaidDynamic.d.ts.map +1 -1
  57. package/dist/types/hooks/useCategoryTitles.d.ts.map +1 -1
  58. package/dist/types/staticComponents/BlogHeaderStatic.d.ts +1 -1
  59. package/dist/types/staticComponents/BlogHeaderStatic.d.ts.map +1 -1
  60. package/dist/types/staticComponents/BlogLinkStatic.d.ts +1 -1
  61. package/dist/types/staticComponents/BlogLinkStatic.d.ts.map +1 -1
  62. package/dist/types/staticComponents/BlogSectionStatic.d.ts +1 -1
  63. package/dist/types/staticComponents/BlogSectionStatic.d.ts.map +1 -1
  64. package/dist/types/staticComponents/BlogStatic.d.ts +2 -1
  65. package/dist/types/staticComponents/BlogStatic.d.ts.map +1 -1
  66. package/dist/types/staticComponents/CalloutStatic.d.ts +1 -1
  67. package/dist/types/staticComponents/CalloutStatic.d.ts.map +1 -1
  68. package/dist/types/staticComponents/CheckListStatic.d.ts +1 -1
  69. package/dist/types/staticComponents/CheckListStatic.d.ts.map +1 -1
  70. package/dist/types/staticComponents/CodeBlockStatic.d.ts +1 -1
  71. package/dist/types/staticComponents/CodeBlockStatic.d.ts.map +1 -1
  72. package/dist/types/staticComponents/MermaidStatic.d.ts +1 -1
  73. package/dist/types/staticComponents/MermaidStatic.d.ts.map +1 -1
  74. package/dist/types/staticComponents/TableStatic.d.ts +1 -1
  75. package/dist/types/staticComponents/TableStatic.d.ts.map +1 -1
  76. package/dist/types/staticComponents/TocNodeStatic.d.ts +1 -1
  77. package/dist/types/staticComponents/TocNodeStatic.d.ts.map +1 -1
  78. package/package.json +4 -4
  79. package/src/components/Blog.tsx +4 -3
  80. package/src/components/MermaidViewport.tsx +1 -1
  81. package/src/dynamicComponents/BlogDynamic.tsx +3 -1
  82. package/src/hooks/useCategoryTitles.ts +16 -18
  83. package/src/staticComponents/BlogStatic.tsx +4 -2
  84. package/src/staticComponents/TocNodeStatic.tsx +1 -1
  85. package/src/styles/Blog.module.scss +22 -4
  86. 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
- type SectionReference = Map<string, SectionReferenceValue>;
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]: [string, SectionReferenceValue],
43
- [, b]: [string, SectionReferenceValue]
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
- for (const [id, { title, el, depth }] of sectionsArray) {
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 id = ref.dataset.id;
104
+ const baseId = ref.dataset.id;
106
105
  const title = ref.dataset.title;
107
- if (!id || !title) return;
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
- removeStaleRefs(ref);
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"
@@ -37,7 +37,7 @@ const TocNode = ({ node, index, visibleTitle, onClick }: TocNodeProperties) => (
37
37
  >
38
38
  {node.children.map((child, i) => (
39
39
  <TocNode
40
- key={child.id}
40
+ key={`${node.id}-${child.id}`}
41
41
  node={child}
42
42
  index={i}
43
43
  visibleTitle={visibleTitle}
@@ -1,10 +1,18 @@
1
- @use '@san-siva/stylekit/styles/index.module.scss' as 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: 100%;
12
+ max-width: $total-width;
13
+ margin: 0 auto;
6
14
  display: grid;
7
- grid-template-columns: #{styles.rem(780)} minmax(#{styles.rem(320)}, 1fr);
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
- #{styles.rem(320)} + #{styles.rem(120)}
48
+ #{$sidebar-width} + #{styles.rem(120)}
31
49
  );
32
50
 
33
51
  @media (max-width: $breakpoint) {
@@ -1,5 +1,6 @@
1
1
  declare const styles: {
2
2
  readonly blog: string;
3
+ readonly 'blog--increased-width': string;
3
4
  readonly 'blog__content': string;
4
5
  readonly 'blog__sidebar': string;
5
6
  readonly 'margin-bottom--3': string;