jekyll-vitepress-theme 1.4.0 → 1.4.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/_layouts/default.html +2 -1
- data/assets/css/vitepress-core.css +11 -0
- data/assets/js/vitepress-theme.js +87 -35
- data/lib/jekyll/vitepress_theme/version.rb +1 -1
- metadata +1 -1
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: fce5780a829b36447736605a77a6597ae45840f199316745147581831999028b
|
|
4
|
+
data.tar.gz: b978b7657d6cc550eee63fac3597f4902378e6758581b167f0e8b321a6f23709
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 05a4d648a549d787d714753a244e0ca34454492b9a910976e3f4806ea1675e479e5eb84d6d0814c754b2099bd47ce2ebcfeb49532511f689afde5d9251c2793c
|
|
7
|
+
data.tar.gz: 0dc9df51ea6b3a896d1ba48f86b2db5c19e682aac304f713233c966af76d21760f8b63d2a2543707ca680270d6712bfa847a5a1294d82ba8da912efa86dfa514
|
data/_layouts/default.html
CHANGED
|
@@ -4,7 +4,8 @@
|
|
|
4
4
|
{% assign theme = site.jekyll_vitepress %}
|
|
5
5
|
{% assign behavior = theme.behavior %}
|
|
6
6
|
{% assign page_theme = page.jekyll_vitepress %}
|
|
7
|
-
|
|
7
|
+
{% assign scroll_offset = behavior.scroll_offset | default: 134 %}
|
|
8
|
+
<body data-vp-scroll-offset="{{ scroll_offset }}" style="--vp-scroll-offset: {{ scroll_offset }}px;">
|
|
8
9
|
{% assign is_home = false %}
|
|
9
10
|
{% if page.layout == 'home' or page.url == '/' %}
|
|
10
11
|
{% assign is_home = true %}
|
|
@@ -1306,6 +1306,15 @@ html:not(.dark) .shiki span {
|
|
|
1306
1306
|
outline: none;
|
|
1307
1307
|
}
|
|
1308
1308
|
|
|
1309
|
+
.vp-doc h1[id],
|
|
1310
|
+
.vp-doc h2[id],
|
|
1311
|
+
.vp-doc h3[id],
|
|
1312
|
+
.vp-doc h4[id],
|
|
1313
|
+
.vp-doc h5[id],
|
|
1314
|
+
.vp-doc h6[id] {
|
|
1315
|
+
scroll-margin-top: calc(var(--vp-scroll-offset, 134px) - var(--vp-heading-anchor-offset, 0px));
|
|
1316
|
+
}
|
|
1317
|
+
|
|
1309
1318
|
.vp-doc h1 {
|
|
1310
1319
|
letter-spacing: -0.02em;
|
|
1311
1320
|
line-height: 40px;
|
|
@@ -1313,6 +1322,8 @@ html:not(.dark) .shiki span {
|
|
|
1313
1322
|
}
|
|
1314
1323
|
|
|
1315
1324
|
.vp-doc h2 {
|
|
1325
|
+
--vp-heading-anchor-offset: 24px;
|
|
1326
|
+
|
|
1316
1327
|
margin: 48px 0 16px;
|
|
1317
1328
|
border-top: 1px solid var(--vp-c-divider);
|
|
1318
1329
|
padding-top: 24px;
|
|
@@ -1320,12 +1320,20 @@
|
|
|
1320
1320
|
return;
|
|
1321
1321
|
}
|
|
1322
1322
|
|
|
1323
|
+
function getHeadingLabel(heading) {
|
|
1324
|
+
var clone = heading.cloneNode(true);
|
|
1325
|
+
clone.querySelectorAll('.header-anchor').forEach(function (anchor) {
|
|
1326
|
+
anchor.remove();
|
|
1327
|
+
});
|
|
1328
|
+
return clone.textContent ? clone.textContent.trim() : heading.id;
|
|
1329
|
+
}
|
|
1330
|
+
|
|
1323
1331
|
content.querySelectorAll('h1[id], h2[id], h3[id], h4[id], h5[id], h6[id]').forEach(function (heading) {
|
|
1324
1332
|
if (heading.querySelector('.header-anchor')) {
|
|
1325
1333
|
return;
|
|
1326
1334
|
}
|
|
1327
1335
|
|
|
1328
|
-
var title = heading
|
|
1336
|
+
var title = getHeadingLabel(heading);
|
|
1329
1337
|
var anchor = document.createElement('a');
|
|
1330
1338
|
anchor.className = 'header-anchor';
|
|
1331
1339
|
anchor.href = '#' + heading.id;
|
|
@@ -1409,7 +1417,7 @@
|
|
|
1409
1417
|
|
|
1410
1418
|
var li = document.createElement('li');
|
|
1411
1419
|
var link = document.createElement('a');
|
|
1412
|
-
var label = entry.heading
|
|
1420
|
+
var label = getHeadingLabel(entry.heading);
|
|
1413
1421
|
|
|
1414
1422
|
link.className = 'outline-link';
|
|
1415
1423
|
link.href = '#' + entry.heading.id;
|
|
@@ -1536,38 +1544,38 @@
|
|
|
1536
1544
|
return 134;
|
|
1537
1545
|
}
|
|
1538
1546
|
|
|
1539
|
-
function
|
|
1547
|
+
function getHashTarget(hash) {
|
|
1540
1548
|
if (!hash) {
|
|
1541
|
-
return;
|
|
1549
|
+
return null;
|
|
1542
1550
|
}
|
|
1543
1551
|
|
|
1544
|
-
var
|
|
1552
|
+
var id = hash.slice(1);
|
|
1545
1553
|
try {
|
|
1546
|
-
|
|
1554
|
+
id = decodeURIComponent(id);
|
|
1547
1555
|
} catch (error) {
|
|
1548
|
-
|
|
1556
|
+
id = hash.slice(1);
|
|
1549
1557
|
}
|
|
1550
1558
|
|
|
1559
|
+
return document.getElementById(id);
|
|
1560
|
+
}
|
|
1561
|
+
|
|
1562
|
+
function scrollToHash(hash, smooth) {
|
|
1563
|
+
var target = getHashTarget(hash);
|
|
1551
1564
|
if (!target) {
|
|
1552
|
-
return;
|
|
1565
|
+
return false;
|
|
1553
1566
|
}
|
|
1554
1567
|
|
|
1555
|
-
var targetTop = window.scrollY +
|
|
1556
|
-
target.getBoundingClientRect().top -
|
|
1557
|
-
getConfiguredScrollOffset() +
|
|
1558
|
-
(parseInt(window.getComputedStyle(target).paddingTop, 10) || 0);
|
|
1559
|
-
|
|
1560
1568
|
var reduceMotion = window.matchMedia('(prefers-reduced-motion: reduce)').matches;
|
|
1561
1569
|
var behavior = 'auto';
|
|
1562
|
-
if (!reduceMotion && smooth && Math.abs(
|
|
1570
|
+
if (!reduceMotion && smooth && Math.abs(target.getBoundingClientRect().top) <= window.innerHeight) {
|
|
1563
1571
|
behavior = 'smooth';
|
|
1564
1572
|
}
|
|
1565
1573
|
|
|
1566
|
-
|
|
1574
|
+
target.scrollIntoView({ block: 'start', inline: 'nearest', behavior: behavior });
|
|
1567
1575
|
|
|
1568
1576
|
target.focus({ preventScroll: true });
|
|
1569
1577
|
if (document.activeElement === target || target.hasAttribute('tabindex')) {
|
|
1570
|
-
return;
|
|
1578
|
+
return true;
|
|
1571
1579
|
}
|
|
1572
1580
|
|
|
1573
1581
|
var restoreTabindex = function () {
|
|
@@ -1581,51 +1589,98 @@
|
|
|
1581
1589
|
if (document.activeElement !== target) {
|
|
1582
1590
|
restoreTabindex();
|
|
1583
1591
|
}
|
|
1592
|
+
|
|
1593
|
+
return true;
|
|
1584
1594
|
}
|
|
1585
1595
|
|
|
1586
|
-
function
|
|
1596
|
+
function getSamePageHash(link) {
|
|
1597
|
+
if (!link) {
|
|
1598
|
+
return null;
|
|
1599
|
+
}
|
|
1600
|
+
|
|
1601
|
+
var href = link.getAttribute('href');
|
|
1602
|
+
if (!href || href === '#') {
|
|
1603
|
+
return null;
|
|
1604
|
+
}
|
|
1605
|
+
|
|
1606
|
+
if (href.charAt(0) === '#') {
|
|
1607
|
+
return href;
|
|
1608
|
+
}
|
|
1609
|
+
|
|
1610
|
+
var url;
|
|
1611
|
+
try {
|
|
1612
|
+
url = new URL(href, window.location.href);
|
|
1613
|
+
} catch (error) {
|
|
1614
|
+
return null;
|
|
1615
|
+
}
|
|
1616
|
+
|
|
1617
|
+
if (url.origin !== window.location.origin ||
|
|
1618
|
+
normalizePathname(url.pathname) !== normalizePathname(window.location.pathname) ||
|
|
1619
|
+
url.search !== window.location.search ||
|
|
1620
|
+
!url.hash) {
|
|
1621
|
+
return null;
|
|
1622
|
+
}
|
|
1623
|
+
|
|
1624
|
+
return url.hash;
|
|
1625
|
+
}
|
|
1626
|
+
|
|
1627
|
+
function handleHashLinkClick(event) {
|
|
1628
|
+
if (event.defaultPrevented || (typeof event.button === 'number' && event.button !== 0) ||
|
|
1629
|
+
event.metaKey || event.ctrlKey || event.shiftKey || event.altKey) {
|
|
1630
|
+
return;
|
|
1631
|
+
}
|
|
1632
|
+
|
|
1587
1633
|
var link = event.currentTarget;
|
|
1588
1634
|
if (!link) {
|
|
1589
1635
|
return;
|
|
1590
1636
|
}
|
|
1591
1637
|
|
|
1592
|
-
var
|
|
1593
|
-
if (
|
|
1638
|
+
var target = link.getAttribute('target');
|
|
1639
|
+
if (target && target !== '_self') {
|
|
1640
|
+
return;
|
|
1641
|
+
}
|
|
1642
|
+
|
|
1643
|
+
var hash = getSamePageHash(link);
|
|
1644
|
+
if (!hash || !getHashTarget(hash)) {
|
|
1594
1645
|
return;
|
|
1595
1646
|
}
|
|
1596
1647
|
|
|
1597
1648
|
event.preventDefault();
|
|
1598
1649
|
|
|
1599
1650
|
if (window.history && typeof window.history.pushState === 'function') {
|
|
1651
|
+
if (window.location.hash === hash) {
|
|
1652
|
+
scrollToHash(hash, true);
|
|
1653
|
+
return;
|
|
1654
|
+
}
|
|
1600
1655
|
window.history.pushState(null, '', hash);
|
|
1601
1656
|
} else {
|
|
1602
1657
|
window.location.hash = hash;
|
|
1603
1658
|
}
|
|
1604
1659
|
|
|
1605
|
-
|
|
1660
|
+
scrollToHash(hash, true);
|
|
1606
1661
|
}
|
|
1607
1662
|
|
|
1608
|
-
function
|
|
1609
|
-
document.querySelectorAll('.outline-link').forEach(function (link) {
|
|
1610
|
-
if (link.hasAttribute('data-vp-bound')) {
|
|
1663
|
+
function bindHashLinkHandlers() {
|
|
1664
|
+
document.querySelectorAll('.outline-link, .vp-doc a[href]').forEach(function (link) {
|
|
1665
|
+
if (link.hasAttribute('data-vp-hash-bound') || !getSamePageHash(link)) {
|
|
1611
1666
|
return;
|
|
1612
1667
|
}
|
|
1613
|
-
link.setAttribute('data-vp-bound', 'true');
|
|
1614
|
-
link.addEventListener('click',
|
|
1668
|
+
link.setAttribute('data-vp-hash-bound', 'true');
|
|
1669
|
+
link.addEventListener('click', handleHashLinkClick);
|
|
1615
1670
|
});
|
|
1616
1671
|
}
|
|
1617
1672
|
|
|
1618
|
-
|
|
1673
|
+
bindHashLinkHandlers();
|
|
1619
1674
|
|
|
1620
1675
|
if (window.location.hash) {
|
|
1621
1676
|
window.requestAnimationFrame(function () {
|
|
1622
|
-
|
|
1677
|
+
scrollToHash(window.location.hash, false);
|
|
1623
1678
|
});
|
|
1624
1679
|
}
|
|
1625
1680
|
|
|
1626
1681
|
window.addEventListener('hashchange', function () {
|
|
1627
1682
|
if (window.location.hash) {
|
|
1628
|
-
|
|
1683
|
+
scrollToHash(window.location.hash, false);
|
|
1629
1684
|
}
|
|
1630
1685
|
});
|
|
1631
1686
|
|
|
@@ -1646,10 +1701,7 @@
|
|
|
1646
1701
|
}
|
|
1647
1702
|
|
|
1648
1703
|
function getOutlineScrollOffset() {
|
|
1649
|
-
|
|
1650
|
-
var navHeight = parseFloat(styles.getPropertyValue('--vp-nav-height')) || 0;
|
|
1651
|
-
var layoutTopHeight = parseFloat(styles.getPropertyValue('--vp-layout-top-height')) || 0;
|
|
1652
|
-
return navHeight + layoutTopHeight;
|
|
1704
|
+
return getConfiguredScrollOffset();
|
|
1653
1705
|
}
|
|
1654
1706
|
|
|
1655
1707
|
function activateOutlineHash(activeHash) {
|
|
@@ -1854,7 +1906,7 @@
|
|
|
1854
1906
|
return;
|
|
1855
1907
|
}
|
|
1856
1908
|
|
|
1857
|
-
var title = heading
|
|
1909
|
+
var title = getHeadingLabel(heading);
|
|
1858
1910
|
var anchor = document.createElement('a');
|
|
1859
1911
|
anchor.className = 'header-anchor';
|
|
1860
1912
|
anchor.href = '#' + heading.id;
|
|
@@ -1936,7 +1988,7 @@
|
|
|
1936
1988
|
localOutlineItems.hidden = true;
|
|
1937
1989
|
}
|
|
1938
1990
|
|
|
1939
|
-
|
|
1991
|
+
bindHashLinkHandlers();
|
|
1940
1992
|
syncLocalOutlineViewportHeight();
|
|
1941
1993
|
syncActiveHeading();
|
|
1942
1994
|
}
|
|
@@ -1971,7 +2023,7 @@
|
|
|
1971
2023
|
refreshDocPageState();
|
|
1972
2024
|
|
|
1973
2025
|
if (window.location.hash) {
|
|
1974
|
-
|
|
2026
|
+
scrollToHash(window.location.hash, false);
|
|
1975
2027
|
} else {
|
|
1976
2028
|
window.scrollTo({ top: 0, left: 0, behavior: 'auto' });
|
|
1977
2029
|
activateOutlineHash(null);
|