Skip to content

Commit c4d61cd

Browse files
committed
Fixed blob edit URLs for view page source button
1 parent eb5d318 commit c4d61cd

File tree

3 files changed

+13
-3
lines changed

3 files changed

+13
-3
lines changed

docs/schema.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@
4141
},
4242
"edit_uri": {
4343
"title": "Path from repository root to directory containing Markdown",
44-
"markdownDescription": "https://squidfunk.github.io/mkdocs-material/setup/adding-a-git-repository/#edit-button",
44+
"markdownDescription": "https://www.mkdocs.org/user-guide/configuration/#edit_uri",
4545
"type": "string"
4646
},
4747
"copyright": {

material/partials/actions.html

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,12 @@
99
</a>
1010
{% endif %}
1111
{% if "content.action.view" in features %}
12-
<a href="{{ page.edit_url | replace('edit', 'raw') }}" title="{{ lang.t('action.view') }}" class="md-content__button md-icon">
12+
{% if "/blob/" in page.edit_url %}
13+
{% set part = "blob" %}
14+
{% else %}
15+
{% set part = "edit" %}
16+
{% endif %}
17+
<a href="{{ page.edit_url | replace(part, 'raw') }}" title="{{ lang.t('action.view') }}" class="md-content__button md-icon">
1318
{% set icon = config.theme.icon.view or "material/file-eye-outline" %}
1419
{% include ".icons/" ~ icon ~ ".svg" %}
1520
</a>

src/partials/actions.html

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,8 +37,13 @@
3737

3838
<!-- View button -->
3939
{% if "content.action.view" in features %}
40+
{% if "/blob/" in page.edit_url %}
41+
{% set part = "blob" %}
42+
{% else %}
43+
{% set part = "edit" %}
44+
{% endif %}
4045
<a
41-
href="{{ page.edit_url | replace('edit', 'raw') }}"
46+
href="{{ page.edit_url | replace(part, 'raw') }}"
4247
title="{{ lang.t('action.view') }}"
4348
class="md-content__button md-icon"
4449
>

0 commit comments

Comments
 (0)