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

Site and Alternate Locales broken in v5.2 #285

Closed
jpmaga opened this issue Jul 7, 2023 · 2 comments
Closed

Site and Alternate Locales broken in v5.2 #285

jpmaga opened this issue Jul 7, 2023 · 2 comments

Comments

@jpmaga
Copy link

jpmaga commented Jul 7, 2023

So this code in v5.1 was working alright:

$tags = new SeoProTags();
$tags->setContext($this->entry->toAugmentedCollection());
$meta = $tags->metaData();

giving the following output:

    "site": {
      "handle": "en",
      "name": "English",
      "lang": "en",
      "locale": "en-US",
      "short_locale": "en",
      "url": "/en",
      "permalink": "http://sandbox.test/en",
      "direction": "ltr",
      "attributes": []
    },
    "alternate_locales": [
      {
        "site": {
          "handle": "other",
          "name": "Other",
          "lang": "ot",
          "locale": "ot-HER",
          "short_locale": "ot",
          "url": "/other",
          "permalink": "http://sandbox.test/other",
          "direction": "ltr",
          "attributes": []
        },
        "url": "http://sandbox.test/other"
      }
    ],

But when i updated to 5.2, this is what i get now:

    "site": {},
    "alternate_locales": [
      {
        "site": {},
        "url": "http://kit.test/other"
      }
    ],

If i revert back to 5.1 then it works again. No code was changed when trying this.

Notes: I have disabled statamic routing, I am using laravel's Route::fallback to handle requests, and this piece of code is part of the controller.

@jasonvarga
Copy link
Member

jasonvarga commented Jul 7, 2023

The tag class is intended to be used as a tag. Not really arbitrarily in a controller.

But you can work around this by adding the following lines.

$tags = new SeoProTags();
$tags->setContext($this->entry->toAugmentedCollection());
$meta = $tags->metaData();
+$meta['site'] = $meta['site']->toAugmentedArray();
+$meta['alternate_locales'] = collect($meta['alternate_locales'])->map(function ($alt) {
+  return array_merge($alt, ['site' => $alt['site']->toAugmentedArray()]);
+})->all();

@jpmaga
Copy link
Author

jpmaga commented Jul 7, 2023

Yeah, this is a bit of a workaround as mentioned in #248 and #264. But thanks for sharing that solution for the time being.

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

No branches or pull requests

2 participants