-
Notifications
You must be signed in to change notification settings - Fork 10
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Locale Switcher #75
base: 0.5
Are you sure you want to change the base?
Locale Switcher #75
Conversation
Deploying ui with Cloudflare Pages
|
@@ -0,0 +1,27 @@ | |||
--- | |||
import Select from 'fulldev-ui/components/Select.astro' |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
destructure the props needed, and also a restprops
Astro.props.locales && ( | ||
<Select | ||
name="locale-switcher" | ||
options={Astro.props.locales} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
use the destructured props and also pass the restprops
@@ -0,0 +1,27 @@ | |||
--- | |||
import Select from 'fulldev-ui/components/Select.astro' |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Add a type, you can use a modified version of ComponentProps You should omit values not needed, and add values that are unique for the LocaleSelect
const target = event.target | ||
const selectedLocale = target.value | ||
const currentUrl = new URL(window.location.href) | ||
currentUrl.pathname = '/' + selectedLocale + currentUrl.pathname |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Make this a template string instead, like /${selectedLocale}....etc
const target = event.target | ||
const selectedLocale = target.value | ||
const currentUrl = new URL(window.location.href) | ||
currentUrl.pathname = '/' + selectedLocale + currentUrl.pathname |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
make this a new const instead
@@ -0,0 +1,18 @@ | |||
--- |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Make it a habit to turn PascalCase in component names to kebab-case in md/mdx etc
So locale-select.mdx
import LocaleSelect from 'fulldev-ui/components/LocaleSelect.astro' | ||
--- | ||
|
||
<LocaleSelect /> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think this will be invisible because there are no locales passes as props, right?
No description provided.