mirror of
https://github.com/docmost/docmost.git
synced 2026-09-11 07:56:54 +08:00
fix: meta title for shared subpages
This commit is contained in:
@@ -60,16 +60,21 @@ export class ShareSeoController {
|
||||
|
||||
const pageId = this.extractPageSlugId(pageSlug);
|
||||
|
||||
const share = await this.shareService.getShareForPage(
|
||||
pageId,
|
||||
workspace.id,
|
||||
);
|
||||
|
||||
if (!share) {
|
||||
let title: string;
|
||||
let searchIndexing = false;
|
||||
try {
|
||||
const shared = await this.shareService.getSharedPage(
|
||||
{ pageId },
|
||||
workspace.id,
|
||||
{ includeContent: false },
|
||||
);
|
||||
title = shared.page.title;
|
||||
searchIndexing = shared.share.searchIndexing;
|
||||
} catch (err) {
|
||||
return this.sendIndex(indexFilePath, res);
|
||||
}
|
||||
|
||||
const rawTitle = htmlEscape(share?.sharedPage.title ?? 'untitled');
|
||||
const rawTitle = htmlEscape(title ?? 'untitled');
|
||||
const metaTitle =
|
||||
rawTitle.length > 80 ? `${rawTitle.slice(0, 77)}…` : rawTitle;
|
||||
|
||||
@@ -78,7 +83,7 @@ export class ShareSeoController {
|
||||
const metaTags = [
|
||||
`<meta property="og:title" content="${metaTitle}" />`,
|
||||
`<meta property="twitter:title" content="${metaTitle}" />`,
|
||||
!share.searchIndexing ? `<meta name="robots" content="noindex" />` : '',
|
||||
!searchIndexing ? `<meta name="robots" content="noindex" />` : '',
|
||||
]
|
||||
.filter(Boolean)
|
||||
.join('\n ');
|
||||
|
||||
Reference in New Issue
Block a user