Skip to content

Commit

Permalink
docs: fix 404 when clicking on "Date Range Field" DemoContainer (#894)
Browse files Browse the repository at this point in the history
On the home page, when a user clicks on a demo container with a title
containing more than two words, they will get a 404.

For example, "Date Range Picker" generates the link:
`/components/date-range%20picker.html` rather than the correct link
`/components/date-range%20picker.html`.

The component responsible for generating this url is `<DemoContainer>`. It
uses the `title` prop to generate the link. When a title has a space, it currently
substitutes a hyphen for the space using `title.replace(" ", "-")`.

However, `.replace()` only replaces the first instance when passed a string as
the pattern, so only the first `" "` is replaced with a `"-"`.

This updates to use a regex in `title.replace()` so that each instance of
whitespace is replaced with a hyphen.
  • Loading branch information
jxjj authored May 6, 2024
1 parent 0db5981 commit 91e4148
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion docs/components/DemoContainer.vue
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ defineProps<{
<div class="w-full" :class="{ 'overflow-x-auto': overflow }">
<a
class="capitalize md:text-lg font-semibold mb-2 ml-2 inline-flex items-center group"
:href="`/components/${title?.replace(' ', '-')}.html`"
:href="`/components/${title?.replace(/\s+/g, '-')}.html`"
>{{ title }}

<Icon icon="ic-round-arrow-forward" class="ml-2 group-focus:ml-3 group-hover:ml-3 transition-[margin]" />
Expand Down

0 comments on commit 91e4148

Please sign in to comment.