Inital commit
This commit is contained in:
commit
a6af7dbfcb
114 files changed
+27520
No files matched your search
@@ -0,0 +1,40 @@
|
||||
import type { Request } from "express";
|
||||
|
||||
import { getConfig } from "./config";
|
||||
import { getTracerId, tracer } from "./pages/tracer";
|
||||
|
||||
function mp(name: string) {
|
||||
if (!name || typeof name !== "string") {
|
||||
return "";
|
||||
}
|
||||
name = name.trim();
|
||||
if (name.endsWith("s") || name.endsWith("S")) {
|
||||
return name + "'";
|
||||
} else {
|
||||
return name + "'s";
|
||||
}
|
||||
}
|
||||
|
||||
export function getPageVariables(req: Request, include: any = {}) {
|
||||
const config = getConfig();
|
||||
const id = getTracerId(req);
|
||||
const varObject = {
|
||||
tracer: id ? tracer(id) : null,
|
||||
t: (link: string) => {
|
||||
if (id && (link.startsWith("/") || link.startsWith("?"))) {
|
||||
new URLSearchParams(link);
|
||||
return `${link}${link.includes("?") ? "&" : "?"}t=${id[0]}`;
|
||||
}
|
||||
return link;
|
||||
},
|
||||
b: (link: string) =>
|
||||
link.startsWith("/") || link.startsWith("./") ? "" : `target="_blank"`,
|
||||
mp,
|
||||
...config,
|
||||
title: config.title || "",
|
||||
titleShort: config.titleShort || "",
|
||||
description: config.description || "",
|
||||
...include,
|
||||
};
|
||||
return varObject;
|
||||
}
|
||||
Reference in new issue
Block a user