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

v3 - add field trans to linkTitle and add lang as async #712

Open
wants to merge 2 commits into
base: v3
Choose a base branch
from

Conversation

christinaroise
Copy link

Short Description

Adding field translations to Sanity for cases where we want to have translations to only specific fields.
⚠️ this does NOT support rich text ⚠️


Visual Overview (Image/Video)

If applicable, please include screenshots or a short video showcasing the changes you have made.

Insert images or videos here.
Screenshot 2024-09-25 at 14 23 14

Screenshot 2024-09-25 at 14 23 25

Checklist

Please ensure that you’ve completed the following checkpoints before submitting your pull request:

  • Documentation: Relevant documentation has been added or updated (if applicable).
  • Testing: Have you tested your changes thoroughly?
    • Please list the types of tests you've run (unit, integration, manual, etc.):

Additional Notes

Other comments relevant to this pull request.

Copy link

vercel bot commented Sep 25, 2024

The latest updates on your projects. Learn more about Vercel for Git ↗︎

Name Status Preview Comments Updated (UTC)
variant-no ✅ Ready (Inspect) Visit Preview 💬 Add feedback Sep 25, 2024 0:30am
variant-se-2 🛑 Canceled (Inspect) 💬 Add feedback Sep 25, 2024 0:30am

@christinaroise christinaroise changed the title add field trans to linkTitle and add lang as async v3 - add field trans to linkTitle and add lang as async Sep 25, 2024
@@ -191,7 +193,7 @@ export const link = defineField({
prepare(selection) {
const { title, type } = selection;
return {
title: title,
title: title[0].value,
Copy link
Author

Choose a reason for hiding this comment

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

To not overcomplicate this I've set it to index [0]. That might be an English translation or a Norwegian, but not something we can spend time on now.

@@ -14,6 +14,8 @@ import { apiVersion, dataset, projectId } from "./env";
import { schema } from "./schema";
import { legalDocumentID } from "./schemas/documents/admin/legalDocuments";

const SUPPORTED_LANGUAGES_QUERY = `*[_type == "languageSettings" && !(_id in path("drafts.*"))].languages[]{id, title}`;
Copy link
Contributor

Choose a reason for hiding this comment

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

Drafts are already filtered out in production, so do we need to check that?

Copy link
Author

Choose a reason for hiding this comment

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

Good point, it's just that when testing in staging we get duplicates. 🤪
So a list of English, Norwegian, English, Norwegian....

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

Successfully merging this pull request may close these issues.

3 participants