Skip to content

Commit 91b3f0d

Browse files
committed
fix: atualiza status de 'backlog' para 'progress' em referencias.md
- Modificado o status do capítulo 'referencias' para refletir o progresso. - Ajustes na documentação do componente ContentCover. - Alterações na geração de imagens OG para melhorar a resposta SVG.
1 parent 11e7401 commit 91b3f0d

3 files changed

Lines changed: 38 additions & 42 deletions

File tree

content/capitulos/referencias.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ date: 2020-04-16 00:31
88
name: referencias
99
# parent:
1010
isParent: false
11-
status: backlog
11+
status: progress
1212
icon: "tabler/IconBooks"
1313

1414
---

src/components/content/ContentCover.js

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -3,20 +3,20 @@ import { getIcon } from '@pog/lib/iconMapper'
33

44
/**
55
* ContentCover Component
6-
*
6+
*
77
* Renders an icon over the base background image.
88
* Replaces static OG images with dynamic icon-based covers.
9-
*
9+
*
1010
* @param {string} icon - Icon identifier (e.g., "tabler/IconRun")
1111
* @param {string} title - Title for accessibility
1212
* @param {string} aspectRatio - Aspect ratio (default: '16/9')
1313
* @param {number} iconSize - Icon size in pixels (default: 120)
1414
*/
15-
const ContentCover = ({
16-
icon,
17-
title,
15+
const ContentCover = ({
16+
icon,
17+
title,
1818
aspectRatio = '16/9',
19-
iconSize = 120
19+
iconSize = 400
2020
}) => {
2121
const IconComponent = getIcon(icon)
2222

@@ -46,7 +46,7 @@ const ContentCover = ({
4646
{/* Icon overlay */}
4747
<Box
4848
sx={{
49-
color: 'primary.main',
49+
color: 'white',
5050
opacity: 0.9,
5151
filter: 'drop-shadow(0px 4px 8px rgba(0, 0, 0, 0.3))',
5252
}}

src/pages/api/og/index.js

Lines changed: 30 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -1,54 +1,50 @@
11
/**
22
* OG Image Generation API
33
*
4-
* For now, returns a simple redirect to static images or generates
5-
* a basic HTML response. Full image generation requires additional
6-
* setup with image processing libraries.
7-
*
8-
* TODO: Implement full image generation using:
9-
* - @vercel/og (recommended for Vercel deployment)
10-
* - OR canvas (for self-hosted)
11-
* - OR satori + resvg (for static exports)
4+
* Generates Open Graph images dynamically using SVG.
5+
* Returns SVG images that can be displayed directly by browsers
6+
* and social media crawlers.
127
*
138
* Usage: /api/og?icon=tabler/IconRun&title=Post Title
149
*/
1510

16-
import { getIcon } from '@pog/lib/iconMapper'
11+
import { createOGImageSVG } from '@pog/lib/iconRenderer'
1712

1813
export default async function handler(req, res) {
1914
try {
2015
const {
2116
icon = 'tabler/IconBooks',
22-
title = 'Livro POG'
17+
title = ''
2318
} = req.query
2419

25-
// Verificar se o ícone existe
26-
const IconComponent = getIcon(icon)
20+
// Generate SVG
21+
const svg = createOGImageSVG(icon, title)
2722

28-
if (!IconComponent) {
29-
return res.status(404).json({
30-
error: 'Icon not found',
31-
icon
32-
})
33-
}
34-
35-
// Por enquanto, retorna JSON com informações
36-
// Em produção, isso geraria uma imagem PNG/JPEG
37-
res.status(200).json({
38-
message: 'OG Image generation endpoint',
39-
icon,
40-
title,
41-
width: 1200,
42-
height: 630,
43-
note: 'Full image generation requires @vercel/og or canvas setup'
44-
})
23+
// Set headers for SVG response
24+
res.setHeader('Content-Type', 'image/svg+xml')
25+
res.setHeader('Cache-Control', 'public, max-age=31536000, immutable')
26+
27+
// Send SVG
28+
res.status(200).send(svg)
4529

4630
} catch (error) {
47-
console.error('Error in OG image endpoint:', error)
48-
res.status(500).json({
49-
error: 'Internal server error',
50-
message: error.message
51-
})
31+
console.error('Error generating OG image:', error)
32+
33+
// Return error SVG
34+
const errorSVG = `
35+
<svg width="1200" height="630" xmlns="http://www.w3.org/2000/svg">
36+
<rect width="1200" height="630" fill="#1a1a2e"/>
37+
<text x="600" y="315" font-family="system-ui" font-size="40" fill="#ff6b6b" text-anchor="middle">
38+
Error generating image
39+
</text>
40+
<text x="600" y="360" font-family="system-ui" font-size="20" fill="#999" text-anchor="middle">
41+
${error.message}
42+
</text>
43+
</svg>`
44+
45+
res.setHeader('Content-Type', 'image/svg+xml')
46+
res.status(500).send(errorSVG)
5247
}
5348
}
5449

50+

0 commit comments

Comments
 (0)