@c-rex/utils 0.3.0-build.31 → 0.3.0-build.33
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/index.d.mts +2 -1
- package/dist/index.d.ts +2 -1
- package/dist/index.js +8 -5
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +7 -5
- package/dist/index.mjs.map +1 -1
- package/package.json +1 -1
package/dist/index.d.mts
CHANGED
|
@@ -114,6 +114,7 @@ type ParsedHtmlContent = {
|
|
|
114
114
|
};
|
|
115
115
|
declare const parseHtmlContent: (html: string) => ParsedHtmlContent;
|
|
116
116
|
declare const getHtmlRenditionViewUrl: (renditions: RenditionModel[] | null | undefined, htmlFormats?: string[]) => string | undefined;
|
|
117
|
+
declare const getHtmlRendition: (renditions: RenditionModel[] | null | undefined, htmlFormats?: string[]) => RenditionModel | undefined;
|
|
117
118
|
declare const metaTagsToMetadata: (metaTags: HtmlMetaTag[]) => Pick<Metadata, "description" | "keywords" | "other">;
|
|
118
119
|
|
|
119
120
|
type RelatedFragmentLike = ObjectRefModel & {
|
|
@@ -128,4 +129,4 @@ interface FindRelatedFragmentOptions {
|
|
|
128
129
|
declare const findRelatedFragment: ({ item, informationSubjectIds, }: FindRelatedFragmentOptions) => RelatedFragmentLike | undefined;
|
|
129
130
|
declare const findRelatedFragmentShortId: (options: FindRelatedFragmentOptions) => string | undefined;
|
|
130
131
|
|
|
131
|
-
export { type FileRenditionActionGroup, type FileRenditionActionItem, type HtmlMetaTag, type ParsedHtmlContent, call, cn, createAvailableVersionList, createParams, extractCountryCodeFromLanguage, filteredItems, findRelatedFragment, findRelatedFragmentShortId, formatDateToLocale, generateBreadcrumbItems, generateQueryParams, getCountryCodeByLang, getFileRenditionGroups, getFileRenditions, getHtmlRenditionViewUrl, getLabelByLang, getLanguage, getTitle, getType, getVersions, isDate, isLanguage, metaTagsToMetadata, normalizeLanguageCode, parseHtmlContent, processDataToLabelValuePairs, replacePathParams, resolveLabelByLanguage, resolvePreferredLanguage, sortAndDeduplicateLanguages, transformLanguageData };
|
|
132
|
+
export { type FileRenditionActionGroup, type FileRenditionActionItem, type HtmlMetaTag, type ParsedHtmlContent, call, cn, createAvailableVersionList, createParams, extractCountryCodeFromLanguage, filteredItems, findRelatedFragment, findRelatedFragmentShortId, formatDateToLocale, generateBreadcrumbItems, generateQueryParams, getCountryCodeByLang, getFileRenditionGroups, getFileRenditions, getHtmlRendition, getHtmlRenditionViewUrl, getLabelByLang, getLanguage, getTitle, getType, getVersions, isDate, isLanguage, metaTagsToMetadata, normalizeLanguageCode, parseHtmlContent, processDataToLabelValuePairs, replacePathParams, resolveLabelByLanguage, resolvePreferredLanguage, sortAndDeduplicateLanguages, transformLanguageData };
|
package/dist/index.d.ts
CHANGED
|
@@ -114,6 +114,7 @@ type ParsedHtmlContent = {
|
|
|
114
114
|
};
|
|
115
115
|
declare const parseHtmlContent: (html: string) => ParsedHtmlContent;
|
|
116
116
|
declare const getHtmlRenditionViewUrl: (renditions: RenditionModel[] | null | undefined, htmlFormats?: string[]) => string | undefined;
|
|
117
|
+
declare const getHtmlRendition: (renditions: RenditionModel[] | null | undefined, htmlFormats?: string[]) => RenditionModel | undefined;
|
|
117
118
|
declare const metaTagsToMetadata: (metaTags: HtmlMetaTag[]) => Pick<Metadata, "description" | "keywords" | "other">;
|
|
118
119
|
|
|
119
120
|
type RelatedFragmentLike = ObjectRefModel & {
|
|
@@ -128,4 +129,4 @@ interface FindRelatedFragmentOptions {
|
|
|
128
129
|
declare const findRelatedFragment: ({ item, informationSubjectIds, }: FindRelatedFragmentOptions) => RelatedFragmentLike | undefined;
|
|
129
130
|
declare const findRelatedFragmentShortId: (options: FindRelatedFragmentOptions) => string | undefined;
|
|
130
131
|
|
|
131
|
-
export { type FileRenditionActionGroup, type FileRenditionActionItem, type HtmlMetaTag, type ParsedHtmlContent, call, cn, createAvailableVersionList, createParams, extractCountryCodeFromLanguage, filteredItems, findRelatedFragment, findRelatedFragmentShortId, formatDateToLocale, generateBreadcrumbItems, generateQueryParams, getCountryCodeByLang, getFileRenditionGroups, getFileRenditions, getHtmlRenditionViewUrl, getLabelByLang, getLanguage, getTitle, getType, getVersions, isDate, isLanguage, metaTagsToMetadata, normalizeLanguageCode, parseHtmlContent, processDataToLabelValuePairs, replacePathParams, resolveLabelByLanguage, resolvePreferredLanguage, sortAndDeduplicateLanguages, transformLanguageData };
|
|
132
|
+
export { type FileRenditionActionGroup, type FileRenditionActionItem, type HtmlMetaTag, type ParsedHtmlContent, call, cn, createAvailableVersionList, createParams, extractCountryCodeFromLanguage, filteredItems, findRelatedFragment, findRelatedFragmentShortId, formatDateToLocale, generateBreadcrumbItems, generateQueryParams, getCountryCodeByLang, getFileRenditionGroups, getFileRenditions, getHtmlRendition, getHtmlRenditionViewUrl, getLabelByLang, getLanguage, getTitle, getType, getVersions, isDate, isLanguage, metaTagsToMetadata, normalizeLanguageCode, parseHtmlContent, processDataToLabelValuePairs, replacePathParams, resolveLabelByLanguage, resolvePreferredLanguage, sortAndDeduplicateLanguages, transformLanguageData };
|
package/dist/index.js
CHANGED
|
@@ -44,6 +44,7 @@ __export(index_exports, {
|
|
|
44
44
|
getCountryCodeByLang: () => getCountryCodeByLang,
|
|
45
45
|
getFileRenditionGroups: () => getFileRenditionGroups,
|
|
46
46
|
getFileRenditions: () => getFileRenditions,
|
|
47
|
+
getHtmlRendition: () => getHtmlRendition,
|
|
47
48
|
getHtmlRenditionViewUrl: () => getHtmlRenditionViewUrl,
|
|
48
49
|
getLabelByLang: () => getLabelByLang,
|
|
49
50
|
getLanguage: () => getLanguage,
|
|
@@ -1811,20 +1812,21 @@ var parseHtmlContent = (html) => {
|
|
|
1811
1812
|
const content = $(el).attr("content");
|
|
1812
1813
|
return name && content ? { name, content } : null;
|
|
1813
1814
|
}).get().filter((tag) => tag !== null);
|
|
1814
|
-
const articleHtml = $("main").html() || "";
|
|
1815
|
+
const articleHtml = $("main").html() || $("article").html() || $("body").html() || $.root().html() || "";
|
|
1815
1816
|
return {
|
|
1816
1817
|
articleHtml,
|
|
1817
1818
|
metaTags
|
|
1818
1819
|
};
|
|
1819
1820
|
};
|
|
1820
1821
|
var getHtmlRenditionViewUrl = (renditions, htmlFormats = ["application/xhtml+xml", "application/html", "text/html"]) => {
|
|
1821
|
-
|
|
1822
|
-
const htmlRendition = renditions.find((rendition) => {
|
|
1823
|
-
return !!rendition.format && htmlFormats.includes(rendition.format);
|
|
1824
|
-
});
|
|
1822
|
+
const htmlRendition = getHtmlRendition(renditions, htmlFormats);
|
|
1825
1823
|
const href = htmlRendition?.links?.find((link) => link.rel === "view")?.href;
|
|
1826
1824
|
return href ?? void 0;
|
|
1827
1825
|
};
|
|
1826
|
+
var getHtmlRendition = (renditions, htmlFormats = ["application/xhtml+xml", "application/html", "text/html"]) => {
|
|
1827
|
+
if (!renditions || renditions.length === 0) return void 0;
|
|
1828
|
+
return renditions.find((rendition) => !!rendition.format && htmlFormats.includes(rendition.format));
|
|
1829
|
+
};
|
|
1828
1830
|
var metaTagsToMetadata = (metaTags) => {
|
|
1829
1831
|
const description = metaTags.find((metaTag) => metaTag.name === "description")?.content;
|
|
1830
1832
|
const keywordsRaw = metaTags.find((metaTag) => metaTag.name === "keywords")?.content;
|
|
@@ -1879,6 +1881,7 @@ var findRelatedFragmentShortId = (options) => {
|
|
|
1879
1881
|
getCountryCodeByLang,
|
|
1880
1882
|
getFileRenditionGroups,
|
|
1881
1883
|
getFileRenditions,
|
|
1884
|
+
getHtmlRendition,
|
|
1882
1885
|
getHtmlRenditionViewUrl,
|
|
1883
1886
|
getLabelByLang,
|
|
1884
1887
|
getLanguage,
|