Skip to content

Commit 553ee20

Browse files
authored
Merge pull request #502 from webstackdev/feature/add-social-shares-and-update-meta-elements
Feature/add social shares and update meta elements
2 parents a3c4931 + 514bd9d commit 553ee20

39 files changed

Lines changed: 588 additions & 963 deletions

.cache/pages.json

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -22,10 +22,16 @@
2222
"contact",
2323
"offline",
2424
{
25-
"privacy": ["my-data"]
25+
"privacy": [
26+
"my-data"
27+
]
2628
},
2729
{
28-
"services": ["consulting", "overview", "web-development"]
30+
"services": [
31+
"consulting",
32+
"overview",
33+
"web-development"
34+
]
2935
},
3036
{
3137
"tags": [
@@ -47,4 +53,4 @@
4753
"typescript"
4854
]
4955
}
50-
]
56+
]

_TODO.md

Lines changed: 10 additions & 124 deletions
Original file line numberDiff line numberDiff line change
@@ -60,6 +60,8 @@ text-white, other default Tailwind colors
6060

6161
## Typing client-side API calls and SSR API endpoints
6262

63+
Use Astro Actions
64+
6365
Shared Types vs Swagger / Keeping Docs in Sync
6466

6567
1. Type-only sharing (current approach)
@@ -117,21 +119,6 @@ fatal: /home/kevin/Repos/Webstack: '/home/kevin/Repos/Webstack' is outside repos
117119

118120
⚠️ Privacy policy version fallback applied: 2025-12-08
119121

120-
## @TODO: Add Check HTML Links to test workflow
121-
122-
npm i -D check-html-links
123-
npx check-html-links _site
124-
`https://github.com/modernweb-dev/rocket/tree/main/packages/check-html-links`
125-
126-
22:38:43 [ERROR] [astro-link-validator] ❌ Found 2 broken links:
127-
\n📄 index.html:
128-
🔗 /services/web-development
129-
File not found: services/web-development
130-
Text: "Improve Your Product"
131-
🔗 /services/consulting
132-
File not found: services/consulting
133-
Text: "Start from scratch"
134-
135122
## Tags
136123

137124
Can we add a markdown page to explain what each tag is, and use those pages instead of src/content/_tagList.ts to define the tags available?
@@ -140,118 +127,44 @@ Can we add a markdown page to explain what each tag is, and use those pages inst
140127

141128
Looking at the social-card endpoint implementation, it's designed to work with third-party screenshot services, not the social networks themselves.
142129

143-
Here's how it works:
144-
145-
The Two Formats
146-
HTML format (format=html or default): Returns a full HTML page with inline CSS styled as a 1200x630px card - the standard Open Graph image dimensions.
147-
148-
OG format (format=og): Returns JSON with Open Graph meta tags, where the og:image URL points back to the HTML version of the card.
149-
150-
How Social Networks Actually Work
151-
Social networks like Twitter, Facebook, LinkedIn, etc. don't screenshot HTML pages. They expect:
152-
153-
- Direct image URLs (PNG, JPEG, etc.)
154-
- Standard dimensions (1200x630px for most platforms)
155-
156-
**The Intended Workflow**
157-
158-
This endpoint is designed to integrate with screenshot services like:
159-
160-
- Puppeteer or Playwright - Run your own screenshot service
161-
- Vercel OG Image Generation - Vercel's built-in service
162-
- Cloudinary - Can fetch and screenshot URLs
163-
- ScreenshotOne or ApiFlash - Dedicated screenshot APIs
164-
- Satori - Convert HTML/CSS to SVG/PNG
165-
166-
**Current Limitation**
167-
168-
As implemented, this endpoint would need an additional step to be useful for social sharing:
169-
170-
Your endpoint → Screenshot service → Image file → Social networks
171-
172-
Better Approaches
173-
174-
For a production Astro site, you'd typically:
175-
176-
- Use @vercel/og or Satori to generate actual images server-side
177-
- Pre-generate images at build time for static content
178-
- Use a screenshot service that can be called from your endpoint to return actual images
179-
180-
**Social Media Preview Generators**
181-
182-
There are several integrations available that vary based on the library they use to create an image file to snapshot, whether they allow the template for generating the image to be modified, and what options they provide for output.
183-
184-
[`astro-og-canvas`](https://www.npmjs.com/package/astro-og-canvas)
185-
186-
- Most popular option (~660 weekly d/l). Generates images at **run time**.
187-
- Uses **`canvaskit-wasm`** for rendering
188-
- Uses plain color or gradient background. Provide title, description, and logo (displayed at top left of card).
189-
- Can't set size of final card.
190-
191-
[`astro-satori`](https://www.npmjs.com/package/astro-satori)
192-
193-
- Moderately popular option (~230 weekly d/l). Generates images at **run time**.
194-
- Uses Vercel's **Satori** library for rendering (entirely done in JS with limitations on what CSS can be used). Satori is a library for generating SVG strings from pure HTML and CSS.
195-
- Size of final card can be set.
196-
- Seems opinionated, but it might be possible to have a lot of control (not sure).
197-
- Output format?
198-
199-
[`astro-opengraph-image`](https://www.npmjs.com/package/@altano/astro-opengraph-image#fn-filename-change)
200-
201-
- Uses **Satori**. Has dependencies on [`@resvg/resvg-wasm`](https://www.npmjs.com/package/@resvg/resvg-wasm) and Sharp. Middleware integration. Generates images at **run time**.
202-
- Provides element to add OG tags in document `<head>`.
203-
- Very flexible, you can provide the Astro template to generate the card.
204-
205-
[Astro Open Graph Image](https://www.npmjs.com/package/astro-og-image)
206-
207-
- Uses **Puppeteer**. Generates images at **build time**.
208-
- You can provide the Astro template to generate the card.
209-
- Requires providing a `baseHead` property in page templates.
210-
211-
[Astro Open Graph Image Generator](https://www.npmjs.com/package/@cyberkoalastudios/og-image-generator)
212-
213-
- Uses **Puppeteer**. Has dependencies on [`canvaskit-wasm`](https://www.npmjs.com/package/@resvg/resvg-wasm) and Sharp.
214-
- You can set the background image. No option to set the size of the card.
215-
- Manually add OF properties on `<head>` element. Flexible.
216-
217-
## @TODO: Use Confetti on CTA forms
130+
## Use Confetti on CTA forms
218131

219132
`canvas-confetti`
220133
`https://github.com/catdad/canvas-confetti`
221134
`https://www.kirilv.com/canvas-confetti/`
222135

223-
## @TODO: Use the Page Visibility API to pause videos, image carousels, and animations
136+
## Use the Page Visibility API to pause videos, image carousels, and animations
224137

225138
Stop unnecessary processes when the user doesn't see the page or inversely to perform background actions.
226139

227-
## @TODO: "Add to Calendar" button
140+
## "Add to Calendar" button
228141

229142
Google Calendar, Apple Calendar, Yahoo Calender, Microsoft 365, Outlook, and Teams, and generate iCal/ics files (for all other calendars and cases).
230143

231144
`https://github.com/add2cal/add-to-calendar-button`
232145
`https://add-to-calendar-button.com/`
233146

234-
## @TODO: Set up webmentions
147+
## Set up webmentions
235148

236149
Needs to add real API key and test
237150

238-
## @TODO: SCSS Use clothoid corners with border-radius
151+
## SCSS Use clothoid corners with border-radius
239152

240153
`https://onotakehiko.dev/clothoid/`
241154

242-
`@TODO: SCSS Make sure accent-color or styling for checkboxes/radio button groups is set up. Sets the colour used by checkboxes and radio buttons, as well as range fields and progress indicators. The accent colour is inherited`
155+
`SCSS Make sure accent-color or styling for checkboxes/radio button groups is set up. Sets the colour used by checkboxes and radio buttons, as well as range fields and progress indicators. The accent colour is inherited`
243156

244157
```scss
245158
:root{
246159
accent-color : #696;
247160
}
248161
```
249162

250-
## @TODO: Refactor modals
163+
## Refactor modals
251164

252165
Modals should be wrapped in the `<dialog>` element and use programmatic methods to display - `showModal()` to disable the area outside of the modal (handles `esc` keypress natively) and `show()` to allow interaction outside the modal, along with `close()`.
253166

254-
## @TODO: Add for iOS
167+
## Add for iOS
255168

256169
Specifying a Launch Screen Image
257170

@@ -383,33 +296,6 @@ Adds some custom directives:
383296

384297
Allows any Mastodon instance to discover your Mastodon profile directly from your own domain.
385298

386-
## Preload hero images, usually loaded after stylesheets and fonts
387-
388-
```font
389-
<head>
390-
<!-- Hey browser! Please preload this important responsive image -->
391-
<link
392-
rel="preload"
393-
as="image"
394-
imagesrcset="
395-
image-400.jpg 400w,
396-
image-800.jpg 800w,
397-
image-1600.jpg 1600w"
398-
imagesizes="100vw"
399-
>
400-
</head>
401-
<body>
402-
<img
403-
srcset="
404-
image-400.jpg 400w,
405-
image-800.jpg 800w,
406-
image-1600.jpg 1600w"
407-
sizes="100vw"
408-
alt="..."
409-
>
410-
</body>
411-
```
412-
413299
## Refactor social neworks in Authors collection to Contact collection format
414300

415301
The contact data collection uses an array of social networks, with keys:

astro.config.ts

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -103,6 +103,12 @@ export default defineConfig({
103103
/** API routes are marked in their files for SSR */
104104
output: 'static',
105105
prefetch: true,
106+
image: {
107+
remotePatterns: [
108+
{ protocol: 'https' },
109+
{ protocol: 'http' },
110+
],
111+
},
106112
/** Change URL between development and production environments */
107113
site: getSiteUrl(),
108114
trailingSlash: 'never',

package-lock.json

Lines changed: 45 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -90,6 +90,7 @@
9090
"astro": "5.16.4",
9191
"astro-icon": "^1.1.5",
9292
"astro-link-validator": "github:rodgtr1/astro-link-validator",
93+
"astro-og-canvas": "^0.7.2",
9394
"astro-vtbot": "^2.1.9",
9495
"cross-env": "^10.1.0",
9596
"dotenv": "17.2.3",
File renamed without changes.

src/components/Head/Meta.astro

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
---
2+
import { getSiteUrl } from '@lib/config/siteUrlServer'
23
import contactData from '@content/contact.json'
34
import { absoluteUrl } from '@components/scripts/utils'
45
import { getMetaThemeData } from '@components/Head/server/meta'
@@ -13,7 +14,7 @@ export interface Props {
1314
contentType?: 'article' | 'website'
1415
/** Meta description */
1516
description?: string
16-
image?: string
17+
/** Last modified date */
1718
modifiedDate?: Date
1819
/** Whether search engines should ignore the page, default: false */
1920
noindex?: boolean
@@ -33,7 +34,6 @@ const {
3334
author,
3435
contentType,
3536
description,
36-
image,
3737
modifiedDate,
3838
noindex = false,
3939
pageTitle,
@@ -43,7 +43,7 @@ const {
4343
tags,
4444
} = Astro.props
4545
46-
const { slug, defaultTheme } = getMetaThemeData(path)
46+
const defaultTheme = getMetaThemeData()
4747
---
4848

4949
<meta http-equiv="X-UA-Compatible" content="IE=edge" />
@@ -64,15 +64,13 @@ const { slug, defaultTheme } = getMetaThemeData(path)
6464
<Social
6565
title={pageTitle}
6666
description={description || contactData.company.description}
67-
slug={slug}
68-
{...image && { image }}
67+
path={path}
6968
/>
7069
{/* JSON-LD Structured Data for search engines */}
7170
<StructuredData
7271
path={path}
7372
pageTitle={pageTitle}
7473
{...description && { description }}
75-
{...image && { image }}
7674
{...contentType && { contentType }}
7775
{...publishDate && { publishDate }}
7876
{...modifiedDate && { modifiedDate }}
@@ -100,7 +98,7 @@ const { slug, defaultTheme } = getMetaThemeData(path)
10098
<link
10199
type="application/rss+xml"
102100
rel="alternate"
103-
href={absoluteUrl('rss.xml', Astro.site)}
101+
href={absoluteUrl('rss.xml', new URL(getSiteUrl()))}
104102
title={`RSS Feed for ${contactData.company.name}`}
105103
/>
106104
{/* Web App Manifest */}

0 commit comments

Comments
 (0)