@digitalculture/ochre-sdk 0.3.8 → 0.4.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 CHANGED
@@ -1329,20 +1329,34 @@ var parseWebpageResources = async (webpageResources, type) => {
1329
1329
  (property) => property.label === "presentation" && property.values[0].content === type
1330
1330
  );
1331
1331
  if (!resourceProperty) continue;
1332
- if (type === "element") {
1333
- const element = await parseWebElement(
1334
- resource,
1335
- resourceProperty.properties
1336
- );
1337
- returnElements.push(
1338
- element
1339
- );
1340
- } else {
1341
- const webpage = await parseWebpage(resource);
1342
- if (webpage) {
1332
+ switch (type) {
1333
+ case "element": {
1334
+ const element = await parseWebElement(
1335
+ resource,
1336
+ resourceProperty.properties
1337
+ );
1343
1338
  returnElements.push(
1344
- webpage
1339
+ element
1345
1340
  );
1341
+ break;
1342
+ }
1343
+ case "page": {
1344
+ const webpage = await parseWebpage(resource);
1345
+ if (webpage) {
1346
+ returnElements.push(
1347
+ webpage
1348
+ );
1349
+ }
1350
+ break;
1351
+ }
1352
+ case "block": {
1353
+ const block = await parseBlock(resource);
1354
+ if (block) {
1355
+ returnElements.push(
1356
+ block
1357
+ );
1358
+ }
1359
+ break;
1346
1360
  }
1347
1361
  }
1348
1362
  }
@@ -1438,6 +1452,13 @@ async function parseWebElementProperties(componentProperty, elementResource) {
1438
1452
  break;
1439
1453
  }
1440
1454
  case "button": {
1455
+ let variant = getPropertyValueByLabel(
1456
+ componentProperty.properties,
1457
+ "variant"
1458
+ );
1459
+ if (variant === null) {
1460
+ variant = "default";
1461
+ }
1441
1462
  let isExternal = false;
1442
1463
  let href = getPropertyValueByLabel(
1443
1464
  componentProperty.properties,
@@ -1453,6 +1474,7 @@ async function parseWebElementProperties(componentProperty, elementResource) {
1453
1474
  isExternal = true;
1454
1475
  }
1455
1476
  }
1477
+ properties.variant = variant;
1456
1478
  properties.href = href;
1457
1479
  properties.isExternal = isExternal;
1458
1480
  properties.label = ["string", "number", "boolean"].includes(
@@ -1878,10 +1900,33 @@ async function parseWebpage(webpageResource) {
1878
1900
  const imageLink = links.find(
1879
1901
  (link) => link.type === "image" || link.type === "IIIF"
1880
1902
  );
1881
- const elements = webpageResource.resource ? await parseWebpageResources(
1903
+ const blocks = webpageResource.resource ? await parseWebpageResources(
1882
1904
  Array.isArray(webpageResource.resource) ? webpageResource.resource : [webpageResource.resource],
1883
- "element"
1905
+ "block"
1884
1906
  ) : [];
1907
+ if (blocks.length === 0) {
1908
+ const defaultBlock = {
1909
+ uuid: webpageResource.uuid,
1910
+ layout: "vertical",
1911
+ blocks: [],
1912
+ elements: [],
1913
+ properties: {
1914
+ spacing: "auto",
1915
+ gap: "none",
1916
+ alignItems: "stretch",
1917
+ justifyContent: "stretch"
1918
+ },
1919
+ cssStyles: []
1920
+ };
1921
+ blocks.push(defaultBlock);
1922
+ const elements = webpageResource.resource ? await parseWebpageResources(
1923
+ Array.isArray(webpageResource.resource) ? webpageResource.resource : [webpageResource.resource],
1924
+ "element"
1925
+ ) : [];
1926
+ if (elements.length > 0) {
1927
+ defaultBlock.elements = elements;
1928
+ }
1929
+ }
1885
1930
  const webpages = webpageResource.resource ? await parseWebpageResources(
1886
1931
  Array.isArray(webpageResource.resource) ? webpageResource.resource : [webpageResource.resource],
1887
1932
  "page"
@@ -1934,7 +1979,7 @@ async function parseWebpage(webpageResource) {
1934
1979
  return {
1935
1980
  title: identification.label,
1936
1981
  slug,
1937
- elements,
1982
+ blocks,
1938
1983
  properties: {
1939
1984
  displayedInHeader,
1940
1985
  width,
@@ -1957,6 +2002,85 @@ async function parseWebpages(webpageResources) {
1957
2002
  }
1958
2003
  return returnPages;
1959
2004
  }
2005
+ async function parseBlock(blockResource) {
2006
+ const returnBlock = {
2007
+ uuid: blockResource.uuid,
2008
+ layout: "vertical",
2009
+ blocks: [],
2010
+ elements: [],
2011
+ properties: {
2012
+ spacing: "auto",
2013
+ gap: "none",
2014
+ alignItems: "stretch",
2015
+ justifyContent: "stretch"
2016
+ },
2017
+ cssStyles: []
2018
+ };
2019
+ const blockProperties = blockResource.properties ? parseProperties(
2020
+ Array.isArray(blockResource.properties.property) ? blockResource.properties.property : [blockResource.properties.property]
2021
+ ) : [];
2022
+ const blockMainProperties = blockProperties.find(
2023
+ (property) => property.label === "presentation" && property.values[0]?.content === "block"
2024
+ )?.properties;
2025
+ if (blockMainProperties) {
2026
+ const layoutProperty = blockMainProperties.find(
2027
+ (property) => property.label === "layout"
2028
+ )?.values[0];
2029
+ if (layoutProperty) {
2030
+ returnBlock.layout = layoutProperty.content;
2031
+ }
2032
+ const spacingProperty = blockMainProperties.find(
2033
+ (property) => property.label === "spacing"
2034
+ )?.values[0];
2035
+ if (spacingProperty) {
2036
+ returnBlock.properties.spacing = spacingProperty.content;
2037
+ }
2038
+ const gapProperty = blockMainProperties.find(
2039
+ (property) => property.label === "gap"
2040
+ )?.values[0];
2041
+ if (gapProperty) {
2042
+ returnBlock.properties.gap = gapProperty.content;
2043
+ }
2044
+ const alignItemsProperty = blockMainProperties.find(
2045
+ (property) => property.label === "align-items"
2046
+ )?.values[0];
2047
+ if (alignItemsProperty) {
2048
+ returnBlock.properties.alignItems = alignItemsProperty.content;
2049
+ }
2050
+ const justifyContentProperty = blockMainProperties.find(
2051
+ (property) => property.label === "justify-content"
2052
+ )?.values[0];
2053
+ if (justifyContentProperty) {
2054
+ returnBlock.properties.justifyContent = justifyContentProperty.content;
2055
+ }
2056
+ }
2057
+ const blockBlocks = blockResource.resource ? await parseWebpageResources(
2058
+ Array.isArray(blockResource.resource) ? blockResource.resource : [blockResource.resource],
2059
+ "block"
2060
+ ) : [];
2061
+ for (const block of blockBlocks) {
2062
+ returnBlock.blocks.push(block);
2063
+ }
2064
+ const blockElements = blockResource.resource ? await parseWebpageResources(
2065
+ Array.isArray(blockResource.resource) ? blockResource.resource : [blockResource.resource],
2066
+ "element"
2067
+ ) : [];
2068
+ for (const element of blockElements) {
2069
+ returnBlock.elements.push(element);
2070
+ }
2071
+ const blockCssStyles = blockProperties.find(
2072
+ (property) => property.label === "presentation" && property.values[0]?.content === "css"
2073
+ )?.properties;
2074
+ if (blockCssStyles) {
2075
+ for (const property of blockCssStyles) {
2076
+ returnBlock.cssStyles.push({
2077
+ label: property.label,
2078
+ value: property.values[0].content
2079
+ });
2080
+ }
2081
+ }
2082
+ return returnBlock;
2083
+ }
1960
2084
  function parseWebsiteProperties(properties) {
1961
2085
  const mainProperties = parseProperties(properties);
1962
2086
  const websiteProperties = mainProperties.find(
@@ -1996,6 +2120,7 @@ function parseWebsiteProperties(properties) {
1996
2120
  let isHeaderProjectDisplayed = true;
1997
2121
  let isFooterDisplayed = true;
1998
2122
  let isSidebarDisplayed = false;
2123
+ let sidebarVariant = "default";
1999
2124
  let searchCollectionUuid = null;
2000
2125
  let supportsThemeToggle = true;
2001
2126
  const headerProperty = websiteProperties.find(
@@ -2034,6 +2159,12 @@ function parseWebsiteProperties(properties) {
2034
2159
  if (sidebarProperty) {
2035
2160
  isSidebarDisplayed = sidebarProperty.content === "Yes";
2036
2161
  }
2162
+ const sidebarVariantProperty = websiteProperties.find(
2163
+ (property) => property.label === "sidebar-variant"
2164
+ )?.values[0];
2165
+ if (sidebarVariantProperty) {
2166
+ sidebarVariant = sidebarVariantProperty.content;
2167
+ }
2037
2168
  const collectionSearchProperty = websiteProperties.find(
2038
2169
  (property) => property.label === "search-collection"
2039
2170
  )?.values[0];
@@ -2061,6 +2192,7 @@ function parseWebsiteProperties(properties) {
2061
2192
  isHeaderProjectDisplayed,
2062
2193
  isFooterDisplayed,
2063
2194
  isSidebarDisplayed,
2195
+ sidebarVariant,
2064
2196
  supportsThemeToggle,
2065
2197
  searchCollectionUuid,
2066
2198
  logoUrl: logoUuid !== null ? `https://ochre.lib.uchicago.edu/ochre?uuid=${logoUuid}&load` : null
package/dist/index.d.cts CHANGED
@@ -430,6 +430,7 @@ type WebsiteProperties = {
430
430
  isHeaderProjectDisplayed: boolean;
431
431
  isFooterDisplayed: boolean;
432
432
  isSidebarDisplayed: boolean;
433
+ sidebarVariant: "default" | "inline";
433
434
  supportsThemeToggle: boolean;
434
435
  searchCollectionUuid: string | null;
435
436
  logoUrl: string | null;
@@ -438,7 +439,7 @@ type Webpage = {
438
439
  title: string;
439
440
  slug: string;
440
441
  properties: WebpageProperties;
441
- elements: Array<WebElement>;
442
+ blocks: Array<Block>;
442
443
  webpages: Array<Webpage>;
443
444
  };
444
445
  /**
@@ -488,6 +489,7 @@ type WebElementComponent = {
488
489
  blogId: string;
489
490
  } | {
490
491
  component: "button";
492
+ variant: "default" | "transparent";
491
493
  href: string;
492
494
  isExternal: boolean;
493
495
  label: string;
@@ -570,6 +572,34 @@ type Style = {
570
572
  label: string;
571
573
  value: string;
572
574
  };
575
+ /**
576
+ * Represents a block of vertical or horizontal content alignment
577
+ */
578
+ type Block = {
579
+ uuid: string;
580
+ layout: "vertical" | "horizontal" | "grid";
581
+ blocks: Array<Block>;
582
+ elements: Array<WebElement>;
583
+ properties: {
584
+ /**
585
+ * valid `gridTemplateColumns` or `gridTemplateRows` CSS property value
586
+ */
587
+ spacing: string;
588
+ /**
589
+ * `gap` CSS property value
590
+ */
591
+ gap: "none" | "small" | "medium" | "large";
592
+ /**
593
+ * `align-items` CSS property value
594
+ */
595
+ alignItems: "stretch" | "start" | "center" | "end" | "space-between";
596
+ /**
597
+ * `justify-content` CSS property value
598
+ */
599
+ justifyContent: "stretch" | "start" | "center" | "end" | "space-between";
600
+ };
601
+ cssStyles: Array<Style>;
602
+ };
573
603
 
574
604
  /**
575
605
  * Fetches and parses a bibliography from the OCHRE API
@@ -1813,4 +1843,4 @@ declare function trimEndLineBreaks(string: string): string;
1813
1843
  */
1814
1844
  declare function parseStringContent(content: OchreStringContent, language?: string): string;
1815
1845
 
1816
- export { type Bibliography, type Concept, type Context, type ContextItem, type ContextNode, type Coordinates, type Data, type Document, type Event, type Footnote, type Gallery, type Identification, type Image, type ImageMap, type ImageMapArea, type Interpretation, type License, type Link, type Metadata, type NestedConcept, type NestedResource, type NestedSpatialUnit, type Note, type Observation, type Period, type Person, type Property, type PropertyValue, type PropertyValueType, type Resource, type Set, type SpatialUnit, type Style, type Tree, type WebElement, type WebElementComponent, type WebImage, type Webpage, type WebpageProperties, type Website, type WebsiteProperties, fetchBibliography, fetchByUuid, fetchConcept, fetchGallery, fetchPeriod, fetchResource, fetchSet, fetchSpatialUnit, fetchTree, fetchWebsite, filterProperties, getAllPropertyLabels, getPropertyByLabel, getPropertyValueByLabel, getPropertyValuesByLabel, parseBibliographies, parseBibliography, parseConcept, parseConcepts, parseContext, parseCoordinates, parseDocument, parseEmailAndUrl, parseEvents, parseFakeString, parseIdentification, parseImage, parseImageMap, parseInterpretations, parseLanguages, parseLicense, parseLink, parseLinks, parseMetadata, parseNotes, parseObservation, parseObservations, parsePeriod, parsePeriods, parsePerson, parsePersons, parseProperties, parseResource, parseResources, parseSet, parseSpatialUnit, parseSpatialUnits, parseStringContent, parseStringDocumentItem, parseStringItem, parseTree, parseWebsite, trimEndLineBreaks };
1846
+ export { type Bibliography, type Block, type Concept, type Context, type ContextItem, type ContextNode, type Coordinates, type Data, type Document, type Event, type Footnote, type Gallery, type Identification, type Image, type ImageMap, type ImageMapArea, type Interpretation, type License, type Link, type Metadata, type NestedConcept, type NestedResource, type NestedSpatialUnit, type Note, type Observation, type Period, type Person, type Property, type PropertyValue, type PropertyValueType, type Resource, type Set, type SpatialUnit, type Style, type Tree, type WebElement, type WebElementComponent, type WebImage, type Webpage, type WebpageProperties, type Website, type WebsiteProperties, fetchBibliography, fetchByUuid, fetchConcept, fetchGallery, fetchPeriod, fetchResource, fetchSet, fetchSpatialUnit, fetchTree, fetchWebsite, filterProperties, getAllPropertyLabels, getPropertyByLabel, getPropertyValueByLabel, getPropertyValuesByLabel, parseBibliographies, parseBibliography, parseConcept, parseConcepts, parseContext, parseCoordinates, parseDocument, parseEmailAndUrl, parseEvents, parseFakeString, parseIdentification, parseImage, parseImageMap, parseInterpretations, parseLanguages, parseLicense, parseLink, parseLinks, parseMetadata, parseNotes, parseObservation, parseObservations, parsePeriod, parsePeriods, parsePerson, parsePersons, parseProperties, parseResource, parseResources, parseSet, parseSpatialUnit, parseSpatialUnits, parseStringContent, parseStringDocumentItem, parseStringItem, parseTree, parseWebsite, trimEndLineBreaks };
package/dist/index.d.ts CHANGED
@@ -430,6 +430,7 @@ type WebsiteProperties = {
430
430
  isHeaderProjectDisplayed: boolean;
431
431
  isFooterDisplayed: boolean;
432
432
  isSidebarDisplayed: boolean;
433
+ sidebarVariant: "default" | "inline";
433
434
  supportsThemeToggle: boolean;
434
435
  searchCollectionUuid: string | null;
435
436
  logoUrl: string | null;
@@ -438,7 +439,7 @@ type Webpage = {
438
439
  title: string;
439
440
  slug: string;
440
441
  properties: WebpageProperties;
441
- elements: Array<WebElement>;
442
+ blocks: Array<Block>;
442
443
  webpages: Array<Webpage>;
443
444
  };
444
445
  /**
@@ -488,6 +489,7 @@ type WebElementComponent = {
488
489
  blogId: string;
489
490
  } | {
490
491
  component: "button";
492
+ variant: "default" | "transparent";
491
493
  href: string;
492
494
  isExternal: boolean;
493
495
  label: string;
@@ -570,6 +572,34 @@ type Style = {
570
572
  label: string;
571
573
  value: string;
572
574
  };
575
+ /**
576
+ * Represents a block of vertical or horizontal content alignment
577
+ */
578
+ type Block = {
579
+ uuid: string;
580
+ layout: "vertical" | "horizontal" | "grid";
581
+ blocks: Array<Block>;
582
+ elements: Array<WebElement>;
583
+ properties: {
584
+ /**
585
+ * valid `gridTemplateColumns` or `gridTemplateRows` CSS property value
586
+ */
587
+ spacing: string;
588
+ /**
589
+ * `gap` CSS property value
590
+ */
591
+ gap: "none" | "small" | "medium" | "large";
592
+ /**
593
+ * `align-items` CSS property value
594
+ */
595
+ alignItems: "stretch" | "start" | "center" | "end" | "space-between";
596
+ /**
597
+ * `justify-content` CSS property value
598
+ */
599
+ justifyContent: "stretch" | "start" | "center" | "end" | "space-between";
600
+ };
601
+ cssStyles: Array<Style>;
602
+ };
573
603
 
574
604
  /**
575
605
  * Fetches and parses a bibliography from the OCHRE API
@@ -1813,4 +1843,4 @@ declare function trimEndLineBreaks(string: string): string;
1813
1843
  */
1814
1844
  declare function parseStringContent(content: OchreStringContent, language?: string): string;
1815
1845
 
1816
- export { type Bibliography, type Concept, type Context, type ContextItem, type ContextNode, type Coordinates, type Data, type Document, type Event, type Footnote, type Gallery, type Identification, type Image, type ImageMap, type ImageMapArea, type Interpretation, type License, type Link, type Metadata, type NestedConcept, type NestedResource, type NestedSpatialUnit, type Note, type Observation, type Period, type Person, type Property, type PropertyValue, type PropertyValueType, type Resource, type Set, type SpatialUnit, type Style, type Tree, type WebElement, type WebElementComponent, type WebImage, type Webpage, type WebpageProperties, type Website, type WebsiteProperties, fetchBibliography, fetchByUuid, fetchConcept, fetchGallery, fetchPeriod, fetchResource, fetchSet, fetchSpatialUnit, fetchTree, fetchWebsite, filterProperties, getAllPropertyLabels, getPropertyByLabel, getPropertyValueByLabel, getPropertyValuesByLabel, parseBibliographies, parseBibliography, parseConcept, parseConcepts, parseContext, parseCoordinates, parseDocument, parseEmailAndUrl, parseEvents, parseFakeString, parseIdentification, parseImage, parseImageMap, parseInterpretations, parseLanguages, parseLicense, parseLink, parseLinks, parseMetadata, parseNotes, parseObservation, parseObservations, parsePeriod, parsePeriods, parsePerson, parsePersons, parseProperties, parseResource, parseResources, parseSet, parseSpatialUnit, parseSpatialUnits, parseStringContent, parseStringDocumentItem, parseStringItem, parseTree, parseWebsite, trimEndLineBreaks };
1846
+ export { type Bibliography, type Block, type Concept, type Context, type ContextItem, type ContextNode, type Coordinates, type Data, type Document, type Event, type Footnote, type Gallery, type Identification, type Image, type ImageMap, type ImageMapArea, type Interpretation, type License, type Link, type Metadata, type NestedConcept, type NestedResource, type NestedSpatialUnit, type Note, type Observation, type Period, type Person, type Property, type PropertyValue, type PropertyValueType, type Resource, type Set, type SpatialUnit, type Style, type Tree, type WebElement, type WebElementComponent, type WebImage, type Webpage, type WebpageProperties, type Website, type WebsiteProperties, fetchBibliography, fetchByUuid, fetchConcept, fetchGallery, fetchPeriod, fetchResource, fetchSet, fetchSpatialUnit, fetchTree, fetchWebsite, filterProperties, getAllPropertyLabels, getPropertyByLabel, getPropertyValueByLabel, getPropertyValuesByLabel, parseBibliographies, parseBibliography, parseConcept, parseConcepts, parseContext, parseCoordinates, parseDocument, parseEmailAndUrl, parseEvents, parseFakeString, parseIdentification, parseImage, parseImageMap, parseInterpretations, parseLanguages, parseLicense, parseLink, parseLinks, parseMetadata, parseNotes, parseObservation, parseObservations, parsePeriod, parsePeriods, parsePerson, parsePersons, parseProperties, parseResource, parseResources, parseSet, parseSpatialUnit, parseSpatialUnits, parseStringContent, parseStringDocumentItem, parseStringItem, parseTree, parseWebsite, trimEndLineBreaks };
package/dist/index.js CHANGED
@@ -1251,20 +1251,34 @@ var parseWebpageResources = async (webpageResources, type) => {
1251
1251
  (property) => property.label === "presentation" && property.values[0].content === type
1252
1252
  );
1253
1253
  if (!resourceProperty) continue;
1254
- if (type === "element") {
1255
- const element = await parseWebElement(
1256
- resource,
1257
- resourceProperty.properties
1258
- );
1259
- returnElements.push(
1260
- element
1261
- );
1262
- } else {
1263
- const webpage = await parseWebpage(resource);
1264
- if (webpage) {
1254
+ switch (type) {
1255
+ case "element": {
1256
+ const element = await parseWebElement(
1257
+ resource,
1258
+ resourceProperty.properties
1259
+ );
1265
1260
  returnElements.push(
1266
- webpage
1261
+ element
1267
1262
  );
1263
+ break;
1264
+ }
1265
+ case "page": {
1266
+ const webpage = await parseWebpage(resource);
1267
+ if (webpage) {
1268
+ returnElements.push(
1269
+ webpage
1270
+ );
1271
+ }
1272
+ break;
1273
+ }
1274
+ case "block": {
1275
+ const block = await parseBlock(resource);
1276
+ if (block) {
1277
+ returnElements.push(
1278
+ block
1279
+ );
1280
+ }
1281
+ break;
1268
1282
  }
1269
1283
  }
1270
1284
  }
@@ -1360,6 +1374,13 @@ async function parseWebElementProperties(componentProperty, elementResource) {
1360
1374
  break;
1361
1375
  }
1362
1376
  case "button": {
1377
+ let variant = getPropertyValueByLabel(
1378
+ componentProperty.properties,
1379
+ "variant"
1380
+ );
1381
+ if (variant === null) {
1382
+ variant = "default";
1383
+ }
1363
1384
  let isExternal = false;
1364
1385
  let href = getPropertyValueByLabel(
1365
1386
  componentProperty.properties,
@@ -1375,6 +1396,7 @@ async function parseWebElementProperties(componentProperty, elementResource) {
1375
1396
  isExternal = true;
1376
1397
  }
1377
1398
  }
1399
+ properties.variant = variant;
1378
1400
  properties.href = href;
1379
1401
  properties.isExternal = isExternal;
1380
1402
  properties.label = ["string", "number", "boolean"].includes(
@@ -1800,10 +1822,33 @@ async function parseWebpage(webpageResource) {
1800
1822
  const imageLink = links.find(
1801
1823
  (link) => link.type === "image" || link.type === "IIIF"
1802
1824
  );
1803
- const elements = webpageResource.resource ? await parseWebpageResources(
1825
+ const blocks = webpageResource.resource ? await parseWebpageResources(
1804
1826
  Array.isArray(webpageResource.resource) ? webpageResource.resource : [webpageResource.resource],
1805
- "element"
1827
+ "block"
1806
1828
  ) : [];
1829
+ if (blocks.length === 0) {
1830
+ const defaultBlock = {
1831
+ uuid: webpageResource.uuid,
1832
+ layout: "vertical",
1833
+ blocks: [],
1834
+ elements: [],
1835
+ properties: {
1836
+ spacing: "auto",
1837
+ gap: "none",
1838
+ alignItems: "stretch",
1839
+ justifyContent: "stretch"
1840
+ },
1841
+ cssStyles: []
1842
+ };
1843
+ blocks.push(defaultBlock);
1844
+ const elements = webpageResource.resource ? await parseWebpageResources(
1845
+ Array.isArray(webpageResource.resource) ? webpageResource.resource : [webpageResource.resource],
1846
+ "element"
1847
+ ) : [];
1848
+ if (elements.length > 0) {
1849
+ defaultBlock.elements = elements;
1850
+ }
1851
+ }
1807
1852
  const webpages = webpageResource.resource ? await parseWebpageResources(
1808
1853
  Array.isArray(webpageResource.resource) ? webpageResource.resource : [webpageResource.resource],
1809
1854
  "page"
@@ -1856,7 +1901,7 @@ async function parseWebpage(webpageResource) {
1856
1901
  return {
1857
1902
  title: identification.label,
1858
1903
  slug,
1859
- elements,
1904
+ blocks,
1860
1905
  properties: {
1861
1906
  displayedInHeader,
1862
1907
  width,
@@ -1879,6 +1924,85 @@ async function parseWebpages(webpageResources) {
1879
1924
  }
1880
1925
  return returnPages;
1881
1926
  }
1927
+ async function parseBlock(blockResource) {
1928
+ const returnBlock = {
1929
+ uuid: blockResource.uuid,
1930
+ layout: "vertical",
1931
+ blocks: [],
1932
+ elements: [],
1933
+ properties: {
1934
+ spacing: "auto",
1935
+ gap: "none",
1936
+ alignItems: "stretch",
1937
+ justifyContent: "stretch"
1938
+ },
1939
+ cssStyles: []
1940
+ };
1941
+ const blockProperties = blockResource.properties ? parseProperties(
1942
+ Array.isArray(blockResource.properties.property) ? blockResource.properties.property : [blockResource.properties.property]
1943
+ ) : [];
1944
+ const blockMainProperties = blockProperties.find(
1945
+ (property) => property.label === "presentation" && property.values[0]?.content === "block"
1946
+ )?.properties;
1947
+ if (blockMainProperties) {
1948
+ const layoutProperty = blockMainProperties.find(
1949
+ (property) => property.label === "layout"
1950
+ )?.values[0];
1951
+ if (layoutProperty) {
1952
+ returnBlock.layout = layoutProperty.content;
1953
+ }
1954
+ const spacingProperty = blockMainProperties.find(
1955
+ (property) => property.label === "spacing"
1956
+ )?.values[0];
1957
+ if (spacingProperty) {
1958
+ returnBlock.properties.spacing = spacingProperty.content;
1959
+ }
1960
+ const gapProperty = blockMainProperties.find(
1961
+ (property) => property.label === "gap"
1962
+ )?.values[0];
1963
+ if (gapProperty) {
1964
+ returnBlock.properties.gap = gapProperty.content;
1965
+ }
1966
+ const alignItemsProperty = blockMainProperties.find(
1967
+ (property) => property.label === "align-items"
1968
+ )?.values[0];
1969
+ if (alignItemsProperty) {
1970
+ returnBlock.properties.alignItems = alignItemsProperty.content;
1971
+ }
1972
+ const justifyContentProperty = blockMainProperties.find(
1973
+ (property) => property.label === "justify-content"
1974
+ )?.values[0];
1975
+ if (justifyContentProperty) {
1976
+ returnBlock.properties.justifyContent = justifyContentProperty.content;
1977
+ }
1978
+ }
1979
+ const blockBlocks = blockResource.resource ? await parseWebpageResources(
1980
+ Array.isArray(blockResource.resource) ? blockResource.resource : [blockResource.resource],
1981
+ "block"
1982
+ ) : [];
1983
+ for (const block of blockBlocks) {
1984
+ returnBlock.blocks.push(block);
1985
+ }
1986
+ const blockElements = blockResource.resource ? await parseWebpageResources(
1987
+ Array.isArray(blockResource.resource) ? blockResource.resource : [blockResource.resource],
1988
+ "element"
1989
+ ) : [];
1990
+ for (const element of blockElements) {
1991
+ returnBlock.elements.push(element);
1992
+ }
1993
+ const blockCssStyles = blockProperties.find(
1994
+ (property) => property.label === "presentation" && property.values[0]?.content === "css"
1995
+ )?.properties;
1996
+ if (blockCssStyles) {
1997
+ for (const property of blockCssStyles) {
1998
+ returnBlock.cssStyles.push({
1999
+ label: property.label,
2000
+ value: property.values[0].content
2001
+ });
2002
+ }
2003
+ }
2004
+ return returnBlock;
2005
+ }
1882
2006
  function parseWebsiteProperties(properties) {
1883
2007
  const mainProperties = parseProperties(properties);
1884
2008
  const websiteProperties = mainProperties.find(
@@ -1918,6 +2042,7 @@ function parseWebsiteProperties(properties) {
1918
2042
  let isHeaderProjectDisplayed = true;
1919
2043
  let isFooterDisplayed = true;
1920
2044
  let isSidebarDisplayed = false;
2045
+ let sidebarVariant = "default";
1921
2046
  let searchCollectionUuid = null;
1922
2047
  let supportsThemeToggle = true;
1923
2048
  const headerProperty = websiteProperties.find(
@@ -1956,6 +2081,12 @@ function parseWebsiteProperties(properties) {
1956
2081
  if (sidebarProperty) {
1957
2082
  isSidebarDisplayed = sidebarProperty.content === "Yes";
1958
2083
  }
2084
+ const sidebarVariantProperty = websiteProperties.find(
2085
+ (property) => property.label === "sidebar-variant"
2086
+ )?.values[0];
2087
+ if (sidebarVariantProperty) {
2088
+ sidebarVariant = sidebarVariantProperty.content;
2089
+ }
1959
2090
  const collectionSearchProperty = websiteProperties.find(
1960
2091
  (property) => property.label === "search-collection"
1961
2092
  )?.values[0];
@@ -1983,6 +2114,7 @@ function parseWebsiteProperties(properties) {
1983
2114
  isHeaderProjectDisplayed,
1984
2115
  isFooterDisplayed,
1985
2116
  isSidebarDisplayed,
2117
+ sidebarVariant,
1986
2118
  supportsThemeToggle,
1987
2119
  searchCollectionUuid,
1988
2120
  logoUrl: logoUuid !== null ? `https://ochre.lib.uchicago.edu/ochre?uuid=${logoUuid}&load` : null
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@digitalculture/ochre-sdk",
3
- "version": "0.3.8",
3
+ "version": "0.4.1",
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",
@@ -45,13 +45,13 @@
45
45
  },
46
46
  "devDependencies": {
47
47
  "@antfu/eslint-config": "^4.3.0",
48
- "@arethetypeswrong/cli": "^0.17.3",
48
+ "@arethetypeswrong/cli": "^0.17.4",
49
49
  "@changesets/cli": "^2.28.1",
50
50
  "@total-typescript/ts-reset": "^0.6.1",
51
- "@types/node": "^22.13.4",
52
- "eslint": "^9.20.1",
51
+ "@types/node": "^22.13.5",
52
+ "eslint": "^9.21.0",
53
53
  "eslint-plugin-unused-imports": "^4.1.4",
54
- "prettier": "^3.5.1",
54
+ "prettier": "^3.5.2",
55
55
  "tsup": "^8.3.6",
56
56
  "typescript": "^5.7.3",
57
57
  "vitest": "^3.0.6"