mirror of
https://github.com/GoogleChromeLabs/squoosh.git
synced 2025-11-11 16:26:20 +00:00
Include site origin in build
This commit is contained in:
@@ -6,9 +6,9 @@
|
||||
"scripts": {
|
||||
"build": "rollup -c && node lib/move-output.js",
|
||||
"debug": "node --inspect-brk node_modules/.bin/rollup -c",
|
||||
"dev": "run-p watch serve",
|
||||
"dev": "DEV_PORT=\"${DEV_PORT:=5000}\" run-p watch serve",
|
||||
"watch": "rollup -cw",
|
||||
"serve": "serve --config ../../../serve.json .tmp/build/static"
|
||||
"serve": "serve --listen=$DEV_PORT --config ../../../serve.json .tmp/build/static"
|
||||
},
|
||||
"devDependencies": {
|
||||
"@rollup/plugin-commonjs": "^17.0.0",
|
||||
|
||||
@@ -17,7 +17,7 @@ import initialCss from 'initial-css:';
|
||||
import { allSrc } from 'client-bundle:client/initial-app';
|
||||
import favicon from 'url:static-build/assets/favicon.ico';
|
||||
import ogImage from 'url:static-build/assets/icon-large-maskable.png';
|
||||
import { escapeStyleScriptContent } from 'static-build/utils';
|
||||
import { escapeStyleScriptContent, siteOrigin } from 'static-build/utils';
|
||||
import Intro from 'shared/prerendered-app/Intro';
|
||||
|
||||
interface Props {}
|
||||
@@ -34,8 +34,11 @@ const Index: FunctionalComponent<Props> = () => (
|
||||
<meta name="twitter:site" content="@SquooshApp" />
|
||||
<meta property="og:title" content="Squoosh" />
|
||||
<meta property="og:type" content="website" />
|
||||
<meta property="og:image" content={ogImage} />
|
||||
<meta property="og:image:secure_url" content={ogImage} />
|
||||
<meta property="og:image" content={`${siteOrigin}${ogImage}`} />
|
||||
<meta
|
||||
property="og:image:secure_url"
|
||||
content={`${siteOrigin}${ogImage}`}
|
||||
/>
|
||||
<meta property="og:image:type" content="image/png" />
|
||||
<meta property="og:image:width" content="500" />
|
||||
<meta property="og:image:height" content="500" />
|
||||
|
||||
@@ -56,3 +56,17 @@ export function escapeStyleScriptContent(str: string): string {
|
||||
.replace(/<style/g, '<\\style')
|
||||
.replace(/<\/style/g, '<\\/style');
|
||||
}
|
||||
|
||||
/**
|
||||
* Origin of the site, depending on the environment.
|
||||
*/
|
||||
export const siteOrigin = (() => {
|
||||
if (process.env.DEV_PORT) return `http://localhost:${process.env.DEV_PORT}`;
|
||||
// https://docs.netlify.com/configure-builds/environment-variables/#build-metadata
|
||||
if (process.env.CONTEXT === 'production') return 'https://squoosh.app';
|
||||
if (process.env.DEPLOY_PRIME_URL) return process.env.DEPLOY_PRIME_URL;
|
||||
console.warn(
|
||||
'Unable to determine site origin, defaulting to https://squoosh.app',
|
||||
);
|
||||
return 'https://squoosh.app';
|
||||
})();
|
||||
|
||||
Reference in New Issue
Block a user