@gatsby-cloud-pkg/gatsby-cms-extension-base
Advanced tools
Comparing version 0.0.26 to 0.0.27
@@ -1,15 +0,15 @@ | ||
export declare function getContentPath({ contentSlug, siteUrl, authToken }: { | ||
export declare function getContentPath({ contentSlug, previewUrl, authToken }: { | ||
contentSlug: any; | ||
siteUrl: any; | ||
previewUrl: any; | ||
authToken: any; | ||
}): Promise<string>; | ||
export declare function openSite({ contentSlug, siteUrl, authToken }: { | ||
export declare function openPreview({ contentSlug, previewUrl, authToken }: { | ||
contentSlug: any; | ||
siteUrl: any; | ||
previewUrl: any; | ||
authToken: any; | ||
}): Promise<Window>; | ||
export declare function ExtensionUI({ contentSlug, siteUrl, authToken }: { | ||
export declare function ExtensionUI({ contentSlug, previewUrl, authToken }: { | ||
contentSlug: any; | ||
siteUrl: any; | ||
previewUrl: any; | ||
authToken: any; | ||
}): JSX.Element; |
@@ -15,3 +15,3 @@ "use strict"; | ||
const normalize = part => part.replace(/\/$/, ``); | ||
function getContentPath({ contentSlug, siteUrl, authToken }) { | ||
function getContentPath({ contentSlug, previewUrl, authToken }) { | ||
return __awaiter(this, void 0, void 0, function* () { | ||
@@ -21,7 +21,7 @@ const entryUrl = contentSlug && contentSlug.startsWith(`/`) | ||
: contentSlug; | ||
const normalizedSiteUrl = normalize(siteUrl); | ||
const normalizedPreviewUrl = normalize(previewUrl); | ||
const pathQuery = `query getQualifiedSlug($entryUrl:String) { sitePage( path:{ ${entryUrl ? `regex` : `eq`}:$entryUrl } ) { path } }`; | ||
const pathVariables = entryUrl ? `/${entryUrl}\/?$/` : `/`; | ||
try { | ||
const res = yield fetch(`${normalizedSiteUrl}/___graphql`, { | ||
const res = yield fetch(`${normalizedPreviewUrl}/___graphql`, { | ||
method: `POST`, | ||
@@ -41,6 +41,6 @@ headers: { | ||
const path = data ? data.sitePage.path : ``; | ||
return `${normalizedSiteUrl}${path}`; | ||
return `${normalizedPreviewUrl}${path}`; | ||
} | ||
catch (e) { | ||
return `${normalizedSiteUrl}/${entryUrl}`; | ||
return `${normalizedPreviewUrl}/${entryUrl}`; | ||
} | ||
@@ -50,7 +50,7 @@ }); | ||
exports.getContentPath = getContentPath; | ||
function openSite({ contentSlug, siteUrl, authToken }) { | ||
function openPreview({ contentSlug, previewUrl, authToken }) { | ||
return __awaiter(this, void 0, void 0, function* () { | ||
const path = yield getContentPath({ | ||
contentSlug, | ||
siteUrl, | ||
previewUrl, | ||
authToken, | ||
@@ -61,3 +61,3 @@ }); | ||
} | ||
exports.openSite = openSite; | ||
exports.openPreview = openPreview; | ||
const Button = styled_1.default(`button`) ` | ||
@@ -94,9 +94,9 @@ border: 0; | ||
`; | ||
function ExtensionUI({ contentSlug, siteUrl, authToken }) { | ||
function ExtensionUI({ contentSlug, previewUrl, authToken }) { | ||
return (React.createElement("div", null, | ||
siteUrl ? (React.createElement(Button, { className: "site-button", type: "button", onClick: () => __awaiter(this, void 0, void 0, function* () { | ||
previewUrl ? (React.createElement(Button, { className: "preview-button", type: "button", onClick: () => __awaiter(this, void 0, void 0, function* () { | ||
return contentSlug | ||
? openSite({ contentSlug, siteUrl, authToken }) | ||
: window.open(siteUrl); | ||
}) }, "Open site")) : (React.createElement(Text, null, "Missing required Gatsby Cloud site url. Please check your configuration.")), | ||
? openPreview({ contentSlug, previewUrl, authToken }) | ||
: window.open(previewUrl); | ||
}) }, "Open Preview")) : (React.createElement(Text, null, "Missing required Gatsby Cloud Preview url. Please check your configuration.")), | ||
React.createElement(PoweredBy, { className: "powered-by" }, | ||
@@ -103,0 +103,0 @@ React.createElement(Text, null, "Powered by:"), |
{ | ||
"name": "@gatsby-cloud-pkg/gatsby-cms-extension-base", | ||
"version": "0.0.26", | ||
"version": "0.0.27", | ||
"description": "Common utilities for integrating Gatsby Preview with CMS providers", | ||
@@ -44,4 +44,3 @@ "main": "dist/index.js", | ||
"react": "16.8.6" | ||
}, | ||
"gitHead": "201133eaf30bbe04d5dbd48a0415b0c3ec28bb00" | ||
} | ||
} |
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
12503