Blog theme for VitePress with Tailwind CSS.
"Trigger" is a out-of-the-box VitePress theme, named after my favorite Anime "World Trigger". You can use it directly or customize it to better suit your needs.
More info about customization :
If there has any problem please feel free to create issue.
Detailed changes are documented in the CHANGELOG.
const sendErrorResponse = (message, status = 500) => { return new Response(JSON.stringify({ error: message }), { status, headers: corsHeaders }); };
export default { async fetch(request, env) { if (request.method === 'OPTIONS') { return new Response(null, { headers: corsHeaders }); }
if (request.method !== 'POST') {
return sendErrorResponse('Only POST requests are allowed', 405);
}
try {
const { message } = await request.json();
if (!message) {
return sendErrorResponse('Missing message in request body', 400);
}
const model = '@cf/meta/llama-3.1-8b-instruct';
const userID = 'YOUR_USER_ID';
const gatewayID = 'YOUR_AI_GATEWAY_NAME'
const gateway = `https://gateway.ai.cloudflare.com/v1/${userID}/{gatewayID}/workers-ai/${model}`;
const prompt = `You are a professional summarization assistant. Based on the content I provide, generate a summary no longer than 60 characters, and return only the summary—no additional text: ${message}`;
const apiResponse = await fetch(
gateway,
{
method: 'POST',
headers: {
'Content-Type': 'application/json',
'Authorization': `${env.key}`
},
body: JSON.stringify({'prompt': prompt})
}
);
if (!apiResponse.ok) {
throw new Error(`Cloudflare Workers AI error: ${apiResponse.statusText}`);
}
const response = await apiResponse.json();
return new Response(JSON.stringify({ response }), { headers: corsHeaders });
} catch (error) {
return sendErrorResponse(error.message);
}
} };
- Launch terminal and execute commands as follows :
```shell
# install devDependencies
(p)npm install
# create new post under /posts
(p)npm run new {new-post-filename}
# start local dev server
(p)npm run dev
# build for production
(p)npm run build
# Locally preview the production build
(p)npm run preview
Our project includes the GitHub workflow. You just need to ensure that the themeConfig.base is properly configured and GitHub pages auto-deployment will be triggered after push to GitHub.
# amplify.yml
version: 1
frontend:
phases:
preBuild:
commands:
- nvm use 18
- npm install -g pnpm
- pnpm install --no-frozen-lockfile
build:
commands:
- pnpm run build
artifacts:
baseDirectory: ./.vitepress/dist
files:
- '**/*'
cache:
paths:
- node_modules/**/*