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

Alternate hreflang v2 #6744

Merged
merged 2 commits into from
Feb 11, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions packages/volto/news/6602.feature
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Add self link in alternate language links @erral
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,11 @@ const AlternateHrefLangs = (props) => {
return (
<Helmet>
{config.settings.isMultilingual &&
content['@components']?.translations?.items?.map((item, key) => {
content['@components']?.translations?.items &&
[
...content['@components']?.translations?.items,
{ '@id': content['@id'], language: content.language.token },
].map((item, key) => {
return (
<link
key={key}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,12 +40,11 @@ describe('AlternateHrefLangs', () => {
config.settings.supportedLanguages = ['en', 'es', 'eu'];

const content = {
'@id': '/en',
language: { token: 'en', title: 'English' },
'@components': {
translations: {
items: [
{ '@id': '/en', language: 'en' },
{ '@id': '/es', language: 'es' },
],
items: [{ '@id': '/es', language: 'es' }],
},
},
};
Expand Down Expand Up @@ -81,6 +80,7 @@ describe('AlternateHrefLangs', () => {
hrefLang: 'en',
});
});

it('multilingual site, with all available translations', () => {
config.settings.isMultilingual = true;
config.settings.supportedLanguages = ['en', 'es', 'eu'];
Expand All @@ -92,10 +92,11 @@ describe('AlternateHrefLangs', () => {
});

const content = {
'@id': '/en',
language: { token: 'en', title: 'English' },
'@components': {
translations: {
items: [
{ '@id': '/en', language: 'en' },
{ '@id': '/eu', language: 'eu' },
{ '@id': '/es', language: 'es' },
],
Expand Down