O Guia do Mochileiro das Galáxias
Falar sobre o livro
Essa é a H1 do Post
E essa é a H2
Contrary to popular belief, Lorem Ipsum is not simply random text. It has roots in a piece of classical Latin literature from 45 BC, making it over 2000 years old. Richard McClintock, a Latin professor at Hampden-Sydney College in Virginia, looked up one of the more obscure Latin words, consectetur, from a Lorem Ipsum passage, and going through the cites of the word in classical literature, discovered the undoubtable source. Lorem Ipsum comes from sections 1.10.32 and 1.10.33 of "de Finibus Bonorum et Malorum" (The Extremes of Good and Evil) by Cicero, written in 45 BC. This book is a treatise on the theory of ethics, very popular during the Renaissance. The first line of Lorem Ipsum, "Lorem ipsum dolor sit amet..", comes from a line in section 1.10.32.
The standard chunk of Lorem Ipsum used since the 1500s is reproduced below for those interested. Sections 1.10.32 and 1.10.33 from "de Finibus Bonorum et Malorum" by Cicero are also reproduced in their exact original form, accompanied by English versions from the 1914 translation by H. Rackham.
- Bullet list 1
- Bullet list 2
- Bullet list 3
- Bullet list 4
- Teste 1
- 2
- 3
Quote é massa tambem.

import type { VercelRequest, VercelResponse } from "@vercel/node";
import { createHmac, timingSafeEqual } from "node:crypto";
import { Client } from "@notionhq/client";
const publishedStatuses = new Set(["published", "publicado", "publish"]);
const statusPropertyNames = ["Status"];
export default async function handler(request: VercelRequest, response: VercelResponse) {
if (request.method !== "POST") {
response.status(405).json({ ok: false, error: "Method not allowed" });
return;
}
const body = JSON.stringify(request.body ?? {});
const verificationToken =
request.body?.verification_token ??
request.body?.verificationToken;
if (verificationToken) {
console.log("Notion webhook verification token:", verificationToken);
response.status(200).json({
ok: true,
verification_token: verificationToken,
});
return;
}
const notionWebhookToken = process.env.NOTION_WEBHOOK_VERIFICATION_TOKEN;
const signature = request.headers["x-notion-signature"];
if (
notionWebhookToken &&
typeof signature === "string" &&
!isValidSignature(body, signature, notionWebhookToken)
) {
response.status(401).json({ ok: false, error: "Invalid Notion signature" });
return;
}
const shouldDeploy = await shouldTriggerDeploy(request.body);
if (!shouldDeploy) {
response.status(200).json({ ok: true, deployTriggered: false, skipped: true });
return;
}
const deployHookUrl = process.env.VERCEL_DEPLOY_HOOK_URL;
if (!deployHookUrl) {
console.warn("VERCEL_DEPLOY_HOOK_URL is missing. Webhook received, but deploy was not triggered.");
response.status(200).json({ ok: true, deployTriggered: false });
return;
}
const deployResponse = await fetch(deployHookUrl, { method: "POST" });
if (!deployResponse.ok) {
console.warn("Deploy hook failed:", deployResponse.status, await deployResponse.text());
}
response.status(200).json({
ok: true,
deployTriggered: deployResponse.ok,
status: deployResponse.status,
});
}
async function shouldTriggerDeploy(payload: any): Promise<boolean> {
const eventType = payload?.type;
if (eventType === "page.deleted") {
return true;
}
if (!["page.content_updated", "page.properties_updated", "page.created"].includes(eventType)) {
return false;
}
const pageId = payload?.entity?.type === "page" ? payload.entity.id : null;
if (!pageId) {
return false;
}
const page = await retrieveNotionPage(pageId);
if (!page) {
return false;
}
if (!isBlogPage(page)) {
return false;
}
const status = getProperty(page.properties ?? {}, statusPropertyNames)?.status?.name ?? "";
if (eventType === "page.properties_updated") {
return true;
}
return publishedStatuses.has(status.toLowerCase());
}
async function retrieveNotionPage(pageId: string): Promise<any | null> {
const notionToken = process.env.NOTION_TOKEN;
if (!notionToken) {
console.warn("NOTION_TOKEN is missing. Skipping webhook-triggered deploy.");
return null;
}
try {
const notion = new Client({ auth: notionToken });
return await notion.pages.retrieve({ page_id: pageId });
} catch (error) {
console.warn("Unable to retrieve Notion page for webhook event:", error);
return null;
}
}
function isBlogPage(page: any): boolean {
const databaseId = normalizeId(process.env.NOTION_BLOG_DATABASE_ID ?? "");
const parentId = normalizeId(page?.parent?.database_id ?? "");
return Boolean(databaseId && parentId && databaseId === parentId);
}
function isValidSignature(body: string, signature: string, verificationToken: string): boolean {
const calculatedSignature = `sha256=${createHmac("sha256", verificationToken).update(body).digest("hex")}`;
try {
return timingSafeEqual(Buffer.from(calculatedSignature), Buffer.from(signature));
} catch {
return false;
}
}
function normalizeId(value: string): string {
return value.replace(/-/g, "").toLowerCase();
}
function getProperty(pageProperties: Record<string, any>, names: string[]): any {
for (const name of names) {
if (pageProperties[name]) {
return pageProperties[name];
}
}
return null;
}
Código!