Skip to content

Commit

Permalink
Removed URL fragment from template and moved it to a guides specific …
Browse files Browse the repository at this point in the history
…preprocess, so it only appears on guides.
  • Loading branch information
rupertj committed Oct 22, 2024
1 parent bf40ba8 commit f9c8423
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 2 deletions.
13 changes: 13 additions & 0 deletions localgov_base.theme
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
use Drupal\Component\Utility\Crypt;
use Drupal\Component\Utility\DeprecationHelper;
use Drupal\Core\Form\FormStateInterface;
use Drupal\Core\Url;
use Drupal\views\ViewExecutable;

/**
Expand Down Expand Up @@ -248,3 +249,15 @@ function localgov_base_preprocess_container(&$variables) {
function localgov_base_form_preview_link_entity_form_alter(&$form, $form_state, $form_id) {
$form['#attached']['library'][''] = 'localgov_base/preview-link';
}

/**
* Implements hook_preprocess_guides_prev_next_block().
*/
function localgov_base_preprocess_guides_prev_next_block(&$variables) {
if ($variables['previous_url'] instanceof Url) {
$variables['previous_url']->setOption('fragment', 'lgd-guides__title');
}
if ($variables['next_url'] instanceof Url) {
$variables['next_url']->setOption('fragment', 'lgd-guides__title');
}
}
4 changes: 2 additions & 2 deletions templates/_components/prev-next.twig
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@
<ul class="lgd-prev-next__list">
{% if previous_url %}
<li class="lgd-prev-next__list-item lgd-prev-next__list-item--prev">
<a href="{{ previous_url }}#lgd-guides__title" class="lgd-prev-next__link lgd-prev-next__link--prev" aria-label="{{ previous_aria_label }}">
<a href="{{ previous_url }}" class="lgd-prev-next__link lgd-prev-next__link--prev" aria-label="{{ previous_aria_label }}">
{% include "@localgov_base/includes/icons/icon.html.twig" with {
icon_name: previous_icon,
icon_classes: 'lgd-prev-next__icon lgd-prev-next__icon--prev',
Expand All @@ -44,7 +44,7 @@
{% endif %}
{% if next_url %}
<li class="lgd-prev-next__list-item lgd-prev-next__list-item--next">
<a href="{{ next_url }}#lgd-guides__title" class="lgd-prev-next__link lgd-prev-next__link--next" aria-label="{{ next_aria_label }}">
<a href="{{ next_url }}" class="lgd-prev-next__link lgd-prev-next__link--next" aria-label="{{ next_aria_label }}">
<div class="lgd-prev-next__label">
{{ 'Next'|t }}
</div>
Expand Down

0 comments on commit f9c8423

Please sign in to comment.