diff --git a/app/server/lib/sendAppPage.ts b/app/server/lib/sendAppPage.ts index 38f3dcb5e9c..23496dd4159 100644 --- a/app/server/lib/sendAppPage.ts +++ b/app/server/lib/sendAppPage.ts @@ -157,8 +157,8 @@ export function makeSendAppPage({ server, staticDir, tag, testLogin, baseDomain const staticTag = options.tag || tag; // If boot tag is used, serve assets locally, otherwise respect // APP_STATIC_URL. - const staticOrigin = staticTag === 'boot' ? '' : (process.env.APP_STATIC_URL || ''); - const staticBaseUrl = `${staticOrigin}/v/${staticTag}/`; + const staticOrigin = staticTag === 'boot' ? '' : (process.env.APP_STATIC_URL || config.homeUrl || ''); + const staticBaseUrl = new URL(`/v/${staticTag}/`, staticOrigin).href; const customHeadHtmlSnippet = server.create.getExtraHeadHtml?.() ?? ""; const warning = testLogin ? "
Authentication is not enforced
" : ""; // Preload all languages that will be used or are requested by client. @@ -173,7 +173,7 @@ export function makeSendAppPage({ server, staticDir, tag, testLogin, baseDomain const content = fileContent .replace("", warning) .replace("", getPageTitle(req, config)) - .replace("", getPageMetadataHtmlSnippet(config)) + .replace("", getPageMetadataHtmlSnippet(req, config, staticBaseUrl)) .replace("", getPageTitleSuffix(server.getGristConfig())) .replace("", `` + tagManagerSnippet) .replace("", preloads) @@ -284,25 +284,21 @@ function getPageTitle(req: express.Request, config: GristLoadConfig): string { * * Note: The string returned is escaped and safe to insert into HTML. */ -function getPageMetadataHtmlSnippet(config: GristLoadConfig): string { +function getPageMetadataHtmlSnippet(req: express.Request, config: GristLoadConfig, staticBaseUrl: string): string { const metadataElements: string[] = []; const maybeDoc = getDocFromConfig(config); - const description = maybeDoc?.options?.description; - if (description) { - const content = handlebars.Utils.escapeExpression(description); - metadataElements.push(``); - metadataElements.push(``); - metadataElements.push(``); - } + const description = maybeDoc?.options?.description ?? String(translate(req, 'gristMetaDescription')); + const escapedDescription = handlebars.Utils.escapeExpression(description); + metadataElements.push(``); + metadataElements.push(``); + metadataElements.push(``); - const icon = maybeDoc?.options?.icon; - if (icon) { - const content = handlebars.Utils.escapeExpression(icon); - metadataElements.push(``); - metadataElements.push(``); - metadataElements.push(``); - } + const icon = maybeDoc?.options?.icon ?? new URL('/img/logo-grist.png', staticBaseUrl).href; + const escapedIcon = handlebars.Utils.escapeExpression(icon); + metadataElements.push(``); + metadataElements.push(``); + metadataElements.push(``); return metadataElements.join('\n'); } diff --git a/static/locales/en.server.json b/static/locales/en.server.json index 3023c47ad28..dafb0a347e0 100644 --- a/static/locales/en.server.json +++ b/static/locales/en.server.json @@ -1,6 +1,7 @@ { "sendAppPage": { - "Loading": "Loading" + "Loading": "Loading", + "gristMetaDescription": "Grist is the evolution of spreadsheets." }, "oidc": { "emailNotVerifiedError": "Please verify your email with the identity provider, and log in again."