joostdecock / site

This is/was the old freesewing website
https://old.freesewing.org/
16 stars 49 forks source link

(maybe a) fix for patron page broken links #476

Closed AlfaLyr closed 6 years ago

AlfaLyr commented 6 years ago

The links to the user profiles in the patron page are broken. I don't know anything about Nuxt and I don't know if this would fix it (do the ':' before the attributes mean that you can use variables? I'm just guessing here), but you get the idea ;)

joostdecock commented 6 years ago

Your guess is correct, an attribute that is prefixed by : is treated as a JavaScript expression. This is not nuxt specific but basic Vue.js functionality (nuxt us build on top of vue.js, and our site is build on top of nuxt).

This is a very good attempt, but there's one thing you missed. Your code would work, but it would always point to the English version of the user profile, even if somebody was browsing the site in Spanish.

What you need to do is check the language the user is using, and if it's not the default language, you need to add the language prefix to the URL. Which is really not the kind of thing you want to be doing every time you create a link to a user profile. So, we have a helper function for that in the freesewing plugin.

userPath() will contruct a correct langauge path to the profile of the username you pass it. I updated your pull request to use it, the source code of that method is here.

AlfaLyr commented 6 years ago

Thanks for the info :) And thanks so much for the course!! I'm out for the weekend, but I'll look at it next week ;)