Backend of public sharing at root (#6103)
This commit is contained in:
@@ -54,6 +54,7 @@ export const renderApp = async (
|
||||
description?: string;
|
||||
canonical?: string;
|
||||
shortcutIcon?: string;
|
||||
rootShareId?: string;
|
||||
analytics?: Integration | null;
|
||||
} = {}
|
||||
) => {
|
||||
@@ -72,7 +73,7 @@ export const renderApp = async (
|
||||
const page = await readIndexFile();
|
||||
const environment = `
|
||||
<script nonce="${ctx.state.cspNonce}">
|
||||
window.env = ${JSON.stringify(presentEnv(env, options.analytics))};
|
||||
window.env = ${JSON.stringify(presentEnv(env, options))};
|
||||
</script>
|
||||
`;
|
||||
|
||||
@@ -106,7 +107,10 @@ export const renderApp = async (
|
||||
};
|
||||
|
||||
export const renderShare = async (ctx: Context, next: Next) => {
|
||||
const { shareId, documentSlug } = ctx.params;
|
||||
const rootShareId = ctx.state.rootShare?.id;
|
||||
const shareId = rootShareId ?? ctx.params.shareId;
|
||||
const documentSlug = ctx.params.documentSlug;
|
||||
|
||||
// Find the share record if publicly published so that the document title
|
||||
// can be be returned in the server-rendered HTML. This allows it to appear in
|
||||
// unfurls with more reliablity
|
||||
@@ -159,6 +163,7 @@ export const renderShare = async (ctx: Context, next: Next) => {
|
||||
? team.avatarUrl
|
||||
: undefined,
|
||||
analytics,
|
||||
rootShareId,
|
||||
canonical: share
|
||||
? `${share.canonicalUrl}${documentSlug && document ? document.url : ""}`
|
||||
: undefined,
|
||||
|
||||
Reference in New Issue
Block a user