Skip to content
Snippets Groups Projects
Commit f4dda163 authored by David Cameron's avatar David Cameron
Browse files

Issue #3477464 by dcam: Invalid anchor names

parent 152dd249
Branches
Tags
No related merge requests found
Pipeline #483366 passed
......@@ -2,6 +2,7 @@
namespace Drupal\styleguide\Controller;
use Drupal\Component\Utility\Html;
use Drupal\Core\Controller\ControllerBase;
use Drupal\Core\Extension\ThemeExtensionList;
use Drupal\Core\Link;
......@@ -76,6 +77,7 @@ class StyleguideController extends ControllerBase {
// Process the elements, by group.
foreach ($groups as $group => $elements) {
foreach ($elements as $key => $item) {
$id = Html::getUniqueId($key);
$display = [];
// Output a standard HTML tag.
if (isset($item['tag']) && isset($item['content'])) {
......@@ -100,13 +102,13 @@ class StyleguideController extends ControllerBase {
// Add the content.
$content[] = [
'#theme' => 'styleguide_item',
'#key' => $key,
'#key' => $id,
'#item' => $item,
'#content' => $display,
];
// Prepare the header link.
$uri = $this->requestStack->getCurrentRequest()->getUri();
$url = Url::fromUri($uri, ['fragment' => $key]);
$url = Url::fromUri($uri, ['fragment' => $id]);
$link = Link::fromTextAndUrl($item['title'], $url);
$header[$group][] = $link->toRenderable();
}
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment