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

Feature/tqlg 307 seo img alt title #111

Open
wants to merge 15 commits into
base: main
Choose a base branch
from

Conversation

m-borgmann
Copy link
Contributor

@m-borgmann m-borgmann commented Jan 31, 2025

  • add seo relevant alt tags and titles to all img tags in the project with sensible fallbacks where possible
  • unify order lineItem styling for order finish, edit and account
  • only show customerComment if it was used
  • load seo urls in cartItemStore
  • use new useLineItemRoute composable to get seoUrls for lineItems
  • no longer link promotion product name
  • fix error when trying to remove a promotion from cart

Comment on lines 30 to 31
:alt="lineItemCover.alt ?? lineItem?.translated?.name"
:title="lineItemCover.title ?? lineItem?.translated?.name"
Copy link
Member

@mloeffle mloeffle Feb 3, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

couldn't you use getTranslatedProperty ? same question for the following files

Copy link
Contributor Author

@m-borgmann m-borgmann Feb 3, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I didn't use it initially, because getTranslatedProperty returns an empty string if it can't find a matching value. This breaks the nullish coalescent operator ?? because an empty string is falsy, but not nullish. I fixed it by using the logical or operator || instead whenever there is another fallback after one that is called with getTranslatedProperty, which works as intended here.

@m-borgmann m-borgmann requested a review from mloeffle February 3, 2025 15:57
components/Checkout/CheckoutLineItem.vue Outdated Show resolved Hide resolved
components/Order/OrderLineItem.vue Outdated Show resolved Hide resolved
getTranslatedProperty(option.media, 'title') ??
option.media.fileName
"
:alt="getTranslatedProperty(option.media, 'alt') || option.media.fileName"
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

could we not extract this in a method? we used it in a few places

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not sure what you mean here 🤔 do you want a function which takes a preferred and a fallback value as parameters and returns the matching one? if so, i am not sure what the advantage would be over using the operators here 😅

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

i thought it would be beneficial to not copy paste the operator over again and use a function. also to guarantee that its always the same

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I have to disagree here. Imo wrapping this and similar calls in a function would look quite bloated. The issue also is, that we would need another parameter for the operator, making the function call even longer, since some calls work with ?? while others need || because getTranslatedProperty returns an empty string which wont work with ?? if it is the first argument. Because of these differences in the calls I don't see a benefit by using a function

@@ -0,0 +1,38 @@
import type { Schemas } from '@shopware/api-client/api-types';

export function useLineItemRoute() {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

we also have a useProductRoute. could we not merge them to one composable? and also use the same structure as we did for example in useMedia?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I initially actually added the function to that composable but then split them up :D if you prefer it we can group them together though

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

up to you :D i prefer less composables with more logic in it but i dont think we have a guideline for this

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I actually ended up keeping the lineItem but removing the useProductRoute composable. The useProductRoute is already provided by shopware. We had just modified it before to sort of work with lineItems but this implementation is better. Thus I changed the few places where it was used to either use this new one or the default provided by shopware


const { apiClient } = useShopwareContext();

const { data: seoUrls } = await apiClient.invoke('readSeoUrl post /seo-url', {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

does an include make sense here?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The response of that endpoint is actually pretty small since it only returns the seoUrl entity, see: https://shopware.stoplight.io/docs/store-api/a5120c0fde5df-fetch-seo-routes - I dont think we would benefit much from an include here

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

i think its better to really just load the things we need (even if its in this case not that much we load without an include)

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I guess you are right 👍 I added an includes here

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

Successfully merging this pull request may close these issues.

4 participants