1
0
mirror of https://github.com/squidfunk/mkdocs-material.git synced 2024-11-24 07:30:12 +01:00

Fixed blob edit URLs for view page source button

This commit is contained in:
squidfunk 2023-01-05 22:59:56 +01:00
parent eb5d318603
commit c4d61cdc41
3 changed files with 13 additions and 3 deletions

View File

@ -41,7 +41,7 @@
},
"edit_uri": {
"title": "Path from repository root to directory containing Markdown",
"markdownDescription": "https://squidfunk.github.io/mkdocs-material/setup/adding-a-git-repository/#edit-button",
"markdownDescription": "https://www.mkdocs.org/user-guide/configuration/#edit_uri",
"type": "string"
},
"copyright": {

View File

@ -9,7 +9,12 @@
</a>
{% endif %}
{% if "content.action.view" in features %}
<a href="{{ page.edit_url | replace('edit', 'raw') }}" title="{{ lang.t('action.view') }}" class="md-content__button md-icon">
{% if "/blob/" in page.edit_url %}
{% set part = "blob" %}
{% else %}
{% set part = "edit" %}
{% endif %}
<a href="{{ page.edit_url | replace(part, 'raw') }}" title="{{ lang.t('action.view') }}" class="md-content__button md-icon">
{% set icon = config.theme.icon.view or "material/file-eye-outline" %}
{% include ".icons/" ~ icon ~ ".svg" %}
</a>

View File

@ -37,8 +37,13 @@
<!-- View button -->
{% if "content.action.view" in features %}
{% if "/blob/" in page.edit_url %}
{% set part = "blob" %}
{% else %}
{% set part = "edit" %}
{% endif %}
<a
href="{{ page.edit_url | replace('edit', 'raw') }}"
href="{{ page.edit_url | replace(part, 'raw') }}"
title="{{ lang.t('action.view') }}"
class="md-content__button md-icon"
>