feat: add the switch for open graph.

This commit is contained in:
Yufan Sheng 2024-11-29 13:43:54 +08:00
parent 52dd541c5b
commit 9b64b9bc91
Signed by: syhily
GPG Key ID: 9D18A22A7DCD5A9B
2 changed files with 5 additions and 2 deletions
astro.config.ts
src/pages/images/og

View File

@ -35,6 +35,8 @@ export default defineConfig({
ARTALK_SCHEME: envField.string({ context: 'server', access: 'secret' }),
ARTALK_HOST: envField.string({ context: 'server', access: 'secret' }),
ARTALK_PORT: envField.number({ context: 'server', access: 'secret' }),
// Build the Open Graph
BUILD_OPEN_GRAPH: envField.boolean({ context: 'server', access: 'public', default: true }),
},
validateSecrets: true,
},

View File

@ -2,13 +2,14 @@ import { defaultOpenGraph, drawOpenGraph } from '@/helpers/og';
import { getPage, getPost, pages, posts } from '@/helpers/schema';
import options from '@/options';
import type { APIRoute } from 'astro';
import { BUILD_OPEN_GRAPH } from 'astro:env/server';
const fallback = async () =>
new Response(await defaultOpenGraph(), {
headers: { 'Content-Type': 'image/png' },
});
export const prerender = true;
// This endpoint can be controlled by using environment variable.
export const prerender = BUILD_OPEN_GRAPH;
export const GET: APIRoute = async ({ params }) => {
const slug = params.slug;