prismicio-community / eleventy-plugin-prismic

Eleventy plugin and shortcodes to fetch and present Prismic content
https://github.com/prismicio-community/eleventy-plugin-prismic/blob/master/DOCUMENTATION.md
MIT License
98 stars 5 forks source link

Lang Switcher #11

Closed haroldao closed 2 years ago

haroldao commented 2 years ago

Hey the team.

Is there a way to create a lang switcher ?

github-actions[bot] commented 2 years ago

This issue has been labeled as a feature request since it was created using the 🙋‍♀️ Feature Request Template.

Hi there, thank you so much for your request!

Following our Maintenance Process, we will review your request and get back to you soon. If we decide to implement it, will proceed to implement the feature during the last week of the month. In the meantime, feel free to provide any details to help us better understand your request, such as:

If you think you can implement the proposed change yourself, you're more than welcome to open a pull request implementing the new feature. Check out our quick start guide for a simple contribution process. Please note that submitting a pull request does not guarantee the feature will be merged.

- The Prismic Open-Source Team

lihbr commented 2 years ago

Hey there,

I'm not completely sure I get your request, but you should be able to create a lang switcher by looping over your document's alternate languages, something like so:

<ul>
{% for alternateDocument in document.alternate_languages %}
    <li>
    {% link alternateDocument %}
        {{ alternateDocument.lang }}
    {% endlink %}
    </li>
{% endfor %}
</ul>

For this case, you'd have to rely on the link resolver though (unfortunately the route resolver doesn't work with alternate language documents yet): https://github.com/prismicio-community/eleventy-plugin-prismic/blob/master/DOCUMENTATION.md#interface

Let me know :)

haroldao commented 2 years ago

Okay. Ty Lucie. I'll try that☺️