optional url
This commit is contained in:
parent
b774721530
commit
c0963fcbf0
|
@ -55,13 +55,13 @@ export default (() => {
|
|||
return groups
|
||||
}
|
||||
|
||||
// Function to render button content based on contentType
|
||||
// Updated renderButtonContent function
|
||||
function renderButtonContent(button: any): preact.VNode | null {
|
||||
const contentType = button.contentType || "image" // Default to 'image'
|
||||
|
||||
if (contentType === "image") {
|
||||
return (
|
||||
<a href={button.url}>
|
||||
// Create the <img> element
|
||||
const imgElement = (
|
||||
<img
|
||||
src={button.image}
|
||||
alt={button.alt}
|
||||
|
@ -69,8 +69,15 @@ export default (() => {
|
|||
loading="lazy"
|
||||
decoding="async"
|
||||
/>
|
||||
</a>
|
||||
)
|
||||
|
||||
// If `button.url` is present, wrap the image in an `<a>` tag
|
||||
if (button.url) {
|
||||
return <a href={button.url}>{imgElement}</a>
|
||||
} else {
|
||||
// If no `url`, return the image element without wrapping
|
||||
return imgElement
|
||||
}
|
||||
} else if (contentType === "iframe") {
|
||||
const iframeAttrs = button.iframeAttributes || {}
|
||||
return <iframe src={button.url} title={button.title} {...iframeAttrs}></iframe>
|
||||
|
@ -79,5 +86,6 @@ export default (() => {
|
|||
return null
|
||||
}
|
||||
}
|
||||
|
||||
return Btn8831
|
||||
}) satisfies QuartzComponentConstructor
|
||||
|
|
Loading…
Reference in a new issue