Skip to content

Commit

Permalink
Merge pull request #260 from ma10/revise-copylink-20240816
Browse files Browse the repository at this point in the history
明示的に指定されたIDを常に利用するように修正
  • Loading branch information
ma10 authored Aug 16, 2024
2 parents afa8155 + 2eff5d1 commit bc6a154
Showing 1 changed file with 10 additions and 1 deletion.
11 changes: 10 additions & 1 deletion ja/source/_static/copylink.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,16 @@ document.addEventListener('DOMContentLoaded', function () {
document.querySelectorAll('section.permalink').forEach(section => {
const firstHeader = section.querySelector('h1, h2, h3, h4, h5, h6');
if (firstHeader) {
const url = location.origin + location.pathname + '#' + section.id;
let id;
const firstSpan = section.querySelector('span');
if (firstSpan && firstSpan.id && /id\d+/.test(firstSpan.id)) {
id = section.id;
} else if (firstSpan && firstSpan.id) {
id = firstSpan.id;
} else {
id = section.id;
}
const url = location.origin + location.pathname + '#' + id;
appendDropdownMenu(firstHeader, firstHeader.textContent, url);
}
});
Expand Down

0 comments on commit bc6a154

Please sign in to comment.