ochre-sdk 1.0.56 → 1.0.57

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.
@@ -878,10 +878,22 @@ function parseWebpage(webpageResource, options, context, slugPrefix) {
878
878
  returnWebpage.properties.isSidebarDisplayed = pageReader.valueOr("sidebar-displayed", true);
879
879
  returnWebpage.properties.isBreadcrumbsDisplayed = pageReader.valueOr("breadcrumbs-displayed", false);
880
880
  returnWebpage.properties.isNavbarSearchBarDisplayed = pageReader.valueOr("navbar-search-bar-displayed", true);
881
- const redirectHref = parseWebsiteLinkTarget(pageReader.valueNode("redirect-to"), context);
882
- if (redirectHref != null) returnWebpage.properties.redirect = {
883
- href: redirectHref,
884
- isExternal: redirectHref.startsWith("http")
881
+ const redirectValue = pageReader.valueNode("redirect-to");
882
+ const redirectTarget = parseWebsiteLinkTarget(redirectValue, context);
883
+ if (redirectTarget != null) if (redirectValue?.href == null && redirectValue?.uuid != null) returnWebpage.properties.redirect = {
884
+ type: "page",
885
+ slug: redirectTarget,
886
+ uuid: redirectValue.uuid
887
+ };
888
+ else returnWebpage.properties.redirect = {
889
+ type: "url",
890
+ href: redirectTarget,
891
+ isExternal: redirectTarget.startsWith("http")
892
+ };
893
+ else if (redirectValue?.uuid != null) returnWebpage.properties.redirect = {
894
+ type: "item",
895
+ uuid: redirectValue.uuid,
896
+ pageType: "item"
885
897
  };
886
898
  }
887
899
  if (imageLink != null) returnWebpage.properties.backgroundImage = {
@@ -203,8 +203,17 @@ type Webpage<T extends LanguageCodes = LanguageCodes> = {
203
203
  isDisplayedInNavbar: boolean;
204
204
  isNavbarSearchBarDisplayed: boolean;
205
205
  redirect: {
206
+ type: "url";
206
207
  href: string;
207
208
  isExternal: boolean;
209
+ } | {
210
+ type: "page";
211
+ slug: string;
212
+ uuid: string;
213
+ } | {
214
+ type: "item";
215
+ uuid: string;
216
+ pageType: "item" | "entry";
208
217
  } | null;
209
218
  backgroundImage: WebImage<T> | null;
210
219
  sidebar: WebSidebar<T> | null;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "ochre-sdk",
3
- "version": "1.0.56",
3
+ "version": "1.0.57",
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",