Skip to content

Commit c362f6e

Browse files
authored
[PYT-54] Add automatic anchor links on headers in <article>s (pytorch#3)
1 parent a632558 commit c362f6e

File tree

6 files changed

+19
-0
lines changed

6 files changed

+19
-0
lines changed

Makefile

+1
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,7 @@ include-yarn-deps:
3131
cp node_modules/jquery/dist/jquery.min.js $(VENDOR_DIR)
3232
cp node_modules/popper.js/dist/umd/popper.min.js $(VENDOR_DIR)
3333
cp node_modules/bootstrap/dist/js/bootstrap.min.js $(VENDOR_DIR)
34+
cp node_modules/anchor-js/anchor.min.js $(VENDOR_DIR)
3435

3536
build: install include-yarn-deps
3637
$(JEKYLL) build --config _config.yml,_config_dev.yml

_includes/head.html

+1
Original file line numberDiff line numberDiff line change
@@ -8,4 +8,5 @@
88
<script src="{{ site.baseurl }}/assets/vendor/jquery.min.js"></script>
99
<script src="{{ site.baseurl }}/assets/vendor/popper.min.js"></script>
1010
<script src="{{ site.baseurl }}/assets/vendor/bootstrap.min.js"></script>
11+
<script src="{{ site.baseurl }}/assets/vendor/anchor.min.js"></script>
1112
</head>

_layouts/default.html

+4
Original file line numberDiff line numberDiff line change
@@ -13,5 +13,9 @@
1313
{{ content }}
1414

1515
{% include footer.html %}
16+
17+
<script type="text/javascript">
18+
anchors.add('article h2, article h3, article h4, article h5');
19+
</script>
1620
</body>
1721
</html>

assets/main.scss

+8
Original file line numberDiff line numberDiff line change
@@ -250,3 +250,11 @@ pre {
250250
color: $orange;
251251
}
252252
}
253+
254+
.anchorjs-link {
255+
color: $slate;
256+
&:hover {
257+
color: inherit;
258+
text-decoration: none;
259+
}
260+
}

package.json

+1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
{
22
"dependencies": {
3+
"anchor-js": "^4.1.1",
34
"bootstrap": "4.0.0",
45
"jquery": "^3.3.1",
56
"popper.js": "^1.14.3"

yarn.lock

+4
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,10 @@
22
# yarn lockfile v1
33

44

5+
anchor-js@^4.1.1:
6+
version "4.1.1"
7+
resolved "https://registry.yarnpkg.com/anchor-js/-/anchor-js-4.1.1.tgz#943b7605e47b3c663e91e82879b682f2e186a5b1"
8+
59
bootstrap@4.0.0:
610
version "4.0.0"
711
resolved "https://registry.yarnpkg.com/bootstrap/-/bootstrap-4.0.0.tgz#ceb03842c145fcc1b9b4e15da2a05656ba68469a"

0 commit comments

Comments
 (0)