This PR fixes a bug in the VPButton component of the default VitePress theme. Previously, the tag prop was not being properly respected when determining the component to render. This change ensures that the tag prop takes precedence, falling back to a or button based on the presence of the href prop only if no custom tag is specified.
Here's a simple script that demonstrates the effect of this change:
In this example, even though we specify a custom tag 'div' and there's no href, the original code would incorrectly choose 'a'. The fixed version correctly respects the custom tag 'div'.
Linked Issues
None.
Additional Context
None.
[!TIP]
The author of this PR can publish a preview release by commenting /publish below.
Description
This PR fixes a bug in the VPButton component of the default VitePress theme. Previously, the
tag
prop was not being properly respected when determining the component to render. This change ensures that thetag
prop takes precedence, falling back toa
orbutton
based on the presence of thehref
prop only if no custom tag is specified.Here's a simple script that demonstrates the effect of this change:
In this example, even though we specify a custom tag 'div' and there's no href, the original code would incorrectly choose 'a'. The fixed version correctly respects the custom tag 'div'.
Linked Issues
None.
Additional Context
None.