protomorph / astro-zero

A zero styling, simple, Astro blog starter template.
MIT License
3 stars 1 forks source link

Adding open graph image #15

Closed prakash1763 closed 2 months ago

prakash1763 commented 2 months ago

Hello sir thanks for the awesome starter template, clean, no style, and less framework. I want to ask how to add og:image and twitter:image meta tag on a page that does not contain a blog post? Like in home page, there doesn't seem to be any open graph and twitter card image. I see only blog posts that have it

protomorph commented 2 months ago

Thanks for the positive comment, I'll look at adding og meta tags to other pages and have commit done asap

protomorph commented 2 months ago

@prakash1763 sorry this has taken so long, just to let you know that you can pass an open graph image to the base template via an image attribute on your page template <Base image="/path/to/image">, hope that helps

prakash1763 commented 2 months ago

Thank you!

prakash1763 commented 1 month ago

Sorry sir, why I can't use local image in MDX? Only image from external link is accepted

// src/content/posts/post-1.mdx
---
title: 'I am the title'
description: 'Some description.'
pubDate: 2024-06-28
image: '/assets/example.jpg'
category: 'Astro'
tags: ['html', 'framework']
featured: true
---

## Some text here

The image is located in public/assets folder, I also tried to put the image to src/assets but still got the same error

Screenshot_2024-08-30-14-20-20-291 Cause:

{
  "code": "ERR_INVALID_URL",
  "input": "/assets/example.jpg"
}
protomorph commented 1 month ago

@prakash1763 is the image in the public folder, that could be why it can't find it

prakash1763 commented 1 month ago

Yes it is in the public folder also in src, still not working

protomorph commented 1 month ago

Hmm, that's odd, I'll look into why it can't find local images

bcz3 commented 1 month ago

Hey @prakash1763, have you resolved the issue with using local images? I'm also having trouble using a local image in MDX. I saved the image file in src/assets.

---
title: 'Things you should not do in France'
description: 'When I came to France I discovered that things were quite different here when it comes to social cues than in my home country. '
pubDate: 2024-09-21
image: ../../assets/the-eiffel-tower.jpg
category: 'Travel'
tags: ['france', 'guide', 'tips']
---

Error:

TypeError
An error occurred.
Failed to parse URL from ../../assets/the-eiffel-tower.jpg
protomorph commented 2 weeks ago

@prakash1763 @bcz3 this issue should be fixed now, the Image component was only allowing remote images due to the inferSize attribute being used, sorry about taking so long to fix this