diff --git a/js/yoast_seo.js b/js/yoast_seo.js index dfec4ab548d5e958d2fd478b5f823cc2cbbbb5a1..8547e77946aeb9e12cbcf1d57c0fd000e82fc305 100644 --- a/js/yoast_seo.js +++ b/js/yoast_seo.js @@ -215,8 +215,7 @@ var self = this; this.$form.ajaxSubmit({ - // TODO: This endpoint probably shouldn't be static. - url: '/yoast_seo/preview', + url: this.config.analysis_endpoint, data: { yoast_seo_preview: { path: drupalSettings.path.currentPath, diff --git a/src/Plugin/Field/FieldWidget/YoastSeoWidget.php b/src/Plugin/Field/FieldWidget/YoastSeoWidget.php index 00680afc8e17e90c61d32cc0d1e4cf5fb61655c9..3166b6a6f9eb70ffb653150b53acc45cc842f417 100644 --- a/src/Plugin/Field/FieldWidget/YoastSeoWidget.php +++ b/src/Plugin/Field/FieldWidget/YoastSeoWidget.php @@ -10,6 +10,7 @@ use Drupal\Core\Field\WidgetBase; use Drupal\Core\Form\FormStateInterface; use Drupal\Core\Field\FieldDefinitionInterface; use Drupal\Core\Plugin\ContainerFactoryPluginInterface; +use Drupal\Core\Url; use Drupal\yoast_seo\SeoManager; use Symfony\Component\DependencyInjection\ContainerInterface; @@ -177,6 +178,8 @@ class YoastSeoWidget extends WidgetBase implements ContainerFactoryPluginInterfa 'base_root' => $base_root, // Set up score to indiciator word rules. 'score_status' => $score_to_status_rules, + // Set up our analysis endpoint. + 'analysis_endpoint' => Url::fromRoute('yoast_seo.entity_preview')->toString(), ]; // Set up the names of the text outputs.