1
Fork 0
holllo-org/source/components/web-extension-store.astro

48 lines
1.1 KiB
Plaintext

---
/** Props for the WebExtensionStore component. */
export interface Props {
/** The name of the WebExtension. */
name: string;
/** The store to create the link for. */
store: string;
/** The ID of the WebExtension to append to the store link. */
webExtensionId: string;
}
const {name, store, webExtensionId} = Astro.props;
let [storeImage, storeName, storeUrl] = ["", "", ""];
switch (store) {
case "chrome": {
storeImage = "/chrome-web-store.png";
storeName = "Chrome";
storeUrl = `https://chrome.google.com/webstore/detail/${webExtensionId}`;
break;
}
case "edge": {
storeImage = "/microsoft.png";
storeName = "Edge";
storeUrl = `https://microsoftedge.microsoft.com/addons/detail/${webExtensionId}`;
break;
}
case "firefox": {
storeImage = "/mozilla-addons.png";
storeName = "Firefox";
storeUrl = `https://addons.mozilla.org/firefox/addon/${webExtensionId}`;
break;
}
default: {
throw new Error(`Unrecognized WebExtension store: ${store}`);
}
}
const altText = `Get ${name} for ${storeName}`;
---
<a href={storeUrl} title={altText}>
<img alt={altText} src={storeImage} />
</a>