-
-
Notifications
You must be signed in to change notification settings - Fork 54
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
Add ability to use nested fields from relations #75
Conversation
Thanks @kibblerz, Though it seems as if you have some kind of linting that applies on save that does not match up with the linting of this repo. Could you check the issues that came out of the pipeline? |
Sure thing! |
Should be good to go now! |
Thanks for approving! |
I still have to do a manual review of the new feature. Until then; you can allready use this PR in your project like this;
|
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.
Hey @kibblerz,
I've thouroughly reviewed your PR. Overall it looks great! Thanks for all the work.
I still have some questions & comment which I have mostly included in the code review.
There was still one question I had;
Did you also test this for a multilingual site?
I applied all of your recommended edits. I don't have a bilingual site to test on, but I don't believe my code modified the localization logic. |
Codecov Report
@@ Coverage Diff @@
## master #75 +/- ##
==========================================
+ Coverage 77.77% 87.50% +9.72%
==========================================
Files 1 2 +1
Lines 36 72 +36
Branches 9 29 +20
==========================================
+ Hits 28 63 +35
- Misses 6 9 +3
+ Partials 2 0 -2
Flags with carried forward coverage won't be shown. Click here to find out more.
Continue to review full report at Codecov.
|
@kibblerz Thanks for the changes! I've tested it and it works pretty much perfect. For some reason the
So the Also, when we're creating a pattern for a content type with localizations enabled we see duplicate field options to add to the pattern. So duplicate entries are returned by the When that's finished I think we need to write some tests for the new pattern logic, but all in all this is a great new feature. Thanks for the work you have allready done on this! Happy easter 🐣 |
I've updated your PR to address the issues I mentioned above. Also I have written some tests for the relational pattern logic. Though whilst doing that I noticed there was one case I was a bit confused with when testing. Which was this part: https://github.com/boazpoolman/strapi-plugin-sitemap/pull/75/files#diff-f306920aa698f85f84aa8ebec6081fda2c285173603fd4dd8ef7e692566699ebR82 A relation field can be an array. So I guess that is for when there can be multiple relations. Like a one-to-many relation type. Though then we just use the first relation? |
@boazpoolman Yes it is set to use the first relation when the relation is an array. The only other solution i thought of was to create a different sitemap path for each relation. Do you have a better recommendation? |
I agree. It makes sense to have the pattern be like If we don’t do that I think we should not allow to add relations to the pattern which are of type array. As you can’t accurately select the relation. Which is fine by me. |
Yes, everything's still working! |
What does it do?
I adjusted how the paths are parsed to allow for the use of relation fields. So with this PR, you can use a related contenttypes fields in the path.
This PR only supports 1 level of depth when using relations. If the relation returns an array, the first result will be used. Would like to improve this in the future
Why is it needed?
Currently, relational attributes aren't able to be used.
How to test it?
If the content type is called company, with relations to employees:
/company/[employee[name]]/[post]
Related issue(s)/PR(s)
Let us know if this is related to any issue/pull request