mirror of
https://github.com/naturalcrit/homebrewery.git
synced 2026-01-04 01:42:42 +00:00
finish setting OG tags
This commit is contained in:
@@ -1,40 +1,4 @@
|
|||||||
const template = async function(name, title='', props = {}){
|
const template = async function(name, title='', props = {}){
|
||||||
// const HOMEBREWERY_PUBLIC_URL=props.config.publicUrl;
|
|
||||||
|
|
||||||
// const ogMeta = {
|
|
||||||
// siteName : 'The Homebrewery - Make your Homebrew content look legit!',
|
|
||||||
// title : 'The Homebrewery',
|
|
||||||
// description : 'Homepage',
|
|
||||||
// thumbnail : `${HOMEBREWERY_PUBLIC_URL}/thumbnail.png`,
|
|
||||||
// type : 'website'
|
|
||||||
// };
|
|
||||||
|
|
||||||
// if(props.url.match(/\/share\/|\/edit\//)){
|
|
||||||
// Object.assign(ogMeta, {
|
|
||||||
// siteName : null,
|
|
||||||
// title : props.brew.title || 'Homebrewery - Untitled Brew',
|
|
||||||
// description : props.brew.description || 'No description.',
|
|
||||||
// image : props.brew.thumbnail || null,
|
|
||||||
// type : 'article'
|
|
||||||
// });
|
|
||||||
// } else if(props.url.match(/\/print\/|\/source\//)){
|
|
||||||
// Object.assign(ogMeta, {
|
|
||||||
// siteName : null,
|
|
||||||
// title : props.brew.title ? `${props.brew.title} - ${props.url.match(/\/print\/|\/source\//)}` : 'Homebrewery - Untitled Brew',
|
|
||||||
// description : props.brew.description || 'No description.',
|
|
||||||
// image : props.brew.thumbnail || null,
|
|
||||||
// type : 'article'
|
|
||||||
// });
|
|
||||||
// } else if(props.url.match(/\/user\//)){
|
|
||||||
// Object.assign(ogMeta, {
|
|
||||||
// siteName : null,
|
|
||||||
// title : `${props.username} - The Homebrewery`,
|
|
||||||
// description : `${props.username}'s user page.`,
|
|
||||||
// image : null,
|
|
||||||
// type : 'profile'
|
|
||||||
// });
|
|
||||||
// }
|
|
||||||
|
|
||||||
const ogTags = [];
|
const ogTags = [];
|
||||||
Object.entries(props.ogMeta).forEach(([key, value])=>{
|
Object.entries(props.ogMeta).forEach(([key, value])=>{
|
||||||
if(!value) return;
|
if(!value) return;
|
||||||
@@ -43,7 +7,6 @@ const template = async function(name, title='', props = {}){
|
|||||||
});
|
});
|
||||||
const ogMetaTags = ogTags.join('\n');
|
const ogMetaTags = ogTags.join('\n');
|
||||||
|
|
||||||
|
|
||||||
return `<!DOCTYPE html>
|
return `<!DOCTYPE html>
|
||||||
<html>
|
<html>
|
||||||
<head>
|
<head>
|
||||||
|
|||||||
@@ -91,7 +91,7 @@ app.get('/', (req, res, next)=>{
|
|||||||
|
|
||||||
req.ogMeta = {
|
req.ogMeta = {
|
||||||
siteName : 'The Homebrewery - Make your Homebrew content look legit!',
|
siteName : 'The Homebrewery - Make your Homebrew content look legit!',
|
||||||
title : 'The Homebrewery - Homepage',
|
title : 'Homepage',
|
||||||
description : 'Homepage',
|
description : 'Homepage',
|
||||||
thumbnail : `${config.get('publicUrl')}/thumbnail.png`,
|
thumbnail : `${config.get('publicUrl')}/thumbnail.png`,
|
||||||
type : 'website'
|
type : 'website'
|
||||||
@@ -109,7 +109,7 @@ app.get('/legacy', (req, res, next)=>{
|
|||||||
|
|
||||||
req.ogMeta = {
|
req.ogMeta = {
|
||||||
siteName : 'The Homebrewery - Make your Homebrew content look legit!',
|
siteName : 'The Homebrewery - Make your Homebrew content look legit!',
|
||||||
title : 'The Homebrewery - Homepage (Legacy)',
|
title : 'Homepage (Legacy)',
|
||||||
description : 'Homepage',
|
description : 'Homepage',
|
||||||
thumbnail : `${config.get('publicUrl')}/thumbnail.png`,
|
thumbnail : `${config.get('publicUrl')}/thumbnail.png`,
|
||||||
type : 'website'
|
type : 'website'
|
||||||
@@ -127,7 +127,7 @@ app.get('/migrate', (req, res, next)=>{
|
|||||||
|
|
||||||
req.ogMeta = {
|
req.ogMeta = {
|
||||||
siteName : 'The Homebrewery - Make your Homebrew content look legit!',
|
siteName : 'The Homebrewery - Make your Homebrew content look legit!',
|
||||||
title : 'The Homebrewery - v3 Migration Guide',
|
title : 'v3 Migration Guide',
|
||||||
description : 'A brief guide to converting Legacy documents to the v3 renderer.',
|
description : 'A brief guide to converting Legacy documents to the v3 renderer.',
|
||||||
thumbnail : `${config.get('publicUrl')}/thumbnail.png`,
|
thumbnail : `${config.get('publicUrl')}/thumbnail.png`,
|
||||||
type : 'website'
|
type : 'website'
|
||||||
@@ -146,9 +146,9 @@ app.get('/changelog', async (req, res, next)=>{
|
|||||||
|
|
||||||
req.ogMeta = {
|
req.ogMeta = {
|
||||||
siteName : 'The Homebrewery - Make your Homebrew content look legit!',
|
siteName : 'The Homebrewery - Make your Homebrew content look legit!',
|
||||||
title : 'The Homebrewery - Changelog',
|
title : 'Changelog',
|
||||||
description : 'Development changelog.',
|
description : 'Development changelog.',
|
||||||
thumbnail : `${config.get('publicUrl')}/thumbnail.png`,
|
thumbnail : null,
|
||||||
type : 'website'
|
type : 'website'
|
||||||
};
|
};
|
||||||
splitTextStyleAndMetadata(req.brew);
|
splitTextStyleAndMetadata(req.brew);
|
||||||
@@ -165,7 +165,7 @@ app.get('/faq', async (req, res, next)=>{
|
|||||||
|
|
||||||
req.ogMeta = {
|
req.ogMeta = {
|
||||||
siteName : 'The Homebrewery - Make your Homebrew content look legit!',
|
siteName : 'The Homebrewery - Make your Homebrew content look legit!',
|
||||||
title : 'The Homebrewery - FAQ',
|
title : 'FAQ',
|
||||||
description : 'Frequently Asked Questions',
|
description : 'Frequently Asked Questions',
|
||||||
thumbnail : `${config.get('publicUrl')}/thumbnail.png`,
|
thumbnail : `${config.get('publicUrl')}/thumbnail.png`,
|
||||||
type : 'website'
|
type : 'website'
|
||||||
@@ -179,14 +179,6 @@ app.get('/faq', async (req, res, next)=>{
|
|||||||
app.get('/source/:id', asyncHandler(getBrew('share')), (req, res)=>{
|
app.get('/source/:id', asyncHandler(getBrew('share')), (req, res)=>{
|
||||||
const { brew } = req;
|
const { brew } = req;
|
||||||
|
|
||||||
req.ogMeta = {
|
|
||||||
siteName : null,
|
|
||||||
title : req.brew.title ? `${req.brew.title} - /source/` : 'Homebrewery - Untitled Brew',
|
|
||||||
description : req.brew.description || 'No description.',
|
|
||||||
image : req.brew.thumbnail || null,
|
|
||||||
type : 'article'
|
|
||||||
};
|
|
||||||
|
|
||||||
const replaceStrings = { '&': '&', '<': '<', '>': '>' };
|
const replaceStrings = { '&': '&', '<': '<', '>': '>' };
|
||||||
let text = brew.text;
|
let text = brew.text;
|
||||||
for (const replaceStr in replaceStrings) {
|
for (const replaceStr in replaceStrings) {
|
||||||
@@ -202,14 +194,6 @@ app.get('/download/:id', asyncHandler(getBrew('share')), (req, res)=>{
|
|||||||
sanitizeBrew(brew, 'share');
|
sanitizeBrew(brew, 'share');
|
||||||
const prefix = 'HB - ';
|
const prefix = 'HB - ';
|
||||||
|
|
||||||
req.ogMeta = {
|
|
||||||
siteName : null,
|
|
||||||
title : req.brew.title ? `${req.brew.title} - /download/` : 'Homebrewery - Untitled Brew',
|
|
||||||
description : req.brew.description || 'No description.',
|
|
||||||
image : req.brew.thumbnail || null,
|
|
||||||
type : 'article'
|
|
||||||
};
|
|
||||||
|
|
||||||
let fileName = sanitizeFilename(`${prefix}${brew.title}`).replaceAll(' ', '');
|
let fileName = sanitizeFilename(`${prefix}${brew.title}`).replaceAll(' ', '');
|
||||||
if(!fileName || !fileName.length) { fileName = `${prefix}-Untitled-Brew`; };
|
if(!fileName || !fileName.length) { fileName = `${prefix}-Untitled-Brew`; };
|
||||||
res.set({
|
res.set({
|
||||||
@@ -224,6 +208,14 @@ app.get('/download/:id', asyncHandler(getBrew('share')), (req, res)=>{
|
|||||||
app.get('/user/:username', async (req, res, next)=>{
|
app.get('/user/:username', async (req, res, next)=>{
|
||||||
const ownAccount = req.account && (req.account.username == req.params.username);
|
const ownAccount = req.account && (req.account.username == req.params.username);
|
||||||
|
|
||||||
|
req.ogMeta = {
|
||||||
|
siteName : 'The Homebrewery - Make your Homebrew content look legit!',
|
||||||
|
title : `${req.params.username}'s Collection`,
|
||||||
|
description : 'View my collection of homebrew on the Homebrewery.',
|
||||||
|
image : null,
|
||||||
|
type : 'website' // or 'profile'?
|
||||||
|
};
|
||||||
|
|
||||||
const fields = [
|
const fields = [
|
||||||
'googleId',
|
'googleId',
|
||||||
'title',
|
'title',
|
||||||
@@ -283,8 +275,8 @@ app.get('/edit/:id', asyncHandler(getBrew('edit')), (req, res, next)=>{
|
|||||||
req.brew = req.brew.toObject ? req.brew.toObject() : req.brew;
|
req.brew = req.brew.toObject ? req.brew.toObject() : req.brew;
|
||||||
|
|
||||||
req.ogMeta = {
|
req.ogMeta = {
|
||||||
siteName : null,
|
siteName : 'The Homebrewery - Make your Homebrew content look legit!',
|
||||||
title : req.brew.title || 'Homebrewery - Untitled Brew',
|
title : req.brew.title || 'Untitled Brew',
|
||||||
description : req.brew.description || 'No description.',
|
description : req.brew.description || 'No description.',
|
||||||
image : req.brew.thumbnail || null,
|
image : req.brew.thumbnail || null,
|
||||||
type : 'article'
|
type : 'article'
|
||||||
@@ -300,6 +292,13 @@ app.get('/new/:id', asyncHandler(getBrew('share')), (req, res, next)=>{
|
|||||||
sanitizeBrew(req.brew, 'share');
|
sanitizeBrew(req.brew, 'share');
|
||||||
splitTextStyleAndMetadata(req.brew);
|
splitTextStyleAndMetadata(req.brew);
|
||||||
req.brew.title = `CLONE - ${req.brew.title}`;
|
req.brew.title = `CLONE - ${req.brew.title}`;
|
||||||
|
req.ogMeta = {
|
||||||
|
siteName : 'The Homebrewery - Make your Homebrew content look legit!',
|
||||||
|
title : 'New',
|
||||||
|
description : 'Start crafting your homebrew on the Homebrewery!',
|
||||||
|
image : null,
|
||||||
|
type : 'website'
|
||||||
|
};
|
||||||
return next();
|
return next();
|
||||||
});
|
});
|
||||||
|
|
||||||
@@ -308,8 +307,8 @@ app.get('/share/:id', asyncHandler(getBrew('share')), asyncHandler(async (req, r
|
|||||||
const { brew } = req;
|
const { brew } = req;
|
||||||
|
|
||||||
req.ogMeta = {
|
req.ogMeta = {
|
||||||
siteName : null,
|
siteName : 'The Homebrewery - Make your Homebrew content look legit!',
|
||||||
title : req.brew.title || 'Homebrewery - Untitled Brew',
|
title : req.brew.title || 'Untitled Brew',
|
||||||
description : req.brew.description || 'No description.',
|
description : req.brew.description || 'No description.',
|
||||||
image : req.brew.thumbnail || null,
|
image : req.brew.thumbnail || null,
|
||||||
type : 'article'
|
type : 'article'
|
||||||
|
|||||||
Reference in New Issue
Block a user