Moved page edit action into separate partial

This commit is contained in:
squidfunk 2022-09-03 21:33:49 +02:00
parent 141bd2ec7b
commit c6dd6b67d5
8 changed files with 106 additions and 50 deletions

View File

@ -0,0 +1,13 @@
{#-
This file was automatically generated - do not edit
-#}
{% if page.edit_url %}
{% set edit = "https://github.com/squidfunk/mkdocs-material/edit" %}
{% set view = "https://raw.githubusercontent.com/squidfunk/mkdocs-material" %}
<a href="{{ page.edit_url }}" title="{{ lang.t('edit.link.title') }}" class="md-content__button md-icon">
{% include ".icons/material/file-edit-outline.svg" %}
</a>
<a href="{{ page.edit_url | replace(edit, view) }}" title="View source of this page" class="md-content__button md-icon">
{% include ".icons/material/file-eye-outline.svg" %}
</a>
{% endif %}

View File

@ -1,19 +1,10 @@
{#- {#-
This file was automatically generated - do not edit This file was automatically generated - do not edit
-#} -#}
{% if page.edit_url %}
{% set edit = "https://github.com/squidfunk/mkdocs-material/edit" %}
{% set view = "https://raw.githubusercontent.com/squidfunk/mkdocs-material" %}
<a href="{{ page.edit_url }}" title="{{ lang.t('edit.link.title') }}" class="md-content__button md-icon">
{% include ".icons/material/file-edit-outline.svg" %}
</a>
<a href="{{ page.edit_url | replace(edit, view) }}" title="View source of this page" class="md-content__button md-icon">
{% include ".icons/material/file-eye-outline.svg" %}
</a>
{% endif %}
{% if "tags" in config.plugins %} {% if "tags" in config.plugins %}
{% include "partials/tags.html" %} {% include "partials/tags.html" %}
{% endif %} {% endif %}
{% include "overrides/partials/actions.html" %}
{% if not "\x3ch1" in page.content %} {% if not "\x3ch1" in page.content %}
<h1>{{ page.title | d(config.site_name, true)}}</h1> <h1>{{ page.title | d(config.site_name, true)}}</h1>
{% endif %} {% endif %}

View File

@ -0,0 +1,9 @@
{#-
This file was automatically generated - do not edit
-#}
{% if page.edit_url %}
<a href="{{ page.edit_url }}" title="{{ lang.t('edit.link.title') }}" class="md-content__button md-icon">
{% set icon = config.theme.icon.edit or "material/pencil" %}
{% include ".icons/" ~ icon ~ ".svg" %}
</a>
{% endif %}

View File

@ -1,15 +1,10 @@
{#- {#-
This file was automatically generated - do not edit This file was automatically generated - do not edit
-#} -#}
{% if page.edit_url %}
<a href="{{ page.edit_url }}" title="{{ lang.t('edit.link.title') }}" class="md-content__button md-icon">
{% set icon = config.theme.icon.edit or "material/pencil" %}
{% include ".icons/" ~ icon ~ ".svg" %}
</a>
{% endif %}
{% if "tags" in config.plugins %} {% if "tags" in config.plugins %}
{% include "partials/tags.html" %} {% include "partials/tags.html" %}
{% endif %} {% endif %}
{% include "partials/actions.html" %}
{% if not "\x3ch1" in page.content %} {% if not "\x3ch1" in page.content %}
<h1>{{ page.title | d(config.site_name, true)}}</h1> <h1>{{ page.title | d(config.site_name, true)}}</h1>
{% endif %} {% endif %}

View File

@ -0,0 +1,41 @@
<!--
Copyright (c) 2016-2022 Martin Donath <martin.donath@squidfunk.com>
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to
deal in the Software without restriction, including without limitation the
rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
sell copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in
all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
IN THE SOFTWARE.
-->
<!-- Edit and view button -->
{% if page.edit_url %}
{% set edit = "https://github.com/squidfunk/mkdocs-material/edit" %}
{% set view = "https://raw.githubusercontent.com/squidfunk/mkdocs-material" %}
<a
href="{{ page.edit_url }}"
title="{{ lang.t('edit.link.title') }}"
class="md-content__button md-icon"
>
{% include ".icons/material/file-edit-outline.svg" %}
</a>
<a
href="{{ page.edit_url | replace(edit, view) }}"
title="View source of this page"
class="md-content__button md-icon"
>
{% include ".icons/material/file-eye-outline.svg" %}
</a>
{% endif %}

View File

@ -20,31 +20,14 @@
IN THE SOFTWARE. IN THE SOFTWARE.
--> -->
<!-- Edit and view button -->
{% if page.edit_url %}
{% set edit = "https://github.com/squidfunk/mkdocs-material/edit" %}
{% set view = "https://raw.githubusercontent.com/squidfunk/mkdocs-material" %}
<a
href="{{ page.edit_url }}"
title="{{ lang.t('edit.link.title') }}"
class="md-content__button md-icon"
>
{% include ".icons/material/file-edit-outline.svg" %}
</a>
<a
href="{{ page.edit_url | replace(edit, view) }}"
title="View source of this page"
class="md-content__button md-icon"
>
{% include ".icons/material/file-eye-outline.svg" %}
</a>
{% endif %}
<!-- Tags --> <!-- Tags -->
{% if "tags" in config.plugins %} {% if "tags" in config.plugins %}
{% include "partials/tags.html" %} {% include "partials/tags.html" %}
{% endif %} {% endif %}
<!-- Actions -->
{% include "overrides/partials/actions.html" %}
<!-- <!--
Hack: check whether the content contains a h1 headline. If it doesn't, the Hack: check whether the content contains a h1 headline. If it doesn't, the
page title (or respectively site name) is used as the main headline. page title (or respectively site name) is used as the main headline.
@ -53,7 +36,7 @@
<h1>{{ page.title | d(config.site_name, true)}}</h1> <h1>{{ page.title | d(config.site_name, true)}}</h1>
{% endif %} {% endif %}
<!-- Markdown content --> <!-- Page content -->
{{ page.content }} {{ page.content }}
<!-- Source file information --> <!-- Source file information -->

33
src/partials/actions.html Normal file
View File

@ -0,0 +1,33 @@
<!--
Copyright (c) 2016-2022 Martin Donath <martin.donath@squidfunk.com>
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to
deal in the Software without restriction, including without limitation the
rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
sell copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in
all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
IN THE SOFTWARE.
-->
<!-- Edit button -->
{% if page.edit_url %}
<a
href="{{ page.edit_url }}"
title="{{ lang.t('edit.link.title') }}"
class="md-content__button md-icon"
>
{% set icon = config.theme.icon.edit or "material/pencil" %}
{% include ".icons/" ~ icon ~ ".svg" %}
</a>
{% endif %}

View File

@ -20,23 +20,14 @@
IN THE SOFTWARE. IN THE SOFTWARE.
--> -->
<!-- Edit button -->
{% if page.edit_url %}
<a
href="{{ page.edit_url }}"
title="{{ lang.t('edit.link.title') }}"
class="md-content__button md-icon"
>
{% set icon = config.theme.icon.edit or "material/pencil" %}
{% include ".icons/" ~ icon ~ ".svg" %}
</a>
{% endif %}
<!-- Tags --> <!-- Tags -->
{% if "tags" in config.plugins %} {% if "tags" in config.plugins %}
{% include "partials/tags.html" %} {% include "partials/tags.html" %}
{% endif %} {% endif %}
<!-- Actions -->
{% include "partials/actions.html" %}
<!-- <!--
Hack: check whether the content contains a h1 headline. If it doesn't, the Hack: check whether the content contains a h1 headline. If it doesn't, the
page title (or respectively site name) is used as the main headline. page title (or respectively site name) is used as the main headline.
@ -45,7 +36,7 @@
<h1>{{ page.title | d(config.site_name, true)}}</h1> <h1>{{ page.title | d(config.site_name, true)}}</h1>
{% endif %} {% endif %}
<!-- Markdown content --> <!-- Page content -->
{{ page.content }} {{ page.content }}
<!-- Source file information --> <!-- Source file information -->