silent1mezzo / astro-social-share

Social media share buttons for Astro
https://astro-social-share.mckerlie.com
MIT License
37 stars 4 forks source link

`url` can't be overwritten which leads to failure in static site generation #18

Closed madrobby closed 1 month ago

madrobby commented 1 month ago

Because url is based on the Astro request, the buttons fail to correctly generate when used with static sites generated by Astro (they all point to localhost:4321).

madrobby commented 1 month ago

Take it back, you can actually set it!

silent1mezzo commented 1 month ago

@madrobby Leaving this for others who see this.

  1. URL defaults to Astro.requests.url which I believe uses the base url you set in your astro config. You can see this working on my blog and the source code that controls it.
  2. url can be overridden if you want, you can include it with SocialShare component or any of the individual buttons.

e.g.

<SocialShare
    url="https://whateverurlyouwant.com"
    description="Description of the page/post"
    via="YourTwitterAccount"
    title="Page Title"
/>