Add open graph link titles

This commit is contained in:
Mononaut 2022-07-27 00:55:17 +00:00
parent a67c0b166c
commit d1ad9efe64
No known key found for this signature in database
GPG Key ID: 61B952CAF4838F94
2 changed files with 15 additions and 2 deletions

View File

@ -20,13 +20,13 @@ export class SeoService {
setTitle(newTitle: string): void {
this.titleService.setTitle(newTitle + ' - ' + this.getTitle());
this.metaService.updateTag({ property: 'og:title', content: newTitle});
this.metaService.updateTag({ property: 'twitter:description', content: newTitle});
this.metaService.updateTag({ property: 'twitter:title', content: newTitle});
}
resetTitle(): void {
this.titleService.setTitle(this.getTitle());
this.metaService.updateTag({ property: 'og:title', content: this.getTitle()});
this.metaService.updateTag({ property: 'twitter:description', content: this.getTitle()});
this.metaService.updateTag({ property: 'twitter:title', content: this.getTitle()});
}
setEnterpriseTitle(title: string) {

View File

@ -76,6 +76,11 @@ class Server {
return page.screenshot();
} break;
default: {
try {
await page.waitForSelector('meta[property="og:title"', { timeout: 5000 })
} catch (e) {
// probably timed out
}
return page.content();
}
}
@ -96,6 +101,14 @@ class Server {
}
async renderHTML(req, res) {
// drop requests for static files
const path = req.params[0];
const match = path.match(/\.[\w]+$/);
if (match?.length && match[0] !== '.html') {
res.status(404).send();
return
}
try {
let html = await this.cluster?.execute({ url: this.mempoolHost + req.params[0], action: 'html' });