Skip to content

Commit

Permalink
Add previewUrl to site config
Browse files Browse the repository at this point in the history
  • Loading branch information
thomasdax98 committed Jul 12, 2024
1 parent 68f7f3d commit 2f9c151
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 3 deletions.
4 changes: 2 additions & 2 deletions admin/src/App.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -65,8 +65,8 @@ export function App() {
return {
url: siteConfig.url,
preloginEnabled: siteConfig.preloginEnabled || false,
blockPreviewBaseUrl: `${config.previewUrl}/block-preview`,
sitePreviewApiUrl: `${config.previewUrl}/api/site-preview`,
blockPreviewBaseUrl: `${siteConfig.previewUrl}/block-preview`,
sitePreviewApiUrl: `${siteConfig.previewUrl}/api/site-preview`,
};
},
}}
Expand Down
2 changes: 1 addition & 1 deletion site-configs.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,4 +11,4 @@ export interface SiteConfig extends BaseSiteConfig {
}

export type PrivateSiteConfig = ExtractPrivateSiteConfig<SiteConfig>;
export type PublicSiteConfig = ExtractPublicSiteConfig<SiteConfig>;
export type PublicSiteConfig = ExtractPublicSiteConfig<SiteConfig> & { previewUrl: string };
7 changes: 7 additions & 0 deletions site-configs.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,10 @@ export type Config = Omit<SiteConfig, "domains" | "contentScope"> & {
};
};

const getUrlFromDomain = (domain: string): string => {
return domain.includes("localhost") ? `http://${domain}` : `https://${domain}`;
};

// Called by `npx @comet/cli inject-site-configs`
const getSiteConfigs = async (env: Environment): Promise<SiteConfig[]> => {
const path = `${__dirname}/site-configs`;
Expand All @@ -38,6 +42,9 @@ const getSiteConfigs = async (env: Environment): Promise<SiteConfig[]> => {
preliminary: env === "prod" ? `${domains["preliminary"]}/${language}` : undefined,
},
preloginEnabled: env === "prod" ? site.preloginEnabled : true,
public: {
previewUrl: getUrlFromDomain(domains[env] ?? ""),
}
}
})

Expand Down

0 comments on commit 2f9c151

Please sign in to comment.