computer-scienceangular-roadmapbackend-roadmapblockchain-roadmapdba-roadmapdeveloper-roadmapdevops-roadmapfrontend-roadmapgo-roadmaphactoberfestjava-roadmapjavascript-roadmapnodejs-roadmappython-roadmapqa-roadmapreact-roadmaproadmapstudy-planvue-roadmapweb3-roadmap
You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
26 lines
957 B
26 lines
957 B
type RoadmapOpenGraphQuery = { |
|
group: 'roadmap' | 'guide' | 'best-practice'; |
|
resourceId: string; |
|
}; |
|
|
|
export function getOpenGraphImageUrl(params: RoadmapOpenGraphQuery) { |
|
return `${import.meta.env.DEV ? 'http://localhost:3000' : 'https://roadmap.sh'}/og/${params.group}/${params.resourceId}`; |
|
} |
|
|
|
export async function getDefaultOpenGraphImageBuffer() { |
|
const defaultImageUrl = `${import.meta.env.DEV ? 'http://localhost:3000' : 'https://roadmap.sh'}/images/og-img.png`; |
|
return fetch(defaultImageUrl).then((response) => response.arrayBuffer()); |
|
} |
|
|
|
export async function getResourceOpenGraph( |
|
type: 'roadmap' | 'guide' | 'best-practice', |
|
resourceId: string, |
|
) { |
|
const url = new URL(`${import.meta.env.PUBLIC_API_URL}/v1-open-graph`); |
|
url.searchParams.set('type', type); |
|
url.searchParams.set('resourceId', resourceId); |
|
url.searchParams.set('variant', 'image'); |
|
const response = await fetch(url.toString()); |
|
|
|
return response.text(); |
|
}
|
|
|