@san-siva/blogkit 1.1.14 → 1.1.16
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 +1 -1
- package/dist/cjs/components/Blog.js +2 -2
- package/dist/cjs/components/Blog.js.map +1 -1
- package/dist/cjs/dynamicComponents/BlogDynamic.js +33 -6
- package/dist/cjs/dynamicComponents/BlogDynamic.js.map +1 -1
- package/dist/cjs/dynamicComponents/BlogSectionDynamic.js +1 -1
- package/dist/cjs/dynamicComponents/BlogSectionDynamic.js.map +1 -1
- package/dist/cjs/dynamicComponents/lockScrollUpdates.js +24 -0
- package/dist/cjs/dynamicComponents/lockScrollUpdates.js.map +1 -0
- 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/BlogSection.module.scss.js +1 -1
- package/dist/cjs/styles/Callout.module.scss.js +1 -1
- package/dist/cjs/utils/index.js +2 -0
- package/dist/cjs/utils/index.js.map +1 -1
- package/dist/cjs/utils/lockScrollUpdates.js +24 -0
- package/dist/cjs/utils/lockScrollUpdates.js.map +1 -0
- package/dist/esm/components/Blog.js +2 -2
- package/dist/esm/components/Blog.js.map +1 -1
- package/dist/esm/dynamicComponents/BlogDynamic.js +33 -6
- package/dist/esm/dynamicComponents/BlogDynamic.js.map +1 -1
- package/dist/esm/dynamicComponents/BlogSectionDynamic.js +2 -2
- package/dist/esm/dynamicComponents/BlogSectionDynamic.js.map +1 -1
- package/dist/esm/dynamicComponents/lockScrollUpdates.js +20 -0
- package/dist/esm/dynamicComponents/lockScrollUpdates.js.map +1 -0
- package/dist/esm/index.css +1 -1
- package/dist/esm/index.css.map +1 -1
- package/dist/esm/staticComponents/BlogStatic.js +3 -3
- package/dist/esm/staticComponents/BlogStatic.js.map +1 -1
- package/dist/esm/styles/BlogSection.module.scss.js +1 -1
- package/dist/esm/styles/Callout.module.scss.js +1 -1
- package/dist/esm/utils/index.js +2 -1
- package/dist/esm/utils/index.js.map +1 -1
- package/dist/esm/utils/lockScrollUpdates.js +20 -0
- package/dist/esm/utils/lockScrollUpdates.js.map +1 -0
- package/dist/types/components/Blog.d.ts +3 -1
- package/dist/types/components/Blog.d.ts.map +1 -1
- package/dist/types/dynamicComponents/BlogDynamic.d.ts +3 -1
- package/dist/types/dynamicComponents/BlogDynamic.d.ts.map +1 -1
- package/dist/types/dynamicComponents/lockScrollUpdates.d.ts +4 -0
- package/dist/types/dynamicComponents/lockScrollUpdates.d.ts.map +1 -0
- package/dist/types/staticComponents/BlogStatic.d.ts +3 -1
- package/dist/types/staticComponents/BlogStatic.d.ts.map +1 -1
- package/package.json +3 -2
- package/src/components/Blog.tsx +5 -3
- package/src/dynamicComponents/BlogDynamic.tsx +43 -5
- package/src/dynamicComponents/BlogSectionDynamic.tsx +6 -2
- package/src/staticComponents/BlogStatic.tsx +9 -1
- package/src/styles/BlogSection.module.scss +16 -2
- package/src/utils/index.ts +2 -0
- package/src/utils/lockScrollUpdates.ts +29 -0
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
import { jsx } from 'react/jsx-runtime';
|
|
1
|
+
import { jsxs, jsx } from 'react/jsx-runtime';
|
|
2
2
|
import styles from '../styles/Blog.module.scss.js';
|
|
3
3
|
|
|
4
|
-
const BlogStatic = ({ children }) => {
|
|
5
|
-
return (
|
|
4
|
+
const BlogStatic = ({ children, jsonLd }) => {
|
|
5
|
+
return (jsxs("div", { className: styles.blog, 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 styles from '../styles/Blog.module.scss';\n\ninterface BlogStaticProperties {\n\tchildren: ReactNode;\n}\n\nconst BlogStatic = ({ children }: BlogStaticProperties) => {\n\treturn (\n\t\t<div className={styles.blog}>\n\t\t\t<div className={styles['blog__content']}>{children}</div>\n\t\t</div>\n\t);\n};\n\nexport default BlogStatic;\n"],"names":["_jsx"],"mappings":";;;
|
|
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}\n\nconst BlogStatic = ({ children, jsonLd }: BlogStaticProperties) => {\n\treturn (\n\t\t<div className={styles.blog}>\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":";;;AASA,MAAM,UAAU,GAAG,CAAC,EAAE,QAAQ,EAAE,MAAM,EAAwB,KAAI;AACjE,IAAA,QACCA,IAAA,CAAA,KAAA,EAAA,EAAK,SAAS,EAAE,MAAM,CAAC,IAAI,EAAA,QAAA,EAAA,CACzB,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--6":"BlogSection-module_margin-bottom--6__-hlAO","margin-bottom--9":"BlogSection-module_margin-bottom--9__xU5rE","blog-section__title":"BlogSection-module_blog-section__title__5-4Oy","blog-section":"BlogSection-module_blog-section__NTDM4"};
|
|
1
|
+
var styles = {"margin-bottom--6":"BlogSection-module_margin-bottom--6__-hlAO","margin-bottom--9":"BlogSection-module_margin-bottom--9__xU5rE","blog-section__title":"BlogSection-module_blog-section__title__5-4Oy","blog-section__title-link":"BlogSection-module_blog-section__title-link__Q4R5T","blog-section":"BlogSection-module_blog-section__NTDM4"};
|
|
2
2
|
|
|
3
3
|
export { styles as default };
|
|
4
4
|
//# sourceMappingURL=BlogSection.module.scss.js.map
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
var styles = {"margin-top":"Callout-module_margin-top__dS2UF","padding-top":"Callout-module_padding-top__aJrE4","margin-top--1":"Callout-module_margin-top--1__eBfEL","padding-top--1":"Callout-module_padding-top--1__rrL2e","margin-top--2":"Callout-module_margin-top--2__Ej-fE","padding-top--2":"Callout-module_padding-top--2__NtBHH","margin-top--3":"Callout-module_margin-top--3__AsHPR","padding-top--3":"Callout-module_padding-top--3__CjXpH","margin-top--4":"Callout-module_margin-top--4__3ji03","padding-top--4":"Callout-module_padding-top--4__BdcKb","margin-top--5":"Callout-module_margin-top--5__j3Qds","padding-top--5":"Callout-module_padding-top--5__TWT9C","margin-top--6":"Callout-module_margin-top--6__GQFRt","padding-top--6":"Callout-module_padding-top--6__4bYvI","margin-top--7":"Callout-module_margin-top--7__ArvNz","padding-top--7":"Callout-module_padding-top--7__PnU3M","margin-top--8":"Callout-module_margin-top--8__DvN7J","padding-top--8":"Callout-module_padding-top--8__qunY9","margin-top--9":"Callout-module_margin-top--9__mSjxY","padding-top--9":"Callout-module_padding-top--9__N4Z2b","margin-bottom":"Callout-module_margin-bottom__UlOKu","padding-bottom":"Callout-module_padding-bottom__-XwJQ","margin-bottom--1":"Callout-module_margin-bottom--1__LxnVH","padding-bottom--1":"Callout-module_padding-bottom--1__MfyXw","margin-bottom--2":"Callout-module_margin-bottom--2__nelQj","padding-bottom--2":"Callout-module_padding-bottom--2__9MX1j","margin-bottom--3":"Callout-module_margin-bottom--3__VfA8y","padding-bottom--3":"Callout-module_padding-bottom--3__FRllS","margin-bottom--4":"Callout-module_margin-bottom--4__-j-tS","padding-bottom--4":"Callout-module_padding-bottom--4__sJzsQ","margin-bottom--5":"Callout-module_margin-bottom--5__0hYDy","padding-bottom--5":"Callout-module_padding-bottom--5__c4BQo","margin-bottom--6":"Callout-module_margin-bottom--6__8Ny2B","padding-bottom--6":"Callout-module_padding-bottom--6__wNeJk","margin-bottom--7":"Callout-module_margin-bottom--7__0dYmE","padding-bottom--7":"Callout-module_padding-bottom--7__FueIs","margin-bottom--8":"Callout-module_margin-bottom--8__r93zU","padding-bottom--8":"Callout-module_padding-bottom--8__APcyf","margin-bottom--9":"Callout-module_margin-bottom--9__f6KUQ","padding-bottom--9":"Callout-module_padding-bottom--9__KVgqO","margin-left":"Callout-module_margin-left__mb1jm","padding-left":"Callout-module_padding-left__cgzip","margin-left--1":"Callout-module_margin-left--1__DWFsG","padding-left--1":"Callout-module_padding-left--1__3nWMz","margin-left--2":"Callout-module_margin-left--2__ByTNO","padding-left--2":"Callout-module_padding-left--2__9-PLw","margin-left--3":"Callout-module_margin-left--3__0Iz7m","padding-left--3":"Callout-module_padding-left--3__FQgJY","margin-left--4":"Callout-module_margin-left--4__cmAQ4","padding-left--4":"Callout-module_padding-left--4__pW9OV","margin-left--5":"Callout-module_margin-left--5__qD5bN","padding-left--5":"Callout-module_padding-left--5__FaZO8","margin-left--6":"Callout-module_margin-left--6__h-dBW","padding-left--6":"Callout-module_padding-left--6__RT6JH","margin-left--7":"Callout-module_margin-left--7__9wZFI","padding-left--7":"Callout-module_padding-left--7__-31-c","margin-left--8":"Callout-module_margin-left--8__bbcki","padding-left--8":"Callout-module_padding-left--8__f3ctw","margin-left--9":"Callout-module_margin-left--9__0xlWQ","padding-left--9":"Callout-module_padding-left--9__QsNKP","margin-right":"Callout-module_margin-right__CN33J","padding-right":"Callout-module_padding-right__Cn14a","margin-right--1":"Callout-module_margin-right--1__GAGZO","padding-right--1":"Callout-module_padding-right--1__qh8gH","margin-right--2":"Callout-module_margin-right--2__MjxOE","padding-right--2":"Callout-module_padding-right--2__CDawi","margin-right--3":"Callout-module_margin-right--3__w3PO-","padding-right--3":"Callout-module_padding-right--3__bOIL3","margin-right--4":"Callout-module_margin-right--4__wjZRG","padding-right--4":"Callout-module_padding-right--4__DNn-A","margin-right--5":"Callout-module_margin-right--5__JUYoz","padding-right--5":"Callout-module_padding-right--5__V1t3c","margin-right--6":"Callout-module_margin-right--6__UXR9-","padding-right--6":"Callout-module_padding-right--6__pVwQj","margin-right--7":"Callout-module_margin-right--7__ZwUec","padding-right--7":"Callout-module_padding-right--7__EHY0p","margin-right--8":"Callout-module_margin-right--8__k9asQ","padding-right--8":"Callout-module_padding-right--8__1Nqrm","margin-right--9":"Callout-module_margin-right--9__J8sMZ","padding-right--9":"Callout-module_padding-right--9__QYnAq","error":"Callout-module_error__UeboU","font--primary":"Callout-module_font--primary__Ayv9J","font--secondary":"Callout-module_font--secondary__mBXUH","font--code":"Callout-module_font--code__fG36F","font-weight--400":"Callout-module_font-weight--400__VYsxM","font-weight--500":"Callout-module_font-weight--500__zXuRq","font-weight--600":"Callout-module_font-weight--600__fJDVt","font-weight--700":"Callout-module_font-weight--700__3kQTh","font-weight--800":"Callout-module_font-weight--800__5POjB","font-size--h1":"Callout-module_font-size--h1__9fzEM","font-size--h2":"Callout-module_font-size--h2__EowCg","font-size--h3":"Callout-module_font-size--h3__8EcUJ","font-size--h4":"Callout-module_font-size--h4__ferQ7","font-size--h5":"Callout-module_font-size--h5__43lHF","font-size--h6":"Callout-module_font-size--h6__GpBej","font-size--big":"Callout-module_font-size--big__-BXjA","font-size--button":"Callout-module_font-size--button__9KupW","font-size--p":"Callout-module_font-size--p__RJTna","font-size--small":"Callout-module_font-size--small__YEsJl","line-height--large":"Callout-module_line-height--large__OStzV","line-height--normal":"Callout-module_line-height--normal__p5UA7","line-height--small":"Callout-module_line-height--small__2kXv9","text-align--center":"Callout-module_text-align--center__5JXeQ","category__header":"Callout-module_category__header__Edg04","a--highlighted":"Callout-module_a--highlighted__JmfE5","grecaptcha-badge":"Callout-module_grecaptcha-badge__7vWF5","container":"Callout-module_container__FV7VM","container--contents-centered":"Callout-module_container--contents-centered__zx2lp","container--no-padding":"Callout-module_container--no-padding__wI9Pc","page":"Callout-module_page__2bQ0P","page--contents-max-width":"Callout-module_page--contents-max-width__4p2pL","page--no-extra-padding":"Callout-module_page--no-extra-padding__lGzpM","page--no-max-width":"Callout-module_page--no-max-width__cF1qn","hr":"Callout-module_hr__iz4ZP","li--disabled":"Callout-module_li--disabled__09IJ1","block":"Callout-module_block__cdSSP","callout":"Callout-module_callout__kEgS8","callout__icon":"Callout-module_callout__icon__z-ZHp","callout--info":"Callout-module_callout--info__zpyMT","callout--info__icon":"Callout-module_callout--info__icon__hHBbh","callout--warning":"Callout-module_callout--warning__QhFli","callout--error":"Callout-module_callout--error__-HDOj","callout--success":"Callout-module_callout--success__f1lTK","callout__wrapper":"Callout-module_callout__wrapper__jooXm","loading_animation":"Callout-module_loading_animation__9m516","MoveInTop":"Callout-module_MoveInTop__fio2m","fadeInDown":"Callout-module_fadeInDown__webmy","fadeUp":"Callout-module_fadeUp__uXBP6"};
|
|
1
|
+
var styles = {"margin-top":"Callout-module_margin-top__dS2UF","padding-top":"Callout-module_padding-top__aJrE4","margin-top--1":"Callout-module_margin-top--1__eBfEL","padding-top--1":"Callout-module_padding-top--1__rrL2e","margin-top--2":"Callout-module_margin-top--2__Ej-fE","padding-top--2":"Callout-module_padding-top--2__NtBHH","margin-top--3":"Callout-module_margin-top--3__AsHPR","padding-top--3":"Callout-module_padding-top--3__CjXpH","margin-top--4":"Callout-module_margin-top--4__3ji03","padding-top--4":"Callout-module_padding-top--4__BdcKb","margin-top--5":"Callout-module_margin-top--5__j3Qds","padding-top--5":"Callout-module_padding-top--5__TWT9C","margin-top--6":"Callout-module_margin-top--6__GQFRt","padding-top--6":"Callout-module_padding-top--6__4bYvI","margin-top--7":"Callout-module_margin-top--7__ArvNz","padding-top--7":"Callout-module_padding-top--7__PnU3M","margin-top--8":"Callout-module_margin-top--8__DvN7J","padding-top--8":"Callout-module_padding-top--8__qunY9","margin-top--9":"Callout-module_margin-top--9__mSjxY","padding-top--9":"Callout-module_padding-top--9__N4Z2b","margin-bottom":"Callout-module_margin-bottom__UlOKu","padding-bottom":"Callout-module_padding-bottom__-XwJQ","margin-bottom--1":"Callout-module_margin-bottom--1__LxnVH","padding-bottom--1":"Callout-module_padding-bottom--1__MfyXw","margin-bottom--2":"Callout-module_margin-bottom--2__nelQj","padding-bottom--2":"Callout-module_padding-bottom--2__9MX1j","margin-bottom--3":"Callout-module_margin-bottom--3__VfA8y","padding-bottom--3":"Callout-module_padding-bottom--3__FRllS","margin-bottom--4":"Callout-module_margin-bottom--4__-j-tS","padding-bottom--4":"Callout-module_padding-bottom--4__sJzsQ","margin-bottom--5":"Callout-module_margin-bottom--5__0hYDy","padding-bottom--5":"Callout-module_padding-bottom--5__c4BQo","margin-bottom--6":"Callout-module_margin-bottom--6__8Ny2B","padding-bottom--6":"Callout-module_padding-bottom--6__wNeJk","margin-bottom--7":"Callout-module_margin-bottom--7__0dYmE","padding-bottom--7":"Callout-module_padding-bottom--7__FueIs","margin-bottom--8":"Callout-module_margin-bottom--8__r93zU","padding-bottom--8":"Callout-module_padding-bottom--8__APcyf","margin-bottom--9":"Callout-module_margin-bottom--9__f6KUQ","padding-bottom--9":"Callout-module_padding-bottom--9__KVgqO","margin-left":"Callout-module_margin-left__mb1jm","padding-left":"Callout-module_padding-left__cgzip","margin-left--1":"Callout-module_margin-left--1__DWFsG","padding-left--1":"Callout-module_padding-left--1__3nWMz","margin-left--2":"Callout-module_margin-left--2__ByTNO","padding-left--2":"Callout-module_padding-left--2__9-PLw","margin-left--3":"Callout-module_margin-left--3__0Iz7m","padding-left--3":"Callout-module_padding-left--3__FQgJY","margin-left--4":"Callout-module_margin-left--4__cmAQ4","padding-left--4":"Callout-module_padding-left--4__pW9OV","margin-left--5":"Callout-module_margin-left--5__qD5bN","padding-left--5":"Callout-module_padding-left--5__FaZO8","margin-left--6":"Callout-module_margin-left--6__h-dBW","padding-left--6":"Callout-module_padding-left--6__RT6JH","margin-left--7":"Callout-module_margin-left--7__9wZFI","padding-left--7":"Callout-module_padding-left--7__-31-c","margin-left--8":"Callout-module_margin-left--8__bbcki","padding-left--8":"Callout-module_padding-left--8__f3ctw","margin-left--9":"Callout-module_margin-left--9__0xlWQ","padding-left--9":"Callout-module_padding-left--9__QsNKP","margin-right":"Callout-module_margin-right__CN33J","padding-right":"Callout-module_padding-right__Cn14a","margin-right--1":"Callout-module_margin-right--1__GAGZO","padding-right--1":"Callout-module_padding-right--1__qh8gH","margin-right--2":"Callout-module_margin-right--2__MjxOE","padding-right--2":"Callout-module_padding-right--2__CDawi","margin-right--3":"Callout-module_margin-right--3__w3PO-","padding-right--3":"Callout-module_padding-right--3__bOIL3","margin-right--4":"Callout-module_margin-right--4__wjZRG","padding-right--4":"Callout-module_padding-right--4__DNn-A","margin-right--5":"Callout-module_margin-right--5__JUYoz","padding-right--5":"Callout-module_padding-right--5__V1t3c","margin-right--6":"Callout-module_margin-right--6__UXR9-","padding-right--6":"Callout-module_padding-right--6__pVwQj","margin-right--7":"Callout-module_margin-right--7__ZwUec","padding-right--7":"Callout-module_padding-right--7__EHY0p","margin-right--8":"Callout-module_margin-right--8__k9asQ","padding-right--8":"Callout-module_padding-right--8__1Nqrm","margin-right--9":"Callout-module_margin-right--9__J8sMZ","padding-right--9":"Callout-module_padding-right--9__QYnAq","error":"Callout-module_error__UeboU","font--primary":"Callout-module_font--primary__Ayv9J","font--secondary":"Callout-module_font--secondary__mBXUH","font--code":"Callout-module_font--code__fG36F","font-weight--400":"Callout-module_font-weight--400__VYsxM","font-weight--500":"Callout-module_font-weight--500__zXuRq","font-weight--600":"Callout-module_font-weight--600__fJDVt","font-weight--700":"Callout-module_font-weight--700__3kQTh","font-weight--800":"Callout-module_font-weight--800__5POjB","font-size--h1":"Callout-module_font-size--h1__9fzEM","font-size--h2":"Callout-module_font-size--h2__EowCg","font-size--h3":"Callout-module_font-size--h3__8EcUJ","font-size--h4":"Callout-module_font-size--h4__ferQ7","font-size--h5":"Callout-module_font-size--h5__43lHF","font-size--h6":"Callout-module_font-size--h6__GpBej","font-size--big":"Callout-module_font-size--big__-BXjA","font-size--button":"Callout-module_font-size--button__9KupW","font-size--p":"Callout-module_font-size--p__RJTna","font-size--small":"Callout-module_font-size--small__YEsJl","line-height--large":"Callout-module_line-height--large__OStzV","line-height--normal":"Callout-module_line-height--normal__p5UA7","line-height--small":"Callout-module_line-height--small__2kXv9","line-height--very-small":"Callout-module_line-height--very-small__AS59u","text-align--center":"Callout-module_text-align--center__5JXeQ","category__header":"Callout-module_category__header__Edg04","a--highlighted":"Callout-module_a--highlighted__JmfE5","grecaptcha-badge":"Callout-module_grecaptcha-badge__7vWF5","container":"Callout-module_container__FV7VM","container--contents-centered":"Callout-module_container--contents-centered__zx2lp","container--no-padding":"Callout-module_container--no-padding__wI9Pc","page":"Callout-module_page__2bQ0P","page--contents-max-width":"Callout-module_page--contents-max-width__4p2pL","page--no-extra-padding":"Callout-module_page--no-extra-padding__lGzpM","page--no-max-width":"Callout-module_page--no-max-width__cF1qn","hr":"Callout-module_hr__iz4ZP","li--disabled":"Callout-module_li--disabled__09IJ1","block":"Callout-module_block__cdSSP","callout":"Callout-module_callout__kEgS8","callout__icon":"Callout-module_callout__icon__z-ZHp","callout--info":"Callout-module_callout--info__zpyMT","callout--info__icon":"Callout-module_callout--info__icon__hHBbh","callout--warning":"Callout-module_callout--warning__QhFli","callout--error":"Callout-module_callout--error__-HDOj","callout--success":"Callout-module_callout--success__f1lTK","callout__wrapper":"Callout-module_callout__wrapper__jooXm","loading_animation":"Callout-module_loading_animation__9m516","MoveInTop":"Callout-module_MoveInTop__fio2m","fadeInDown":"Callout-module_fadeInDown__webmy","fadeUp":"Callout-module_fadeUp__uXBP6"};
|
|
2
2
|
|
|
3
3
|
export { styles as default };
|
|
4
4
|
//# sourceMappingURL=Callout.module.scss.js.map
|
package/dist/esm/utils/index.js
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
const generateIdForBlogTitle = (title) => title.toLowerCase().replace(/[^\w\d]/g, '-');
|
|
2
2
|
const generateUrlForBlogTitle = (title) => encodeURIComponent(title.replace(/[^\w]+/g, '-').toLowerCase());
|
|
3
|
+
const generateSectionHref = (id) => `?section=${id}`;
|
|
3
4
|
|
|
4
|
-
export { generateIdForBlogTitle, generateUrlForBlogTitle };
|
|
5
|
+
export { generateIdForBlogTitle, generateSectionHref, generateUrlForBlogTitle };
|
|
5
6
|
//# sourceMappingURL=index.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sources":["../../../src/utils/index.ts"],"sourcesContent":["export const generateIdForBlogTitle = (title: string) => title.toLowerCase().replace(/[^\\w\\d]/g, '-');\n\nexport const generateUrlForBlogTitle = (title: string) => encodeURIComponent(title.replace(/[^\\w]+/g, '-').toLowerCase());\n"],"names":[],"mappings":"MAAa,sBAAsB,GAAG,CAAC,KAAa,KAAK,KAAK,CAAC,WAAW,EAAE,CAAC,OAAO,CAAC,UAAU,EAAE,GAAG;MAEvF,uBAAuB,GAAG,CAAC,KAAa,KAAK,kBAAkB,CAAC,KAAK,CAAC,OAAO,CAAC,SAAS,EAAE,GAAG,CAAC,CAAC,WAAW,EAAE;;;;"}
|
|
1
|
+
{"version":3,"file":"index.js","sources":["../../../src/utils/index.ts"],"sourcesContent":["export const generateIdForBlogTitle = (title: string) => title.toLowerCase().replace(/[^\\w\\d]/g, '-');\n\nexport const generateUrlForBlogTitle = (title: string) => encodeURIComponent(title.replace(/[^\\w]+/g, '-').toLowerCase());\n\nexport const generateSectionHref = (id: string) => `?section=${id}`;\n"],"names":[],"mappings":"MAAa,sBAAsB,GAAG,CAAC,KAAa,KAAK,KAAK,CAAC,WAAW,EAAE,CAAC,OAAO,CAAC,UAAU,EAAE,GAAG;MAEvF,uBAAuB,GAAG,CAAC,KAAa,KAAK,kBAAkB,CAAC,KAAK,CAAC,OAAO,CAAC,SAAS,EAAE,GAAG,CAAC,CAAC,WAAW,EAAE;AAEjH,MAAM,mBAAmB,GAAG,CAAC,EAAU,KAAK,CAAA,SAAA,EAAY,EAAE,CAAA;;;;"}
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
const lockScrollUpdates = (id, isClickScrolling, scrollEndHandlerRef, setVisibleTitle) => {
|
|
2
|
+
if (scrollEndHandlerRef.current) {
|
|
3
|
+
document.body.removeEventListener('scrollend', scrollEndHandlerRef.current);
|
|
4
|
+
}
|
|
5
|
+
isClickScrolling.current = true;
|
|
6
|
+
scrollEndHandlerRef.current = () => {
|
|
7
|
+
isClickScrolling.current = false;
|
|
8
|
+
scrollEndHandlerRef.current = null;
|
|
9
|
+
setVisibleTitle(id);
|
|
10
|
+
const url = new URL(window.location.href);
|
|
11
|
+
url.searchParams.set('section', id);
|
|
12
|
+
window.history.replaceState({}, '', url.toString());
|
|
13
|
+
};
|
|
14
|
+
document.body.addEventListener('scrollend', scrollEndHandlerRef.current, {
|
|
15
|
+
once: true,
|
|
16
|
+
});
|
|
17
|
+
};
|
|
18
|
+
|
|
19
|
+
export { lockScrollUpdates as default };
|
|
20
|
+
//# sourceMappingURL=lockScrollUpdates.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"lockScrollUpdates.js","sources":["../../../src/utils/lockScrollUpdates.ts"],"sourcesContent":["import type { MutableRefObject } from 'react';\n\nconst lockScrollUpdates = (\n\tid: string,\n\tisClickScrolling: MutableRefObject<boolean>,\n\tscrollEndHandlerRef: MutableRefObject<(() => void) | null>,\n\tsetVisibleTitle: (id: string) => void\n) => {\n\tif (scrollEndHandlerRef.current) {\n\t\tdocument.body.removeEventListener('scrollend', scrollEndHandlerRef.current);\n\t}\n\n\tisClickScrolling.current = true;\n\n\tscrollEndHandlerRef.current = () => {\n\t\tisClickScrolling.current = false;\n\t\tscrollEndHandlerRef.current = null;\n\t\tsetVisibleTitle(id);\n\t\tconst url = new URL(window.location.href);\n\t\turl.searchParams.set('section', id);\n\t\twindow.history.replaceState({}, '', url.toString());\n\t};\n\n\tdocument.body.addEventListener('scrollend', scrollEndHandlerRef.current, {\n\t\tonce: true,\n\t});\n};\n\nexport default lockScrollUpdates;\n"],"names":[],"mappings":"AAEA,MAAM,iBAAiB,GAAG,CACzB,EAAU,EACV,gBAA2C,EAC3C,mBAA0D,EAC1D,eAAqC,KAClC;AACH,IAAA,IAAI,mBAAmB,CAAC,OAAO,EAAE;QAChC,QAAQ,CAAC,IAAI,CAAC,mBAAmB,CAAC,WAAW,EAAE,mBAAmB,CAAC,OAAO,CAAC;IAC5E;AAEA,IAAA,gBAAgB,CAAC,OAAO,GAAG,IAAI;AAE/B,IAAA,mBAAmB,CAAC,OAAO,GAAG,MAAK;AAClC,QAAA,gBAAgB,CAAC,OAAO,GAAG,KAAK;AAChC,QAAA,mBAAmB,CAAC,OAAO,GAAG,IAAI;QAClC,eAAe,CAAC,EAAE,CAAC;QACnB,MAAM,GAAG,GAAG,IAAI,GAAG,CAAC,MAAM,CAAC,QAAQ,CAAC,IAAI,CAAC;QACzC,GAAG,CAAC,YAAY,CAAC,GAAG,CAAC,SAAS,EAAE,EAAE,CAAC;AACnC,QAAA,MAAM,CAAC,OAAO,CAAC,YAAY,CAAC,EAAE,EAAE,EAAE,EAAE,GAAG,CAAC,QAAQ,EAAE,CAAC;AACpD,IAAA,CAAC;IAED,QAAQ,CAAC,IAAI,CAAC,gBAAgB,CAAC,WAAW,EAAE,mBAAmB,CAAC,OAAO,EAAE;AACxE,QAAA,IAAI,EAAE,IAAI;AACV,KAAA,CAAC;AACH;;;;"}
|
|
@@ -1,8 +1,10 @@
|
|
|
1
1
|
import type { ReactNode } from 'react';
|
|
2
|
+
import type { Thing, WithContext } from 'schema-dts';
|
|
2
3
|
interface BlogProperties {
|
|
3
4
|
children: ReactNode;
|
|
4
5
|
title?: string;
|
|
6
|
+
jsonLd?: WithContext<Thing>;
|
|
5
7
|
}
|
|
6
|
-
declare const Blog: ({ children, title }: BlogProperties) => import("react/jsx-runtime").JSX.Element;
|
|
8
|
+
declare const Blog: ({ children, title, jsonLd }: BlogProperties) => import("react/jsx-runtime").JSX.Element;
|
|
7
9
|
export default Blog;
|
|
8
10
|
//# 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;
|
|
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;CAC5B;AAED,QAAA,MAAM,IAAI,GAAI,6BAAiD,cAAc,4CAM5E,CAAC;AAEF,eAAe,IAAI,CAAC"}
|
|
@@ -1,12 +1,14 @@
|
|
|
1
1
|
import type { ReactNode } from 'react';
|
|
2
|
+
import type { Thing, WithContext } from 'schema-dts';
|
|
2
3
|
interface BlogProperties {
|
|
3
4
|
children: ReactNode;
|
|
4
5
|
title?: string;
|
|
6
|
+
jsonLd?: WithContext<Thing>;
|
|
5
7
|
}
|
|
6
8
|
export interface ForwardedReference {
|
|
7
9
|
parentRef: HTMLDivElement;
|
|
8
10
|
childRefs: HTMLDivElement[];
|
|
9
11
|
}
|
|
10
|
-
declare const Blog: ({ children, title }: BlogProperties) => import("react/jsx-runtime").JSX.Element;
|
|
12
|
+
declare const Blog: ({ children, title, jsonLd, }: BlogProperties) => import("react/jsx-runtime").JSX.Element;
|
|
11
13
|
export default Blog;
|
|
12
14
|
//# sourceMappingURL=BlogDynamic.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"BlogDynamic.d.ts","sourceRoot":"","sources":["../../../src/dynamicComponents/BlogDynamic.tsx"],"names":[],"mappings":"AAaA,OAAO,KAAK,EAAc,SAAS,EAAiB,MAAM,OAAO,CAAC;
|
|
1
|
+
{"version":3,"file":"BlogDynamic.d.ts","sourceRoot":"","sources":["../../../src/dynamicComponents/BlogDynamic.tsx"],"names":[],"mappings":"AAaA,OAAO,KAAK,EAAc,SAAS,EAAiB,MAAM,OAAO,CAAC;AAClE,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;CAC5B;AAED,MAAM,WAAW,kBAAkB;IAClC,SAAS,EAAE,cAAc,CAAC;IAC1B,SAAS,EAAE,cAAc,EAAE,CAAC;CAC5B;AAgBD,QAAA,MAAM,IAAI,GAAI,8BAIX,cAAc,4CAiPhB,CAAC;AAEF,eAAe,IAAI,CAAC"}
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
import type { MutableRefObject } from 'react';
|
|
2
|
+
declare const lockScrollUpdates: (id: string, isClickScrolling: MutableRefObject<boolean>, scrollEndHandlerRef: MutableRefObject<(() => void) | null>, setVisibleTitle: (id: string) => void) => void;
|
|
3
|
+
export default lockScrollUpdates;
|
|
4
|
+
//# sourceMappingURL=lockScrollUpdates.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"lockScrollUpdates.d.ts","sourceRoot":"","sources":["../../../src/dynamicComponents/lockScrollUpdates.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,OAAO,CAAC;AAE9C,QAAA,MAAM,iBAAiB,GACtB,IAAI,MAAM,EACV,kBAAkB,gBAAgB,CAAC,OAAO,CAAC,EAC3C,qBAAqB,gBAAgB,CAAC,CAAC,MAAM,IAAI,CAAC,GAAG,IAAI,CAAC,EAC1D,iBAAiB,CAAC,EAAE,EAAE,MAAM,KAAK,IAAI,SAoBrC,CAAC;AAEF,eAAe,iBAAiB,CAAC"}
|
|
@@ -1,7 +1,9 @@
|
|
|
1
1
|
import type { ReactNode } from 'react';
|
|
2
|
+
import type { Thing, WithContext } from 'schema-dts';
|
|
2
3
|
interface BlogStaticProperties {
|
|
3
4
|
children: ReactNode;
|
|
5
|
+
jsonLd?: WithContext<Thing>;
|
|
4
6
|
}
|
|
5
|
-
declare const BlogStatic: ({ children }: BlogStaticProperties) => import("react/jsx-runtime").JSX.Element;
|
|
7
|
+
declare const BlogStatic: ({ children, jsonLd }: BlogStaticProperties) => import("react/jsx-runtime").JSX.Element;
|
|
6
8
|
export default BlogStatic;
|
|
7
9
|
//# 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;
|
|
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;CAC5B;AAED,QAAA,MAAM,UAAU,GAAI,sBAAsB,oBAAoB,4CAY7D,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.16",
|
|
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",
|
|
@@ -38,7 +38,8 @@
|
|
|
38
38
|
"author": "Santhosh Siva",
|
|
39
39
|
"license": "MIT",
|
|
40
40
|
"dependencies": {
|
|
41
|
-
"@san-siva/stylekit": "^1.0.5"
|
|
41
|
+
"@san-siva/stylekit": "^1.0.5",
|
|
42
|
+
"schema-dts": "^1.1.5"
|
|
42
43
|
},
|
|
43
44
|
"peerDependencies": {
|
|
44
45
|
"@react-spring/web": "^10.0.0",
|
package/src/components/Blog.tsx
CHANGED
|
@@ -2,6 +2,7 @@
|
|
|
2
2
|
|
|
3
3
|
import { lazy, Suspense } from 'react';
|
|
4
4
|
import type { ReactNode } from 'react';
|
|
5
|
+
import type { Thing, WithContext } from 'schema-dts';
|
|
5
6
|
import BlogStatic from '../staticComponents/BlogStatic';
|
|
6
7
|
|
|
7
8
|
const BlogDynamic = lazy(() => import('../dynamicComponents/BlogDynamic'));
|
|
@@ -9,12 +10,13 @@ const BlogDynamic = lazy(() => import('../dynamicComponents/BlogDynamic'));
|
|
|
9
10
|
interface BlogProperties {
|
|
10
11
|
children: ReactNode;
|
|
11
12
|
title?: string;
|
|
13
|
+
jsonLd?: WithContext<Thing>;
|
|
12
14
|
}
|
|
13
15
|
|
|
14
|
-
const Blog = ({ children, title = 'In this article' }: BlogProperties) => {
|
|
16
|
+
const Blog = ({ children, title = 'In this article', jsonLd }: BlogProperties) => {
|
|
15
17
|
return (
|
|
16
|
-
<Suspense fallback={<BlogStatic>{children}</BlogStatic>}>
|
|
17
|
-
<BlogDynamic title={title}>{children}</BlogDynamic>
|
|
18
|
+
<Suspense fallback={<BlogStatic jsonLd={jsonLd}>{children}</BlogStatic>}>
|
|
19
|
+
<BlogDynamic title={title} jsonLd={jsonLd}>{children}</BlogDynamic>
|
|
18
20
|
</Suspense>
|
|
19
21
|
);
|
|
20
22
|
};
|
|
@@ -12,12 +12,15 @@ import {
|
|
|
12
12
|
import { useSpring, animated, config } from '@react-spring/web';
|
|
13
13
|
|
|
14
14
|
import type { MouseEvent, ReactNode, RefAttributes } from 'react';
|
|
15
|
+
import type { Thing, WithContext } from 'schema-dts';
|
|
15
16
|
|
|
16
17
|
import styles from '../styles/Blog.module.scss';
|
|
18
|
+
import lockScrollUpdates from '../utils/lockScrollUpdates';
|
|
17
19
|
|
|
18
20
|
interface BlogProperties {
|
|
19
21
|
children: ReactNode;
|
|
20
22
|
title?: string;
|
|
23
|
+
jsonLd?: WithContext<Thing>;
|
|
21
24
|
}
|
|
22
25
|
|
|
23
26
|
export interface ForwardedReference {
|
|
@@ -39,7 +42,11 @@ interface CategoryTitleValue extends SectionReferenceValue {
|
|
|
39
42
|
|
|
40
43
|
type CategoryTitle = Map<string, CategoryTitleValue>;
|
|
41
44
|
|
|
42
|
-
const Blog = ({
|
|
45
|
+
const Blog = ({
|
|
46
|
+
children,
|
|
47
|
+
title = 'In this article',
|
|
48
|
+
jsonLd,
|
|
49
|
+
}: BlogProperties) => {
|
|
43
50
|
const sectionReferences = useRef<SectionReference>(new Map());
|
|
44
51
|
const [categoryTitles, setCategoryTitles] = useState<CategoryTitle>(
|
|
45
52
|
new Map()
|
|
@@ -49,6 +56,9 @@ const Blog = ({ children, title = 'In this article' }: BlogProperties) => {
|
|
|
49
56
|
|
|
50
57
|
const updateTimerRef = useRef<ReturnType<typeof setTimeout> | null>(null);
|
|
51
58
|
const showTOCTimerRef = useRef<ReturnType<typeof setTimeout> | null>(null);
|
|
59
|
+
const hasScrolledToInitialSection = useRef(false);
|
|
60
|
+
const isClickScrolling = useRef(false);
|
|
61
|
+
const scrollEndHandlerRef = useRef<(() => void) | null>(null);
|
|
52
62
|
|
|
53
63
|
const sortByDomPosition = useCallback(
|
|
54
64
|
(
|
|
@@ -112,6 +122,7 @@ const Blog = ({ children, title = 'In this article' }: BlogProperties) => {
|
|
|
112
122
|
const observer = new IntersectionObserver(
|
|
113
123
|
([entry]) => {
|
|
114
124
|
if (!entry.isIntersecting) return;
|
|
125
|
+
if (isClickScrolling.current) return;
|
|
115
126
|
setVisibleTitle(visibleId => {
|
|
116
127
|
if (visibleId === id && !entry.isIntersecting) return null;
|
|
117
128
|
if (entry.isIntersecting) return id;
|
|
@@ -138,9 +149,28 @@ const Blog = ({ children, title = 'In this article' }: BlogProperties) => {
|
|
|
138
149
|
if (showTOCTimerRef.current) {
|
|
139
150
|
clearTimeout(showTOCTimerRef.current);
|
|
140
151
|
}
|
|
152
|
+
if (scrollEndHandlerRef.current) {
|
|
153
|
+
document.body.removeEventListener('scrollend', scrollEndHandlerRef.current);
|
|
154
|
+
}
|
|
141
155
|
};
|
|
142
156
|
}, []);
|
|
143
157
|
|
|
158
|
+
// On initial load, scroll to section specified in URL
|
|
159
|
+
useEffect(() => {
|
|
160
|
+
if (hasScrolledToInitialSection.current) return;
|
|
161
|
+
if (categoryTitles.size === 0) return;
|
|
162
|
+
const url = new URL(window.location.href);
|
|
163
|
+
const section = url.searchParams.get('section');
|
|
164
|
+
if (!section) return;
|
|
165
|
+
const entry = categoryTitles.get(section);
|
|
166
|
+
if (!entry) return;
|
|
167
|
+
hasScrolledToInitialSection.current = true;
|
|
168
|
+
const top =
|
|
169
|
+
entry.el.getBoundingClientRect().top + document.body.scrollTop - 100;
|
|
170
|
+
document.body.scrollTo({ top, behavior: 'smooth' });
|
|
171
|
+
lockScrollUpdates(section, isClickScrolling, scrollEndHandlerRef, setVisibleTitle);
|
|
172
|
+
}, [categoryTitles]);
|
|
173
|
+
|
|
144
174
|
const handleSectionReference = useCallback(
|
|
145
175
|
(element: ForwardedReference) => {
|
|
146
176
|
if (!element) return;
|
|
@@ -191,15 +221,17 @@ const Blog = ({ children, title = 'In this article' }: BlogProperties) => {
|
|
|
191
221
|
if (!el) return;
|
|
192
222
|
|
|
193
223
|
const top = el.getBoundingClientRect().top + document.body.scrollTop - 100;
|
|
224
|
+
|
|
225
|
+
const url = new URL(window.location.href);
|
|
226
|
+
url.searchParams.set('section', id);
|
|
227
|
+
window.history.replaceState({}, '', url.toString());
|
|
228
|
+
|
|
194
229
|
document.body.scrollTo({
|
|
195
230
|
top,
|
|
196
231
|
behavior: 'smooth',
|
|
197
232
|
});
|
|
198
233
|
|
|
199
|
-
|
|
200
|
-
setVisibleTitle(id);
|
|
201
|
-
clearTimeout(timer);
|
|
202
|
-
}, 1000);
|
|
234
|
+
lockScrollUpdates(id, isClickScrolling, scrollEndHandlerRef, setVisibleTitle);
|
|
203
235
|
};
|
|
204
236
|
|
|
205
237
|
const sidebarStyle = useSpring({
|
|
@@ -210,6 +242,12 @@ const Blog = ({ children, title = 'In this article' }: BlogProperties) => {
|
|
|
210
242
|
|
|
211
243
|
return (
|
|
212
244
|
<div className={styles.blog}>
|
|
245
|
+
{jsonLd && (
|
|
246
|
+
<script
|
|
247
|
+
type="application/ld+json"
|
|
248
|
+
dangerouslySetInnerHTML={{ __html: JSON.stringify(jsonLd) }}
|
|
249
|
+
/>
|
|
250
|
+
)}
|
|
213
251
|
<div className={styles['blog__content']}>
|
|
214
252
|
{Children.map(children, child => {
|
|
215
253
|
if (!isValidElement(child)) return child;
|
|
@@ -14,7 +14,7 @@ import type { ReactNode, RefAttributes } from 'react';
|
|
|
14
14
|
import styles from '../styles/BlogSection.module.scss';
|
|
15
15
|
|
|
16
16
|
import type { ForwardedReference } from './BlogDynamic';
|
|
17
|
-
import { generateIdForBlogTitle } from '../utils';
|
|
17
|
+
import { generateIdForBlogTitle, generateSectionHref } from '../utils';
|
|
18
18
|
|
|
19
19
|
interface BlogProperties {
|
|
20
20
|
title?: string;
|
|
@@ -74,7 +74,11 @@ const BlogSection = forwardRef<ForwardedReference, BlogProperties>(
|
|
|
74
74
|
ref={parentReference}
|
|
75
75
|
>
|
|
76
76
|
{title ? (
|
|
77
|
-
<h4 className={styles['blog-section__title']}>
|
|
77
|
+
<h4 className={styles['blog-section__title']}>
|
|
78
|
+
<a href={generateSectionHref(id)} className={styles['blog-section__title-link']} onClick={e => e.preventDefault()}>
|
|
79
|
+
{title}
|
|
80
|
+
</a>
|
|
81
|
+
</h4>
|
|
78
82
|
) : null}
|
|
79
83
|
{Children.map(children, child => {
|
|
80
84
|
if (!isValidElement(child)) return child;
|
|
@@ -1,13 +1,21 @@
|
|
|
1
1
|
import type { ReactNode } from 'react';
|
|
2
|
+
import type { Thing, WithContext } from 'schema-dts';
|
|
2
3
|
import styles from '../styles/Blog.module.scss';
|
|
3
4
|
|
|
4
5
|
interface BlogStaticProperties {
|
|
5
6
|
children: ReactNode;
|
|
7
|
+
jsonLd?: WithContext<Thing>;
|
|
6
8
|
}
|
|
7
9
|
|
|
8
|
-
const BlogStatic = ({ children }: BlogStaticProperties) => {
|
|
10
|
+
const BlogStatic = ({ children, jsonLd }: BlogStaticProperties) => {
|
|
9
11
|
return (
|
|
10
12
|
<div className={styles.blog}>
|
|
13
|
+
{jsonLd && (
|
|
14
|
+
<script
|
|
15
|
+
type="application/ld+json"
|
|
16
|
+
dangerouslySetInnerHTML={{ __html: JSON.stringify(jsonLd) }}
|
|
17
|
+
/>
|
|
18
|
+
)}
|
|
11
19
|
<div className={styles['blog__content']}>{children}</div>
|
|
12
20
|
</div>
|
|
13
21
|
);
|
|
@@ -4,6 +4,20 @@
|
|
|
4
4
|
&__title {
|
|
5
5
|
margin-bottom: stylekit.space(2);
|
|
6
6
|
}
|
|
7
|
+
|
|
8
|
+
&__title-link {
|
|
9
|
+
color: inherit;
|
|
10
|
+
text-decoration: none;
|
|
11
|
+
font-size: inherit;
|
|
12
|
+
font-weight: inherit;
|
|
13
|
+
font-family: inherit;
|
|
14
|
+
|
|
15
|
+
&:hover {
|
|
16
|
+
color: stylekit.$color--dark;
|
|
17
|
+
text-decoration: underline;
|
|
18
|
+
text-decoration-color: stylekit.$color--primary;
|
|
19
|
+
}
|
|
20
|
+
}
|
|
7
21
|
}
|
|
8
22
|
|
|
9
23
|
.blog-section .blog-section > .blog-section__title {
|
|
@@ -24,9 +38,9 @@
|
|
|
24
38
|
}
|
|
25
39
|
|
|
26
40
|
.margin-bottom--6 {
|
|
27
|
-
|
|
41
|
+
margin-bottom: stylekit.space(6);
|
|
28
42
|
}
|
|
29
43
|
|
|
30
44
|
.margin-bottom--9 {
|
|
31
|
-
|
|
45
|
+
margin-bottom: stylekit.space(9);
|
|
32
46
|
}
|
package/src/utils/index.ts
CHANGED
|
@@ -1,3 +1,5 @@
|
|
|
1
1
|
export const generateIdForBlogTitle = (title: string) => title.toLowerCase().replace(/[^\w\d]/g, '-');
|
|
2
2
|
|
|
3
3
|
export const generateUrlForBlogTitle = (title: string) => encodeURIComponent(title.replace(/[^\w]+/g, '-').toLowerCase());
|
|
4
|
+
|
|
5
|
+
export const generateSectionHref = (id: string) => `?section=${id}`;
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
import type { MutableRefObject } from 'react';
|
|
2
|
+
|
|
3
|
+
const lockScrollUpdates = (
|
|
4
|
+
id: string,
|
|
5
|
+
isClickScrolling: MutableRefObject<boolean>,
|
|
6
|
+
scrollEndHandlerRef: MutableRefObject<(() => void) | null>,
|
|
7
|
+
setVisibleTitle: (id: string) => void
|
|
8
|
+
) => {
|
|
9
|
+
if (scrollEndHandlerRef.current) {
|
|
10
|
+
document.body.removeEventListener('scrollend', scrollEndHandlerRef.current);
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
isClickScrolling.current = true;
|
|
14
|
+
|
|
15
|
+
scrollEndHandlerRef.current = () => {
|
|
16
|
+
isClickScrolling.current = false;
|
|
17
|
+
scrollEndHandlerRef.current = null;
|
|
18
|
+
setVisibleTitle(id);
|
|
19
|
+
const url = new URL(window.location.href);
|
|
20
|
+
url.searchParams.set('section', id);
|
|
21
|
+
window.history.replaceState({}, '', url.toString());
|
|
22
|
+
};
|
|
23
|
+
|
|
24
|
+
document.body.addEventListener('scrollend', scrollEndHandlerRef.current, {
|
|
25
|
+
once: true,
|
|
26
|
+
});
|
|
27
|
+
};
|
|
28
|
+
|
|
29
|
+
export default lockScrollUpdates;
|