proc canonical url
This commit is contained in:
parent
532787a77b
commit
38c26c07cd
|
@ -1,6 +1,6 @@
|
|||
import { readFileSync } from "node:fs";
|
||||
import markdownit from "markdown-it";
|
||||
import { Article, getById as getArticleById } from "./article.js";
|
||||
import { Article, buildCanonicalUrl, getById as getArticleById } from "./article.js";
|
||||
import { User, getByActor } from "./user.js";
|
||||
import { fillRoute, reverseRoute } from "./router.js";
|
||||
import { streamToString, hashDigest } from "./util.js";
|
||||
|
@ -155,10 +155,10 @@ export const handleInboxPost = async (req: Request, res: Response) => {
|
|||
|
||||
export const deleteArticleActivity = (article: Article, user: User) => {
|
||||
const actor = fillRoute("actor", user.nickname);
|
||||
const published = typeof article.updated_at === "number" ? new Date(article.updated_at) : article.updated_at;
|
||||
const published = article.updated_at;
|
||||
const context = fillRoute("context", article.id);
|
||||
const objectId = fillRoute("object", article.id);
|
||||
const canonicalUrl = `https://${process.env.blog_host}/${article.slug}.html`;
|
||||
const canonicalUrl = buildCanonicalUrl(article);
|
||||
|
||||
const activity: Record<string, any> = {
|
||||
id: fillRoute("activity", article.id) + "/delete",
|
||||
|
@ -201,7 +201,7 @@ export const createArticleObject = (article: Article, nickname: string) => {
|
|||
const context = fillRoute("context", article.id);
|
||||
const objectId = fillRoute("object", article.id);
|
||||
|
||||
const canonicalUrl = `https://${process.env.blog_host}/${article.slug}.html`;
|
||||
const canonicalUrl = buildCanonicalUrl(article);
|
||||
const content = readFileSync(article.file as string, "utf-8") + `
|
||||
|
||||
[Read on site](${canonicalUrl})
|
||||
|
|
|
@ -63,3 +63,6 @@ export const getAll = async (count: number, lastId = Number.MAX_SAFE_INTEGER) =>
|
|||
.limit(count)
|
||||
.then((articles) => articles.map((a) => fixDates<Article>(a)))
|
||||
;
|
||||
|
||||
export const buildCanonicalUrl = (article: Article) =>
|
||||
`https://${process.env.blog_host}/${article.slug}.html`;
|
Loading…
Reference in New Issue