Introduce short share urls
This commit is contained in:
parent
34bc5855ec
commit
d4d63cf5d1
@ -110,6 +110,7 @@ Application behavior can be changed by configuring the following environment var
|
||||
- `NEXT_PUBLIC_NAV_TITLE` (defaults to domain when not configured)
|
||||
- `NEXT_PUBLIC_NAV_CAPTION` (seen in navigation, beneath title)
|
||||
- `NEXT_PUBLIC_PAGE_ABOUT` (seen in grid sidebar—accepts rich formatting tags: `<b>`, `<strong>`, `<i>`, `<em>`, `<u>`, `<br>`)
|
||||
- `NEXT_PUBLIC_DOMAIN_SHARE` (seen in share modals where a shorter url may be desirable)
|
||||
|
||||
#### Performance
|
||||
> ⚠️ Enabling may result in increased project usage. Static optimization [troubleshooting hints](#why-do-production-deployments-fail-when-static-optimization-is-enabled) in FAQ.
|
||||
|
||||
@ -77,15 +77,22 @@ const SITE_DOMAIN =
|
||||
VERCEL_PRODUCTION_URL ||
|
||||
VERCEL_PROJECT_URL ||
|
||||
VERCEL_DEPLOYMENT_URL;
|
||||
const SITE_DOMAIN_SHARE = process.env.NEXT_PUBLIC_DOMAIN_SHARE;
|
||||
|
||||
// Used primarily for absolute references such as OG images
|
||||
export const BASE_URL = makeUrlAbsolute((
|
||||
process.env.NODE_ENV === 'production' &&
|
||||
VERCEL_ENV !== 'preview'
|
||||
) ? SITE_DOMAIN
|
||||
: VERCEL_ENV === 'preview'
|
||||
? VERCEL_BRANCH_URL || VERCEL_DEPLOYMENT_URL
|
||||
: 'http://localhost:3000')?.toLocaleLowerCase();
|
||||
export const BASE_URL =
|
||||
makeUrlAbsolute((
|
||||
process.env.NODE_ENV === 'production' &&
|
||||
VERCEL_ENV !== 'preview'
|
||||
) ? SITE_DOMAIN
|
||||
: VERCEL_ENV === 'preview'
|
||||
? VERCEL_BRANCH_URL || VERCEL_DEPLOYMENT_URL
|
||||
: 'http://localhost:3000')?.toLocaleLowerCase();
|
||||
export const BASE_URL_SHARE =
|
||||
makeUrlAbsolute(SITE_DOMAIN_SHARE)?.toLocaleLowerCase();
|
||||
|
||||
export const getBaseUrl = (share?: boolean) =>
|
||||
share ? BASE_URL_SHARE : BASE_URL;
|
||||
|
||||
const SITE_DOMAIN_SHORT = shortenUrl(SITE_DOMAIN);
|
||||
|
||||
@ -400,6 +407,7 @@ export const APP_CONFIGURATION = {
|
||||
isAdminSqlDebugEnabled: ADMIN_SQL_DEBUG_ENABLED,
|
||||
// Misc
|
||||
baseUrl: BASE_URL,
|
||||
baseUrlShare: BASE_URL_SHARE,
|
||||
commitSha: VERCEL_GIT_COMMIT_SHA_SHORT,
|
||||
commitMessage: VERCEL_GIT_COMMIT_MESSAGE,
|
||||
commitUrl: VERCEL_GIT_COMMIT_URL,
|
||||
|
||||
@ -1,6 +1,6 @@
|
||||
import { Photo } from '@/photo';
|
||||
import { PhotoSetCategory } from '@/category';
|
||||
import { BASE_URL, GRID_HOMEPAGE_ENABLED } from './config';
|
||||
import { getBaseUrl, GRID_HOMEPAGE_ENABLED } from './config';
|
||||
import { Camera } from '@/camera';
|
||||
import { parameterize } from '@/utility/string';
|
||||
import { TAG_HIDDEN } from '@/tag';
|
||||
@ -167,28 +167,32 @@ export const pathForRecipe = (recipe: string) =>
|
||||
`${PREFIX_RECIPE}/${recipe}`;
|
||||
|
||||
// Absolute paths
|
||||
export const ABSOLUTE_PATH_FOR_HOME_IMAGE = `${BASE_URL}/home-image`;
|
||||
export const ABSOLUTE_PATH_FOR_HOME_IMAGE =
|
||||
`${getBaseUrl()}/home-image`;
|
||||
|
||||
export const absolutePathForPhoto = (params: PhotoPathParams) =>
|
||||
`${BASE_URL}${pathForPhoto(params)}`;
|
||||
export const absolutePathForPhoto = (
|
||||
params: PhotoPathParams,
|
||||
share?: boolean,
|
||||
) =>
|
||||
`${getBaseUrl(share)}${pathForPhoto(params)}`;
|
||||
|
||||
export const absolutePathForTag = (tag: string) =>
|
||||
`${BASE_URL}${pathForTag(tag)}`;
|
||||
export const absolutePathForTag = (tag: string, share?: boolean) =>
|
||||
`${getBaseUrl(share)}${pathForTag(tag)}`;
|
||||
|
||||
export const absolutePathForCamera= (camera: Camera) =>
|
||||
`${BASE_URL}${pathForCamera(camera)}`;
|
||||
export const absolutePathForCamera= (camera: Camera, share?: boolean) =>
|
||||
`${getBaseUrl(share)}${pathForCamera(camera)}`;
|
||||
|
||||
export const absolutePathForLens= (lens: Lens) =>
|
||||
`${BASE_URL}${pathForLens(lens)}`;
|
||||
export const absolutePathForLens= (lens: Lens, share?: boolean) =>
|
||||
`${getBaseUrl(share)}${pathForLens(lens)}`;
|
||||
|
||||
export const absolutePathForFilm = (film: string) =>
|
||||
`${BASE_URL}${pathForFilm(film)}`;
|
||||
export const absolutePathForFilm = (film: string, share?: boolean) =>
|
||||
`${getBaseUrl(share)}${pathForFilm(film)}`;
|
||||
|
||||
export const absolutePathForRecipe = (recipe: string) =>
|
||||
`${BASE_URL}${pathForRecipe(recipe)}`;
|
||||
export const absolutePathForRecipe = (recipe: string, share?: boolean) =>
|
||||
`${getBaseUrl(share)}${pathForRecipe(recipe)}`;
|
||||
|
||||
export const absolutePathForFocalLength = (focal: number) =>
|
||||
`${BASE_URL}${pathForFocalLength(focal)}`;
|
||||
export const absolutePathForFocalLength = (focal: number, share?: boolean) =>
|
||||
`${getBaseUrl(share)}${pathForFocalLength(focal)}`;
|
||||
|
||||
export const absolutePathForPhotoImage = (photo: PhotoOrPhotoId) =>
|
||||
`${absolutePathForPhoto({ photo })}/image`;
|
||||
|
||||
@ -15,7 +15,7 @@ export default function CameraShareModal({
|
||||
} & PhotoSetAttributes) {
|
||||
return (
|
||||
<ShareModal
|
||||
pathShare={absolutePathForCamera(camera)}
|
||||
pathShare={absolutePathForCamera(camera, true)}
|
||||
navigatorTitle={formatCameraText(camera)}
|
||||
socialText={shareTextForCamera(camera, photos)}
|
||||
>
|
||||
|
||||
@ -14,7 +14,7 @@ export default function FilmShareModal({
|
||||
} & PhotoSetAttributes) {
|
||||
return (
|
||||
<ShareModal
|
||||
pathShare={absolutePathForFilm(film)}
|
||||
pathShare={absolutePathForFilm(film, true)}
|
||||
navigatorTitle={labelForFilm(film).large}
|
||||
socialText={shareTextForFilm(film)}
|
||||
>
|
||||
|
||||
@ -14,7 +14,7 @@ export default function FocalLengthShareModal({
|
||||
} & PhotoSetAttributes) {
|
||||
return (
|
||||
<ShareModal
|
||||
pathShare={absolutePathForFocalLength(focal)}
|
||||
pathShare={absolutePathForFocalLength(focal, true)}
|
||||
navigatorTitle={formatFocalLengthSafe(focal)}
|
||||
socialText={shareTextFocalLength(focal)}
|
||||
>
|
||||
|
||||
@ -15,7 +15,7 @@ export default function LensShareModal({
|
||||
} & PhotoSetAttributes) {
|
||||
return (
|
||||
<ShareModal
|
||||
pathShare={absolutePathForLens(lens)}
|
||||
pathShare={absolutePathForLens(lens, true)}
|
||||
navigatorTitle={formatLensText(lens)}
|
||||
socialText={shareTextForLens(lens, photos)}
|
||||
>
|
||||
|
||||
@ -9,7 +9,7 @@ export default function PhotoShareModal(
|
||||
) {
|
||||
return (
|
||||
<ShareModal
|
||||
pathShare={absolutePathForPhoto(props)}
|
||||
pathShare={absolutePathForPhoto(props, true)}
|
||||
navigatorTitle={titleForPhoto(props.photo)}
|
||||
socialText="Check out this photo"
|
||||
>
|
||||
|
||||
@ -14,7 +14,7 @@ export default function RecipeShareModal({
|
||||
} & PhotoSetAttributes) {
|
||||
return (
|
||||
<ShareModal
|
||||
pathShare={absolutePathForRecipe(recipe)}
|
||||
pathShare={absolutePathForRecipe(recipe, true)}
|
||||
navigatorTitle={formatRecipe(recipe)}
|
||||
socialText={shareTextForRecipe(recipe)}
|
||||
>
|
||||
|
||||
@ -14,7 +14,7 @@ export default function TagShareModal({
|
||||
} & PhotoSetAttributes) {
|
||||
return (
|
||||
<ShareModal
|
||||
pathShare={absolutePathForTag(tag)}
|
||||
pathShare={absolutePathForTag(tag, true)}
|
||||
navigatorTitle={formatTag(tag)}
|
||||
socialText={shareTextForTag(tag)}
|
||||
>
|
||||
|
||||
Loading…
Reference in New Issue
Block a user