@digitalculture/ochre-sdk 0.2.12 → 0.3.1
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.cjs +60 -4
- package/dist/index.d.cts +5 -1
- package/dist/index.d.ts +5 -1
- package/dist/index.js +60 -4
- package/package.json +1 -1
package/dist/index.cjs
CHANGED
|
@@ -2065,8 +2065,20 @@ async function parseWebsite(websiteTree, projectName, website) {
|
|
|
2065
2065
|
}
|
|
2066
2066
|
const resources = Array.isArray(websiteTree.items.resource) ? websiteTree.items.resource : [websiteTree.items.resource];
|
|
2067
2067
|
const pages = await parseWebpages(resources);
|
|
2068
|
+
let sidebar = null;
|
|
2068
2069
|
const sidebarElements = [];
|
|
2069
|
-
const
|
|
2070
|
+
const sidebarTitle = {
|
|
2071
|
+
label: "",
|
|
2072
|
+
variant: "default",
|
|
2073
|
+
properties: {
|
|
2074
|
+
isNameDisplayed: false,
|
|
2075
|
+
isDescriptionDisplayed: false,
|
|
2076
|
+
isDateDisplayed: false,
|
|
2077
|
+
isCreatorsDisplayed: false
|
|
2078
|
+
}
|
|
2079
|
+
};
|
|
2080
|
+
const sidebarCssStyles = [];
|
|
2081
|
+
const sidebarResource = resources.find((resource) => {
|
|
2070
2082
|
const resourceProperties = resource.properties ? parseProperties(
|
|
2071
2083
|
Array.isArray(resource.properties.property) ? resource.properties.property : [resource.properties.property]
|
|
2072
2084
|
) : [];
|
|
@@ -2074,8 +2086,45 @@ async function parseWebsite(websiteTree, projectName, website) {
|
|
|
2074
2086
|
(property) => property.label === "presentation" && property.values[0]?.content === "element" && property.properties[0]?.label === "component" && property.properties[0]?.values[0]?.content === "sidebar"
|
|
2075
2087
|
);
|
|
2076
2088
|
});
|
|
2077
|
-
if (
|
|
2078
|
-
|
|
2089
|
+
if (sidebarResource) {
|
|
2090
|
+
sidebarTitle.label = typeof sidebarResource.identification.label === "string" || typeof sidebarResource.identification.label === "number" || typeof sidebarResource.identification.label === "boolean" ? parseFakeString(sidebarResource.identification.label) : parseStringContent(sidebarResource.identification.label);
|
|
2091
|
+
const sidebarProperties = sidebarResource.properties ? parseProperties(
|
|
2092
|
+
Array.isArray(sidebarResource.properties.property) ? sidebarResource.properties.property : [sidebarResource.properties.property]
|
|
2093
|
+
) : [];
|
|
2094
|
+
const cssProperties = sidebarProperties.find(
|
|
2095
|
+
(property) => property.label === "presentation" && property.values[0].content === "css"
|
|
2096
|
+
)?.properties ?? [];
|
|
2097
|
+
for (const property of cssProperties) {
|
|
2098
|
+
const cssStyle = property.values[0].content;
|
|
2099
|
+
sidebarCssStyles.push({ label: property.label, value: cssStyle });
|
|
2100
|
+
}
|
|
2101
|
+
const titleProperties = sidebarProperties.find(
|
|
2102
|
+
(property) => property.label === "title"
|
|
2103
|
+
)?.properties;
|
|
2104
|
+
if (titleProperties) {
|
|
2105
|
+
const titleVariant = getPropertyValueByLabel(titleProperties, "variant");
|
|
2106
|
+
if (titleVariant) {
|
|
2107
|
+
sidebarTitle.variant = titleVariant;
|
|
2108
|
+
}
|
|
2109
|
+
const titleShow = titleProperties.filter(
|
|
2110
|
+
(property) => property.label === "display"
|
|
2111
|
+
);
|
|
2112
|
+
if (titleShow.length > 0) {
|
|
2113
|
+
sidebarTitle.properties.isNameDisplayed = titleShow.some(
|
|
2114
|
+
(property) => property.values[0].content === "name"
|
|
2115
|
+
);
|
|
2116
|
+
sidebarTitle.properties.isDescriptionDisplayed = titleShow.some(
|
|
2117
|
+
(property) => property.values[0].content === "description"
|
|
2118
|
+
);
|
|
2119
|
+
sidebarTitle.properties.isDateDisplayed = titleShow.some(
|
|
2120
|
+
(property) => property.values[0].content === "date"
|
|
2121
|
+
);
|
|
2122
|
+
sidebarTitle.properties.isCreatorsDisplayed = titleShow.some(
|
|
2123
|
+
(property) => property.values[0].content === "creators"
|
|
2124
|
+
);
|
|
2125
|
+
}
|
|
2126
|
+
}
|
|
2127
|
+
const sidebarResources = sidebarResource.resource ? Array.isArray(sidebarResource.resource) ? sidebarResource.resource : [sidebarResource.resource] : [];
|
|
2079
2128
|
for (const resource of sidebarResources) {
|
|
2080
2129
|
const sidebarResourceProperties = resource.properties ? parseProperties(
|
|
2081
2130
|
Array.isArray(resource.properties.property) ? resource.properties.property : [resource.properties.property]
|
|
@@ -2089,6 +2138,13 @@ async function parseWebsite(websiteTree, projectName, website) {
|
|
|
2089
2138
|
sidebarElements.push(element);
|
|
2090
2139
|
}
|
|
2091
2140
|
}
|
|
2141
|
+
if (sidebarElements.length > 0) {
|
|
2142
|
+
sidebar = {
|
|
2143
|
+
elements: sidebarElements,
|
|
2144
|
+
title: sidebarTitle,
|
|
2145
|
+
cssStyles: sidebarCssStyles
|
|
2146
|
+
};
|
|
2147
|
+
}
|
|
2092
2148
|
return {
|
|
2093
2149
|
uuid: websiteTree.uuid,
|
|
2094
2150
|
publicationDateTime: websiteTree.publicationDateTime ? new Date(websiteTree.publicationDateTime) : null,
|
|
@@ -2102,7 +2158,7 @@ async function parseWebsite(websiteTree, projectName, website) {
|
|
|
2102
2158
|
) : [],
|
|
2103
2159
|
license: parseLicense(websiteTree.availability),
|
|
2104
2160
|
pages,
|
|
2105
|
-
|
|
2161
|
+
sidebar,
|
|
2106
2162
|
properties
|
|
2107
2163
|
};
|
|
2108
2164
|
}
|
package/dist/index.d.cts
CHANGED
|
@@ -409,7 +409,11 @@ type Website = {
|
|
|
409
409
|
creators: Array<Person>;
|
|
410
410
|
license: License | null;
|
|
411
411
|
pages: Array<Webpage>;
|
|
412
|
-
|
|
412
|
+
sidebar: {
|
|
413
|
+
elements: Array<WebElement>;
|
|
414
|
+
title: WebElement["title"];
|
|
415
|
+
cssStyles: Array<Style>;
|
|
416
|
+
} | null;
|
|
413
417
|
properties: WebsiteProperties;
|
|
414
418
|
};
|
|
415
419
|
/**
|
package/dist/index.d.ts
CHANGED
|
@@ -409,7 +409,11 @@ type Website = {
|
|
|
409
409
|
creators: Array<Person>;
|
|
410
410
|
license: License | null;
|
|
411
411
|
pages: Array<Webpage>;
|
|
412
|
-
|
|
412
|
+
sidebar: {
|
|
413
|
+
elements: Array<WebElement>;
|
|
414
|
+
title: WebElement["title"];
|
|
415
|
+
cssStyles: Array<Style>;
|
|
416
|
+
} | null;
|
|
413
417
|
properties: WebsiteProperties;
|
|
414
418
|
};
|
|
415
419
|
/**
|
package/dist/index.js
CHANGED
|
@@ -1987,8 +1987,20 @@ async function parseWebsite(websiteTree, projectName, website) {
|
|
|
1987
1987
|
}
|
|
1988
1988
|
const resources = Array.isArray(websiteTree.items.resource) ? websiteTree.items.resource : [websiteTree.items.resource];
|
|
1989
1989
|
const pages = await parseWebpages(resources);
|
|
1990
|
+
let sidebar = null;
|
|
1990
1991
|
const sidebarElements = [];
|
|
1991
|
-
const
|
|
1992
|
+
const sidebarTitle = {
|
|
1993
|
+
label: "",
|
|
1994
|
+
variant: "default",
|
|
1995
|
+
properties: {
|
|
1996
|
+
isNameDisplayed: false,
|
|
1997
|
+
isDescriptionDisplayed: false,
|
|
1998
|
+
isDateDisplayed: false,
|
|
1999
|
+
isCreatorsDisplayed: false
|
|
2000
|
+
}
|
|
2001
|
+
};
|
|
2002
|
+
const sidebarCssStyles = [];
|
|
2003
|
+
const sidebarResource = resources.find((resource) => {
|
|
1992
2004
|
const resourceProperties = resource.properties ? parseProperties(
|
|
1993
2005
|
Array.isArray(resource.properties.property) ? resource.properties.property : [resource.properties.property]
|
|
1994
2006
|
) : [];
|
|
@@ -1996,8 +2008,45 @@ async function parseWebsite(websiteTree, projectName, website) {
|
|
|
1996
2008
|
(property) => property.label === "presentation" && property.values[0]?.content === "element" && property.properties[0]?.label === "component" && property.properties[0]?.values[0]?.content === "sidebar"
|
|
1997
2009
|
);
|
|
1998
2010
|
});
|
|
1999
|
-
if (
|
|
2000
|
-
|
|
2011
|
+
if (sidebarResource) {
|
|
2012
|
+
sidebarTitle.label = typeof sidebarResource.identification.label === "string" || typeof sidebarResource.identification.label === "number" || typeof sidebarResource.identification.label === "boolean" ? parseFakeString(sidebarResource.identification.label) : parseStringContent(sidebarResource.identification.label);
|
|
2013
|
+
const sidebarProperties = sidebarResource.properties ? parseProperties(
|
|
2014
|
+
Array.isArray(sidebarResource.properties.property) ? sidebarResource.properties.property : [sidebarResource.properties.property]
|
|
2015
|
+
) : [];
|
|
2016
|
+
const cssProperties = sidebarProperties.find(
|
|
2017
|
+
(property) => property.label === "presentation" && property.values[0].content === "css"
|
|
2018
|
+
)?.properties ?? [];
|
|
2019
|
+
for (const property of cssProperties) {
|
|
2020
|
+
const cssStyle = property.values[0].content;
|
|
2021
|
+
sidebarCssStyles.push({ label: property.label, value: cssStyle });
|
|
2022
|
+
}
|
|
2023
|
+
const titleProperties = sidebarProperties.find(
|
|
2024
|
+
(property) => property.label === "title"
|
|
2025
|
+
)?.properties;
|
|
2026
|
+
if (titleProperties) {
|
|
2027
|
+
const titleVariant = getPropertyValueByLabel(titleProperties, "variant");
|
|
2028
|
+
if (titleVariant) {
|
|
2029
|
+
sidebarTitle.variant = titleVariant;
|
|
2030
|
+
}
|
|
2031
|
+
const titleShow = titleProperties.filter(
|
|
2032
|
+
(property) => property.label === "display"
|
|
2033
|
+
);
|
|
2034
|
+
if (titleShow.length > 0) {
|
|
2035
|
+
sidebarTitle.properties.isNameDisplayed = titleShow.some(
|
|
2036
|
+
(property) => property.values[0].content === "name"
|
|
2037
|
+
);
|
|
2038
|
+
sidebarTitle.properties.isDescriptionDisplayed = titleShow.some(
|
|
2039
|
+
(property) => property.values[0].content === "description"
|
|
2040
|
+
);
|
|
2041
|
+
sidebarTitle.properties.isDateDisplayed = titleShow.some(
|
|
2042
|
+
(property) => property.values[0].content === "date"
|
|
2043
|
+
);
|
|
2044
|
+
sidebarTitle.properties.isCreatorsDisplayed = titleShow.some(
|
|
2045
|
+
(property) => property.values[0].content === "creators"
|
|
2046
|
+
);
|
|
2047
|
+
}
|
|
2048
|
+
}
|
|
2049
|
+
const sidebarResources = sidebarResource.resource ? Array.isArray(sidebarResource.resource) ? sidebarResource.resource : [sidebarResource.resource] : [];
|
|
2001
2050
|
for (const resource of sidebarResources) {
|
|
2002
2051
|
const sidebarResourceProperties = resource.properties ? parseProperties(
|
|
2003
2052
|
Array.isArray(resource.properties.property) ? resource.properties.property : [resource.properties.property]
|
|
@@ -2011,6 +2060,13 @@ async function parseWebsite(websiteTree, projectName, website) {
|
|
|
2011
2060
|
sidebarElements.push(element);
|
|
2012
2061
|
}
|
|
2013
2062
|
}
|
|
2063
|
+
if (sidebarElements.length > 0) {
|
|
2064
|
+
sidebar = {
|
|
2065
|
+
elements: sidebarElements,
|
|
2066
|
+
title: sidebarTitle,
|
|
2067
|
+
cssStyles: sidebarCssStyles
|
|
2068
|
+
};
|
|
2069
|
+
}
|
|
2014
2070
|
return {
|
|
2015
2071
|
uuid: websiteTree.uuid,
|
|
2016
2072
|
publicationDateTime: websiteTree.publicationDateTime ? new Date(websiteTree.publicationDateTime) : null,
|
|
@@ -2024,7 +2080,7 @@ async function parseWebsite(websiteTree, projectName, website) {
|
|
|
2024
2080
|
) : [],
|
|
2025
2081
|
license: parseLicense(websiteTree.availability),
|
|
2026
2082
|
pages,
|
|
2027
|
-
|
|
2083
|
+
sidebar,
|
|
2028
2084
|
properties
|
|
2029
2085
|
};
|
|
2030
2086
|
}
|
package/package.json
CHANGED