@finsweet/webflow-apps-utils 1.0.32 → 1.0.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.
@@ -15,8 +15,8 @@ export declare const getPathname: (page: Page | Folder) => Promise<string>;
15
15
  /**
16
16
  * Returns a single page with all its properties.
17
17
  */
18
- export declare const getPageMetadata: (page: Page) => Promise<PageWithProps>;
18
+ export declare const getPageMetadata: (page: Page, targetUrl?: URL) => Promise<PageWithProps>;
19
19
  /**
20
20
  * Returns all pages and folders from the Webflow project.
21
21
  */
22
- export declare const getAllPages: (pagesAndFolders?: boolean, kind?: PageWithProps["kind"]) => Promise<PageWithProps[]>;
22
+ export declare const getAllPages: (pagesAndFolders?: boolean, kind?: PageWithProps["kind"], targetUrl?: URL) => Promise<PageWithProps[]>;
@@ -18,10 +18,11 @@ export const getPathname = async (page) => {
18
18
  /**
19
19
  * Returns a single page with all its properties.
20
20
  */
21
- export const getPageMetadata = async (page) => {
21
+ export const getPageMetadata = async (page, targetUrl) => {
22
22
  if (!pageStagingUrl) {
23
- const { shortName } = await webflow.getSiteInfo();
24
- pageStagingUrl = `https://${shortName}.webflow.io`;
23
+ const { domains } = await webflow.getSiteInfo();
24
+ const stagingUrl = domains.find((domain) => domain.stage === 'staging')?.url;
25
+ pageStagingUrl = targetUrl?.toString() || `https://${stagingUrl}`;
25
26
  }
26
27
  const [fullPath, parent, name, kind, isDraft, isPasswordProtected, generatedPathname] = await Promise.all([
27
28
  page?.getPublishPath(),
@@ -50,7 +51,7 @@ export const getPageMetadata = async (page) => {
50
51
  /**
51
52
  * Returns all pages and folders from the Webflow project.
52
53
  */
53
- export const getAllPages = async (pagesAndFolders, kind) => {
54
+ export const getAllPages = async (pagesAndFolders, kind, targetUrl) => {
54
55
  try {
55
56
  const allPages = await webflow?.getAllPagesAndFolders();
56
57
  const pagesWithPropsPromises = [];
@@ -58,7 +59,7 @@ export const getAllPages = async (pagesAndFolders, kind) => {
58
59
  for (const page of allPages) {
59
60
  if (page.type === 'PageFolder')
60
61
  continue;
61
- pagesWithPropsPromises.push(getPageMetadata(page));
62
+ pagesWithPropsPromises.push(getPageMetadata(page, targetUrl));
62
63
  }
63
64
  }
64
65
  const list = await Promise.all(pagesWithPropsPromises);
@@ -2,10 +2,13 @@
2
2
  * Returns a valid Webflow project staging URL.
3
3
  */
4
4
  export const getSiteStagingUrl = async (origin, stagingName) => {
5
- const { shortName } = await webflow.getSiteInfo();
5
+ const { shortName, domains } = await webflow.getSiteInfo();
6
6
  if (stagingName)
7
7
  return shortName;
8
+ const stagingUrl = domains.find((domain) => domain.stage === 'staging')?.url;
8
9
  if (origin)
9
- return `${shortName}.webflow.io`;
10
+ return stagingUrl || `${shortName}.webflow.io`;
11
+ if (stagingUrl)
12
+ return `https://${stagingUrl}`;
10
13
  return `https://${shortName}.webflow.io`;
11
14
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@finsweet/webflow-apps-utils",
3
- "version": "1.0.32",
3
+ "version": "1.0.33",
4
4
  "description": "Shared utilities for Webflow apps",
5
5
  "homepage": "https://github.com/finsweet/webflow-apps-utils",
6
6
  "repository": {