feat: add the switch for open graph.
This commit is contained in:
parent
52dd541c5b
commit
f5b7a825c8
@ -17,3 +17,6 @@ POSTGRES_DATABASE=
|
|||||||
ARTALK_SCHEME=
|
ARTALK_SCHEME=
|
||||||
ARTALK_HOST=
|
ARTALK_HOST=
|
||||||
ARTALK_PORT=
|
ARTALK_PORT=
|
||||||
|
|
||||||
|
# Open Graph Switch
|
||||||
|
BUILD_OPEN_GRAPH=true
|
||||||
|
@ -46,6 +46,9 @@ npm update
|
|||||||
|
|
||||||
# Start local development with a live preview. The weblog is hosted on http://localhost:4321
|
# Start local development with a live preview. The weblog is hosted on http://localhost:4321
|
||||||
npm run dev
|
npm run dev
|
||||||
|
|
||||||
|
# Build the project
|
||||||
|
BUILD_OPEN_GRAPH=true npm run build
|
||||||
```
|
```
|
||||||
|
|
||||||
### Postgres Database
|
### Postgres Database
|
||||||
@ -193,7 +196,7 @@ to get it worked everywhere.
|
|||||||
This weblog is deployed on the [zeabur](https://zeabur.com) platform.
|
This weblog is deployed on the [zeabur](https://zeabur.com) platform.
|
||||||
You can check their documents and get your own weblog to be published without any budget at first.
|
You can check their documents and get your own weblog to be published without any budget at first.
|
||||||
|
|
||||||
Or you can host on your own machine. Use [Dockerfile](./Dockerfile) to build an image and run it locally.
|
Or you can host on your own machine. Use [Dockerfile](./docs/Dockerfile) to build an image and run it locally.
|
||||||
|
|
||||||
The comment system is leverage the [Artalk](https://artalk.js.org), a self-hosted comment system.
|
The comment system is leverage the [Artalk](https://artalk.js.org), a self-hosted comment system.
|
||||||
You should host it on your own machine.
|
You should host it on your own machine.
|
||||||
|
@ -35,6 +35,8 @@ export default defineConfig({
|
|||||||
ARTALK_SCHEME: envField.string({ context: 'server', access: 'secret' }),
|
ARTALK_SCHEME: envField.string({ context: 'server', access: 'secret' }),
|
||||||
ARTALK_HOST: envField.string({ context: 'server', access: 'secret' }),
|
ARTALK_HOST: envField.string({ context: 'server', access: 'secret' }),
|
||||||
ARTALK_PORT: envField.number({ 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,
|
validateSecrets: true,
|
||||||
},
|
},
|
||||||
|
@ -2,13 +2,13 @@ import { defaultOpenGraph, drawOpenGraph } from '@/helpers/og';
|
|||||||
import { getPage, getPost, pages, posts } from '@/helpers/schema';
|
import { getPage, getPost, pages, posts } from '@/helpers/schema';
|
||||||
import options from '@/options';
|
import options from '@/options';
|
||||||
import type { APIRoute } from 'astro';
|
import type { APIRoute } from 'astro';
|
||||||
|
|
||||||
const fallback = async () =>
|
const fallback = async () =>
|
||||||
new Response(await defaultOpenGraph(), {
|
new Response(await defaultOpenGraph(), {
|
||||||
headers: { 'Content-Type': 'image/png' },
|
headers: { 'Content-Type': 'image/png' },
|
||||||
});
|
});
|
||||||
|
|
||||||
export const prerender = true;
|
// This endpoint can be controlled by using environment variable.
|
||||||
|
export const prerender = import.meta.env.BUILD_OPEN_GRAPH;
|
||||||
|
|
||||||
export const GET: APIRoute = async ({ params }) => {
|
export const GET: APIRoute = async ({ params }) => {
|
||||||
const slug = params.slug;
|
const slug = params.slug;
|
||||||
|
Loading…
Reference in New Issue
Block a user