Add image upload support for OG images
This commit is contained in:
@@ -59,6 +59,18 @@ app.use('/api/auth', authRoutes);
|
||||
app.use('/api/admin', adminRoutes);
|
||||
app.use('/api/q', questionnaireRoutes);
|
||||
|
||||
// Serve uploaded files
|
||||
const uploadsDir = isProduction
|
||||
? '/app/data/uploads'
|
||||
: path.join(__dirname, '..', 'data', 'uploads');
|
||||
|
||||
// Ensure uploads directory exists
|
||||
if (!fs.existsSync(uploadsDir)) {
|
||||
fs.mkdirSync(uploadsDir, { recursive: true });
|
||||
}
|
||||
|
||||
app.use('/uploads', express.static(uploadsDir));
|
||||
|
||||
// Serve static files in production
|
||||
if (isProduction) {
|
||||
const clientPath = path.join(__dirname, '../client');
|
||||
@@ -83,16 +95,22 @@ if (isProduction) {
|
||||
const title = questionnaire.title;
|
||||
const description = questionnaire.description || 'Activiteiten Inventaris - Voeg activiteiten toe en stem!';
|
||||
|
||||
// Make image URL absolute if it's a relative path
|
||||
let ogImageUrl = questionnaire.og_image;
|
||||
if (ogImageUrl && ogImageUrl.startsWith('/')) {
|
||||
ogImageUrl = `${baseUrl}${ogImageUrl}`;
|
||||
}
|
||||
|
||||
const ogTags = `
|
||||
<meta property="og:type" content="website" />
|
||||
<meta property="og:url" content="${pageUrl}" />
|
||||
<meta property="og:title" content="${title}" />
|
||||
<meta property="og:description" content="${description}" />
|
||||
${questionnaire.og_image ? `<meta property="og:image" content="${questionnaire.og_image}" />` : ''}
|
||||
${ogImageUrl ? `<meta property="og:image" content="${ogImageUrl}" />` : ''}
|
||||
<meta name="twitter:card" content="summary_large_image" />
|
||||
<meta name="twitter:title" content="${title}" />
|
||||
<meta name="twitter:description" content="${description}" />
|
||||
${questionnaire.og_image ? `<meta name="twitter:image" content="${questionnaire.og_image}" />` : ''}
|
||||
${ogImageUrl ? `<meta name="twitter:image" content="${ogImageUrl}" />` : ''}
|
||||
`;
|
||||
|
||||
// Insert OG tags before </head>
|
||||
|
||||
Reference in New Issue
Block a user