-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: adds generated open graph image to stop place
- Loading branch information
Showing
13 changed files
with
480 additions
and
32 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Binary file not shown.
Binary file not shown.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
import { mapboxData } from '@atb/modules/org-data'; | ||
import { Position } from './types'; | ||
import { | ||
ZOOM_LEVEL, | ||
defaultPosition, | ||
getMapBounds, | ||
hasInitialPosition, | ||
hasMapLegs, | ||
} from './utils'; | ||
|
||
export type StaticMapProps = { | ||
layer?: 'address' | 'venue'; | ||
position: Position; | ||
initialZoom?: number; | ||
size: { width: number; height: number }; | ||
}; | ||
|
||
export function getStaticMapUrl(props: StaticMapProps) { | ||
const mapLegs = hasMapLegs(props) ? props.mapLegs : undefined; | ||
const { position, initialZoom = ZOOM_LEVEL } = hasInitialPosition(props) | ||
? props | ||
: { position: defaultPosition, initialZoom: ZOOM_LEVEL }; | ||
const bounds = mapLegs ? getMapBounds(mapLegs) : undefined; | ||
|
||
const params = bounds | ||
? `${bounds}` | ||
: `${position.lon},${position.lat},${initialZoom}`; | ||
|
||
return `https://api.mapbox.com/styles/v1/${mapboxData.styleAndId}/static/${params}/${props.size.width}x${props.size.height}?access_token=${mapboxData.accessToken}`; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
import { getOrgData } from '@atb/modules/org-data'; | ||
import Head from 'next/head'; | ||
import { useRouter } from 'next/router'; | ||
|
||
const { | ||
urls: { | ||
sitemapUrls: { prod }, | ||
}, | ||
} = getOrgData(); | ||
|
||
export type OpenGraphImageProps = { | ||
image: string; | ||
}; | ||
export function OpenGraphImage({ image }: OpenGraphImageProps) { | ||
return ( | ||
<Head> | ||
<meta property="og:image" content={`${prod}${image}`} /> | ||
</Head> | ||
); | ||
} | ||
|
||
export type OpenGraphBaseProps = { | ||
title: string; | ||
}; | ||
export function OpenGraphBase({ title }: OpenGraphBaseProps) { | ||
const { asPath } = useRouter(); | ||
|
||
return ( | ||
<Head> | ||
<meta property="og:title" content={title} /> | ||
<meta property="og:type" content="website" /> | ||
<meta property="og:url" content={`${prod}${asPath.slice(1)}`} /> | ||
</Head> | ||
); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.