Fix duplicate anchor link names (#40128)

This commit is contained in:
Wendelin 2025-07-24 15:38:54 +02:00 committed by GitHub
parent 00bbc585bf
commit b497709fef
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 27 additions and 14 deletions

View File

@ -41,15 +41,28 @@ module Jekyll
link.set_attribute('rel', rel.join(' ').strip)
end
# Find all headers, make them linkable
# Find all headers, make them linkable with unique slug names
used_slugs = {}
dom.css('h2,h3,h4,h5,h6,h7,h8').each do |header|
# Skip linked headers
next if header.at_css('a')
# Skip linked headers
next if header.at_css('a')
title = header.content
title = header.content
slug = title.downcase.strip.gsub(' ', '-').gsub(/[^\w-]/, '')
header.children = "#{title} <a class='title-link' name='#{slug}' href='\##{slug}'></a>"
# Clean the title to create a slug
base_slug = title.downcase.strip.gsub(' ', '-').gsub(/[^\w-]/, '')
# Make slug unique by adding counter if needed
if used_slugs[base_slug]
used_slugs[base_slug] += 1
slug = "#{base_slug}-#{used_slugs[base_slug] - 1}"
else
used_slugs[base_slug] = 1
slug = base_slug
end
header.children = "#{title} <a class='title-link' name='#{slug}' href='\##{slug}'></a>"
end
dom.to_s

View File

@ -78,7 +78,7 @@ Home Assistant supports both _classic inclusion_ and _SmartStart_. _Classic incl
For more Z-Wave term definitions, refer to the [terminology section](#z-wave-terminology).
### Getting started with Z-Wave - Prerequisites
### Prerequisites
To run a Z-Wave network, you need the following elements:
@ -178,7 +178,7 @@ Do this if you have an existing Z-Wave network and want to replace its adapter w
You cannot run two Z-Wave adapters simultaneously using the same add-on. If you only run one add-on, you need to migrate the network. If you want to run two adapters, you would need to install another add-on, such as Z-Wave JS UI.
{% endtip %}
### Network migration - Prerequisites
### Prerequisites
- Administrator rights in Home Assistant
- **Important**: If you want to migrate from a **500 series** adapter, before starting migration, you need to update the adapter to SDK 6.61+
@ -215,7 +215,7 @@ The frequency used by Z-Wave devices depends on your region. For 700 and 800 ser
If you are using the Z-Wave JS add-on, Home Assistant automatically changes the radio frequency region to match the region/country you're in. If needed, you can override this setting.
### Overriding the frequency region - Prerequisites
### Prerequisites
- Administrator rights in Home Assistant
- All your Z-Wave devices must be specified for that region
@ -234,7 +234,7 @@ If you are using the Z-Wave JS add-on, Home Assistant automatically changes the
It's recommended to create a backup before making any major changes to your Z-Wave network. For example, before migrating from one adapter to another, or before resetting your adapter. The backup stores your Z-Wave adapter's non-volatile memory (NVM), which contains your network information including paired devices. It is stored in a binary file that you can download.
### Backup - Prerequisites
### Prerequisites
- Administrator rights in Home Assistant
@ -251,7 +251,7 @@ It's recommended to create a backup before making any major changes to your Z-Wa
You can restore your Z-Wave network from a backup.
### Restore network - Prerequisites
### Prerequisites
- Administrator rights in Home Assistant
- Have a [backup](#backing-up-your-z-wave-network) downloaded
@ -280,7 +280,7 @@ A firmware update can damage your Z-Wave device.
The Home Assistant and Z-Wave JS teams do not take any responsibility for any damages to your device as a result of the firmware update and will not be able to help you if you render your device useless due to firmware update.
{% endnote %}
### Firmware update - Prerequisites
### Prerequisites
- Administrator rights in Home Assistant
- Downloaded the firmware file from the manufacturer website
@ -309,7 +309,7 @@ It is recommended to back up your Z-Wave network before resetting the device.
- If there are any devices still paired with the adapter when it is reset, they will have to go through the exclusion process before they can be re-paired.
- The device firmware will remain on the device.
### Reset - Prerequisites
### Prerequisites
- Administrator rights on Home Assistant
- [Backup your Z-Wave network](#backing-up-your-z-wave-network)