Skip to content
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

Expose fixHref as an importable function #159

Closed
jwmann opened this issue May 14, 2020 · 2 comments · Fixed by #160
Closed

Expose fixHref as an importable function #159

jwmann opened this issue May 14, 2020 · 2 comments · Fixed by #160
Assignees
Labels
enhancement New feature or request
Milestone

Comments

@jwmann
Copy link

jwmann commented May 14, 2020

Having the <Link> component is super nice but there are places where I'd like to get a string instead of an anchor element.

Is there a way you can expose the internal fixHref function to be used?

@aralroca
Copy link
Owner

Currently the fixHref is used internally and not directly exposed to the API of the library. This is why is not in the documentation. However, you can use it in this way:

import fixHref from 'next-translate/_helpers/fixHref'

//...
const { t, lang } = useTranslation()
console.log(fixHref('/test', lang)) // -> /en/test

Perhaps we could consider to move fixHref and fixAs to the first level API next-translate/fixHref and next-translate/fixAs, because they are stable and useful.

@aralroca aralroca self-assigned this May 15, 2020
@aralroca aralroca added the enhancement New feature or request label May 15, 2020
@aralroca aralroca added this to the 0.16.0 milestone May 15, 2020
@aralroca
Copy link
Owner

I opened a PR so after 0.16.0 you can import directly from import fixHref from 'next-translate/fixHref'.

@aralroca aralroca mentioned this issue May 15, 2020
2 tasks
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants