opengraph attributes

pull/674/head
Zef Hemel 2024-01-28 15:51:02 +01:00
parent 1d8a54b72f
commit 58ea651668
2 changed files with 13 additions and 1 deletions

View File

@ -132,6 +132,10 @@ export class HttpServer {
"{{SPACE_PATH}}",
spaceServer.pagesPath.replaceAll("\\", "\\\\"),
)
.replace(
"{{DESCRIPTION}}",
JSON.stringify(stripHtml(html).substring(0, 255)),
)
.replace(
"{{TITLE}}",
pageName,
@ -663,3 +667,8 @@ function utcDateString(mtime: number): string {
function authCookieName(host: string) {
return `auth_${host.replaceAll(/\W/g, "_")}`;
}
function stripHtml(html: string): string {
const regex = /<[^>]*>/g;
return html.replace(regex, "");
}

View File

@ -1,5 +1,5 @@
<!DOCTYPE html>
<html lang="en">
<html lang="en" prefix="og: https://ogp.me/ns#">
<head>
<meta charset="utf-8" />
@ -11,6 +11,9 @@
<meta name="theme-color" content="#262626" media="(prefers-color-scheme: dark)">
<title>{{TITLE}}</title>
<meta property="og:image" content="/.client/logo.png">
<meta property="og:description" content={{DESCRIPTION}}>
<script>
// Some global variables we need to make this work
Deno = {