@digitalculture/ochre-sdk 0.2.12 → 0.3.0

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 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 sidebar = resources.find((resource) => {
2070
+ const sidebarTitle = {
2071
+ label: "title",
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,8 @@ 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 (sidebar) {
2078
- const sidebarResources = sidebar.resource ? Array.isArray(sidebar.resource) ? sidebar.resource : [sidebar.resource] : [];
2089
+ if (sidebarResource) {
2090
+ const sidebarResources = sidebarResource.resource ? Array.isArray(sidebarResource.resource) ? sidebarResource.resource : [sidebarResource.resource] : [];
2079
2091
  for (const resource of sidebarResources) {
2080
2092
  const sidebarResourceProperties = resource.properties ? parseProperties(
2081
2093
  Array.isArray(resource.properties.property) ? resource.properties.property : [resource.properties.property]
@@ -2087,8 +2099,51 @@ async function parseWebsite(websiteTree, projectName, website) {
2087
2099
  )?.properties ?? []
2088
2100
  );
2089
2101
  sidebarElements.push(element);
2102
+ const cssProperties = sidebarResourceProperties.find(
2103
+ (property) => property.label === "presentation" && property.values[0].content === "css"
2104
+ )?.properties ?? [];
2105
+ for (const property of cssProperties) {
2106
+ const cssStyle = property.values[0].content;
2107
+ sidebarCssStyles.push({ label: property.label, value: cssStyle });
2108
+ }
2109
+ const titleProperties = sidebarResourceProperties.find(
2110
+ (property) => property.label === "title"
2111
+ )?.properties;
2112
+ if (titleProperties) {
2113
+ const titleVariant = getPropertyValueByLabel(
2114
+ titleProperties,
2115
+ "variant"
2116
+ );
2117
+ if (titleVariant) {
2118
+ sidebarTitle.variant = titleVariant;
2119
+ }
2120
+ const titleShow = titleProperties.filter(
2121
+ (property) => property.label === "display"
2122
+ );
2123
+ if (titleShow.length > 0) {
2124
+ sidebarTitle.properties.isNameDisplayed = titleShow.some(
2125
+ (property) => property.values[0].content === "name"
2126
+ );
2127
+ sidebarTitle.properties.isDescriptionDisplayed = titleShow.some(
2128
+ (property) => property.values[0].content === "description"
2129
+ );
2130
+ sidebarTitle.properties.isDateDisplayed = titleShow.some(
2131
+ (property) => property.values[0].content === "date"
2132
+ );
2133
+ sidebarTitle.properties.isCreatorsDisplayed = titleShow.some(
2134
+ (property) => property.values[0].content === "creators"
2135
+ );
2136
+ }
2137
+ }
2090
2138
  }
2091
2139
  }
2140
+ if (sidebarElements.length > 0) {
2141
+ sidebar = {
2142
+ elements: sidebarElements,
2143
+ title: sidebarTitle,
2144
+ cssStyles: sidebarCssStyles
2145
+ };
2146
+ }
2092
2147
  return {
2093
2148
  uuid: websiteTree.uuid,
2094
2149
  publicationDateTime: websiteTree.publicationDateTime ? new Date(websiteTree.publicationDateTime) : null,
@@ -2102,7 +2157,7 @@ async function parseWebsite(websiteTree, projectName, website) {
2102
2157
  ) : [],
2103
2158
  license: parseLicense(websiteTree.availability),
2104
2159
  pages,
2105
- sidebarElements,
2160
+ sidebar,
2106
2161
  properties
2107
2162
  };
2108
2163
  }
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
- sidebarElements: Array<WebElement>;
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
- sidebarElements: Array<WebElement>;
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 sidebar = resources.find((resource) => {
1992
+ const sidebarTitle = {
1993
+ label: "title",
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,8 @@ 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 (sidebar) {
2000
- const sidebarResources = sidebar.resource ? Array.isArray(sidebar.resource) ? sidebar.resource : [sidebar.resource] : [];
2011
+ if (sidebarResource) {
2012
+ const sidebarResources = sidebarResource.resource ? Array.isArray(sidebarResource.resource) ? sidebarResource.resource : [sidebarResource.resource] : [];
2001
2013
  for (const resource of sidebarResources) {
2002
2014
  const sidebarResourceProperties = resource.properties ? parseProperties(
2003
2015
  Array.isArray(resource.properties.property) ? resource.properties.property : [resource.properties.property]
@@ -2009,8 +2021,51 @@ async function parseWebsite(websiteTree, projectName, website) {
2009
2021
  )?.properties ?? []
2010
2022
  );
2011
2023
  sidebarElements.push(element);
2024
+ const cssProperties = sidebarResourceProperties.find(
2025
+ (property) => property.label === "presentation" && property.values[0].content === "css"
2026
+ )?.properties ?? [];
2027
+ for (const property of cssProperties) {
2028
+ const cssStyle = property.values[0].content;
2029
+ sidebarCssStyles.push({ label: property.label, value: cssStyle });
2030
+ }
2031
+ const titleProperties = sidebarResourceProperties.find(
2032
+ (property) => property.label === "title"
2033
+ )?.properties;
2034
+ if (titleProperties) {
2035
+ const titleVariant = getPropertyValueByLabel(
2036
+ titleProperties,
2037
+ "variant"
2038
+ );
2039
+ if (titleVariant) {
2040
+ sidebarTitle.variant = titleVariant;
2041
+ }
2042
+ const titleShow = titleProperties.filter(
2043
+ (property) => property.label === "display"
2044
+ );
2045
+ if (titleShow.length > 0) {
2046
+ sidebarTitle.properties.isNameDisplayed = titleShow.some(
2047
+ (property) => property.values[0].content === "name"
2048
+ );
2049
+ sidebarTitle.properties.isDescriptionDisplayed = titleShow.some(
2050
+ (property) => property.values[0].content === "description"
2051
+ );
2052
+ sidebarTitle.properties.isDateDisplayed = titleShow.some(
2053
+ (property) => property.values[0].content === "date"
2054
+ );
2055
+ sidebarTitle.properties.isCreatorsDisplayed = titleShow.some(
2056
+ (property) => property.values[0].content === "creators"
2057
+ );
2058
+ }
2059
+ }
2012
2060
  }
2013
2061
  }
2062
+ if (sidebarElements.length > 0) {
2063
+ sidebar = {
2064
+ elements: sidebarElements,
2065
+ title: sidebarTitle,
2066
+ cssStyles: sidebarCssStyles
2067
+ };
2068
+ }
2014
2069
  return {
2015
2070
  uuid: websiteTree.uuid,
2016
2071
  publicationDateTime: websiteTree.publicationDateTime ? new Date(websiteTree.publicationDateTime) : null,
@@ -2024,7 +2079,7 @@ async function parseWebsite(websiteTree, projectName, website) {
2024
2079
  ) : [],
2025
2080
  license: parseLicense(websiteTree.availability),
2026
2081
  pages,
2027
- sidebarElements,
2082
+ sidebar,
2028
2083
  properties
2029
2084
  };
2030
2085
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@digitalculture/ochre-sdk",
3
- "version": "0.2.12",
3
+ "version": "0.3.0",
4
4
  "type": "module",
5
5
  "license": "MIT",
6
6
  "description": "Node.js library for working with OCHRE (Online Cultural and Historical Research Environment) data",