Skip to content

Commit 4e3dd63

Browse files
committed
Add Edit on GitHub link
1 parent 3bd403e commit 4e3dd63

File tree

3 files changed

+124
-1
lines changed

3 files changed

+124
-1
lines changed

_templates/header.html

Lines changed: 86 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,86 @@
1+
<header class="md-header" data-md-component="header">
2+
<nav class="md-header-nav md-grid">
3+
<div class="md-flex navheader">
4+
<div class="md-flex__cell md-flex__cell--shrink">
5+
<a
6+
href="{{ pathto(master_doc)|e }}"
7+
title="{{ docstitle|e }}"
8+
class="md-header-nav__button md-logo"
9+
>
10+
{% if theme_logo_icon|e %}
11+
<i class="md-icon">{{ theme_logo_icon }}</i>
12+
{% elif logo %}
13+
<img
14+
src="{{ pathto('_static/' ~ logo, 1) }}"
15+
height="26"
16+
alt="{{ shorttitle|striptags|e }} logo"
17+
/>
18+
{% else %} &nbsp; {% endif %}
19+
</a>
20+
</div>
21+
<div class="md-flex__cell md-flex__cell--shrink">
22+
<label
23+
class="md-icon md-icon--menu md-header-nav__button"
24+
for="__drawer"
25+
></label>
26+
</div>
27+
<div class="md-flex__cell md-flex__cell--stretch">
28+
<div
29+
class="md-flex__ellipsis md-header-nav__title"
30+
data-md-component="title"
31+
>
32+
<span class="md-header-nav__topic"
33+
>{{ theme_nav_title or shorttitle }}</span
34+
>
35+
<span class="md-header-nav__topic"> {{ title|striptags|e }} </span>
36+
</div>
37+
</div>
38+
<div class="md-flex__cell md-flex__cell--shrink">
39+
<label
40+
class="md-icon md-icon--search md-header-nav__button"
41+
for="__search"
42+
></label>
43+
{% include "searchbox.html" %}
44+
</div>
45+
{% if theme_repo_url %}
46+
<div class="md-flex__cell md-flex__cell--shrink">
47+
<div class="md-header-nav__source">
48+
{% if theme_repo_type %}
49+
<div class="md-source__icon">
50+
<svg
51+
xmlns="http://www.w3.org/2000/svg"
52+
xmlns:xlink="http://www.w3.org/1999/xlink"
53+
viewBox="0 0 24 24"
54+
width="28"
55+
height="28"
56+
>
57+
<use
58+
xlink:href="#__{{ theme_repo_type }}"
59+
width="24"
60+
height="24"
61+
></use>
62+
</svg>
63+
</div>
64+
{% endif %}
65+
<div class="md-source__repository">
66+
<a
67+
href="{{ theme_repo_url }}"
68+
title="Go to repository"
69+
class="md-source__repo"
70+
>
71+
{{ theme_repo_name }}
72+
</a>
73+
<a
74+
href="{{ theme_repo_url }}/edit/main/{{ pagename }}{{ page_source_suffix }}"
75+
title="Edit this page on GitHub"
76+
class="md-source__edit"
77+
>
78+
Edit on GitHub
79+
</a>
80+
</div>
81+
</div>
82+
</div>
83+
{% endif %} {% include "version_dropdown.html" %}
84+
</div>
85+
</nav>
86+
</header>

_templates/layout.html

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
{% extends '!layout.html' %}
2+
3+
{%- block extrahead %}
4+
<style>
5+
.md-source__repo {
6+
display: block;
7+
padding-right: .6rem;
8+
transition: opacity .25s;
9+
font-size: .65rem;
10+
line-height: 1.2;
11+
white-space: nowrap;
12+
}
13+
14+
.md-header-nav__source .md-source__repo:hover {
15+
opacity: .7;
16+
}
17+
18+
.md-source__repo::after,
19+
.md-source__edit::after {
20+
content: none
21+
}
22+
23+
.md-source__edit {
24+
font-size: .55rem;
25+
font-weight: initial;
26+
opacity: .75;
27+
}
28+
29+
.md-header-nav__source .md-source__edit:hover {
30+
opacity: .9;
31+
}
32+
</style>
33+
{{ super() }}
34+
{%- endblock %}

conf.py

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,8 +28,11 @@
2828
headers={"Accept": "application/vnd.github.v3+json"},
2929
params={"per_page": 100},
3030
)
31+
data = repos.json()
32+
for repo in data:
33+
if isinstance(repo, str):
34+
raise ValueError(data["message"])
3135

32-
for repo in repos.json():
3336
if repo["name"].startswith("jupyterlab-contrib"):
3437
continue # Skip special repositories
3538

0 commit comments

Comments
 (0)