Add more og:xx info

Add share param for export gallery
This commit is contained in:
2024-08-12 08:24:16 +08:00
parent 8b1ff26b9c
commit 12373171b7
2 changed files with 24 additions and 1 deletions

View File

@@ -98,6 +98,15 @@ export async function handler(req: Request, ctx: FreshContext) {
)?.setAttribute("content", title);
doc.querySelector('meta[name="description"]')
?.setAttribute("content", desc);
const head = doc.querySelector("head");
const ogt = dom.createElement("meta");
ogt.setAttribute("name", "og:title");
ogt.setAttribute("content", title);
const ogd = dom.createElement("meta");
ogd.setAttribute("name", "og:description");
ogd.setAttribute("content", desc);
head?.append(ogt);
head?.append(ogd);
if (m.cfg.img_verify_secret && doc) {
const p = m.db.get_pmeta_by_index(st.info.gid, 1);
if (p) {
@@ -130,7 +139,14 @@ export async function handler(req: Request, ctx: FreshContext) {
const me = dom.createElement("meta");
me.setAttribute("name", "og:image");
me.setAttribute("content", url);
doc.querySelector("head")?.append(me);
const ogty = dom.createElement("meta");
ogty.setAttribute("name", "og:type");
ogty.setAttribute(
"content",
"summary_large_image",
);
head?.append(me);
head?.append(ogty);
}
}
}

View File

@@ -17,6 +17,13 @@ function handle_auth(req: Request, ctx: FreshContext) {
token = cookies.get("token");
is_from_cookie = true;
}
if (
u.pathname.startsWith("/api/export/gallery/zip/") &&
req.method === "GET"
) {
token = u.searchParams.get("share");
is_from_cookie = false;
}
const check = () => {
if (u.pathname === "/api/token" && req.method === "PUT") return true;
if (u.pathname === "/api/status" && req.method === "GET") return true;