1
0
Fork 0
mirror of https://github.com/codex-team/codex.docs.git synced 2025-08-09 23:45:25 +02:00

create counter for header-anchors

This commit is contained in:
Alexander Chernyaev 2022-09-12 13:15:49 +03:00
parent 07927ccb53
commit eccf0be38c
2 changed files with 7 additions and 2 deletions

View file

@ -1,5 +1,5 @@
<h{{ level }} id="{{ text | urlify }}" class="block-header block-header--{{ level }} block-header--anchor">
<a href="#{{ text | urlify }}">
<h{{ level }} id="{{ linkNumber }}-{{ text | urlify }}" class="block-header block-header--{{ level }} block-header--anchor">
<a href="#{{ linkNumber }}-{{ text | urlify }}">
{{ text }}
</a>
</h{{ level }}>

View file

@ -1,6 +1,7 @@
{% extends 'layout.twig' %}
{% block body %}
{% set linkNumber = 0 %}
<article class="page" data-module="page">
<header class="page__header">
<div class="page__header-nav">
@ -37,6 +38,10 @@
{# Skip first header, because it is already showed as a Title #}
{% if not (loop.first and block.type == 'header') %}
{% if block.type in ['paragraph', 'header', 'image', 'code', 'list', 'delimiter', 'table', 'warning', 'checklist', 'linkTool', 'raw', 'embed'] %}
{# Create the counter to make header-achors different. #}
{% if (block.type == 'header') %}
{% set linkNumber = linkNumber + 1 %}
{% endif %}
<div class="page__content-block">
{% include './blocks/' ~ block.type ~ '.twig' with block.data %}
</div>