Skip to content

Question Regarding Custom Open Graph (OG) Tag Values #217

Answered by mearashadowfax
shah-iq asked this question in Q&A
Discussion options

You must be logged in to vote

For the first option, it would look like this:

// Meta.astro
---
// Default properties for the Meta component
const defaultProps = {
  meta: SITE.description,
  structuredData: SEO.structuredData,
  ogData: {
    title: OG.title,
    description: OG.description,
    image: OG.image,
    url: SITE.url,
  },
};

// Extract props and set defaults if not provided
const {
  meta = defaultProps.meta,
  structuredData = defaultProps.structuredData,
  ogData = defaultProps.ogData,
} = Astro.props;

// Define metadata for OG tags
const URL = `${Astro.site}`; // Site URL from astro.config.mjs
const ogTitle = ogData.title;
const ogDescription = ogData.description;
const socialImageRes = await getImage(

Replies: 2 comments 10 replies

Comment options

You must be logged in to vote
9 replies
@shah-iq
Comment options

@shah-iq
Comment options

@mearashadowfax
Comment options

@shah-iq
Comment options

@mearashadowfax
Comment options

Comment options

You must be logged in to vote
1 reply
@shah-iq
Comment options

Answer selected by shah-iq
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants
Converted from issue

This discussion was converted from issue #216 on September 28, 2024 18:47.