Skip to content

Commit c6dd6b6

Browse files
committed
Moved page edit action into separate partial
1 parent 141bd2e commit c6dd6b6

File tree

8 files changed

+106
-50
lines changed

8 files changed

+106
-50
lines changed
+13
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
{#-
2+
This file was automatically generated - do not edit
3+
-#}
4+
{% if page.edit_url %}
5+
{% set edit = "https://github.com/squidfunk/mkdocs-material/edit" %}
6+
{% set view = "https://raw.githubusercontent.com/squidfunk/mkdocs-material" %}
7+
<a href="{{ page.edit_url }}" title="{{ lang.t('edit.link.title') }}" class="md-content__button md-icon">
8+
{% include ".icons/material/file-edit-outline.svg" %}
9+
</a>
10+
<a href="{{ page.edit_url | replace(edit, view) }}" title="View source of this page" class="md-content__button md-icon">
11+
{% include ".icons/material/file-eye-outline.svg" %}
12+
</a>
13+
{% endif %}

material/overrides/partials/content.html

+1-10
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,10 @@
11
{#-
22
This file was automatically generated - do not edit
33
-#}
4-
{% if page.edit_url %}
5-
{% set edit = "https://github.com/squidfunk/mkdocs-material/edit" %}
6-
{% set view = "https://raw.githubusercontent.com/squidfunk/mkdocs-material" %}
7-
<a href="{{ page.edit_url }}" title="{{ lang.t('edit.link.title') }}" class="md-content__button md-icon">
8-
{% include ".icons/material/file-edit-outline.svg" %}
9-
</a>
10-
<a href="{{ page.edit_url | replace(edit, view) }}" title="View source of this page" class="md-content__button md-icon">
11-
{% include ".icons/material/file-eye-outline.svg" %}
12-
</a>
13-
{% endif %}
144
{% if "tags" in config.plugins %}
155
{% include "partials/tags.html" %}
166
{% endif %}
7+
{% include "overrides/partials/actions.html" %}
178
{% if not "\x3ch1" in page.content %}
189
<h1>{{ page.title | d(config.site_name, true)}}</h1>
1910
{% endif %}

material/partials/actions.html

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

material/partials/content.html

+1-6
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,10 @@
11
{#-
22
This file was automatically generated - do not edit
33
-#}
4-
{% if page.edit_url %}
5-
<a href="{{ page.edit_url }}" title="{{ lang.t('edit.link.title') }}" class="md-content__button md-icon">
6-
{% set icon = config.theme.icon.edit or "material/pencil" %}
7-
{% include ".icons/" ~ icon ~ ".svg" %}
8-
</a>
9-
{% endif %}
104
{% if "tags" in config.plugins %}
115
{% include "partials/tags.html" %}
126
{% endif %}
7+
{% include "partials/actions.html" %}
138
{% if not "\x3ch1" in page.content %}
149
<h1>{{ page.title | d(config.site_name, true)}}</h1>
1510
{% endif %}

src/overrides/partials/actions.html

+41
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
<!--
2+
Copyright (c) 2016-2022 Martin Donath <[email protected]>
3+
4+
Permission is hereby granted, free of charge, to any person obtaining a copy
5+
of this software and associated documentation files (the "Software"), to
6+
deal in the Software without restriction, including without limitation the
7+
rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
8+
sell copies of the Software, and to permit persons to whom the Software is
9+
furnished to do so, subject to the following conditions:
10+
11+
The above copyright notice and this permission notice shall be included in
12+
all copies or substantial portions of the Software.
13+
14+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
15+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
16+
FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT. IN NO EVENT SHALL THE
17+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
18+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
19+
FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
20+
IN THE SOFTWARE.
21+
-->
22+
23+
<!-- Edit and view button -->
24+
{% if page.edit_url %}
25+
{% set edit = "https://github.com/squidfunk/mkdocs-material/edit" %}
26+
{% set view = "https://raw.githubusercontent.com/squidfunk/mkdocs-material" %}
27+
<a
28+
href="{{ page.edit_url }}"
29+
title="{{ lang.t('edit.link.title') }}"
30+
class="md-content__button md-icon"
31+
>
32+
{% include ".icons/material/file-edit-outline.svg" %}
33+
</a>
34+
<a
35+
href="{{ page.edit_url | replace(edit, view) }}"
36+
title="View source of this page"
37+
class="md-content__button md-icon"
38+
>
39+
{% include ".icons/material/file-eye-outline.svg" %}
40+
</a>
41+
{% endif %}

src/overrides/partials/content.html

+4-21
Original file line numberDiff line numberDiff line change
@@ -20,31 +20,14 @@
2020
IN THE SOFTWARE.
2121
-->
2222

23-
<!-- Edit and view button -->
24-
{% if page.edit_url %}
25-
{% set edit = "https://github.com/squidfunk/mkdocs-material/edit" %}
26-
{% set view = "https://raw.githubusercontent.com/squidfunk/mkdocs-material" %}
27-
<a
28-
href="{{ page.edit_url }}"
29-
title="{{ lang.t('edit.link.title') }}"
30-
class="md-content__button md-icon"
31-
>
32-
{% include ".icons/material/file-edit-outline.svg" %}
33-
</a>
34-
<a
35-
href="{{ page.edit_url | replace(edit, view) }}"
36-
title="View source of this page"
37-
class="md-content__button md-icon"
38-
>
39-
{% include ".icons/material/file-eye-outline.svg" %}
40-
</a>
41-
{% endif %}
42-
4323
<!-- Tags -->
4424
{% if "tags" in config.plugins %}
4525
{% include "partials/tags.html" %}
4626
{% endif %}
4727

28+
<!-- Actions -->
29+
{% include "overrides/partials/actions.html" %}
30+
4831
<!--
4932
Hack: check whether the content contains a h1 headline. If it doesn't, the
5033
page title (or respectively site name) is used as the main headline.
@@ -53,7 +36,7 @@
5336
<h1>{{ page.title | d(config.site_name, true)}}</h1>
5437
{% endif %}
5538

56-
<!-- Markdown content -->
39+
<!-- Page content -->
5740
{{ page.content }}
5841

5942
<!-- Source file information -->

src/partials/actions.html

+33
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
<!--
2+
Copyright (c) 2016-2022 Martin Donath <[email protected]>
3+
4+
Permission is hereby granted, free of charge, to any person obtaining a copy
5+
of this software and associated documentation files (the "Software"), to
6+
deal in the Software without restriction, including without limitation the
7+
rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
8+
sell copies of the Software, and to permit persons to whom the Software is
9+
furnished to do so, subject to the following conditions:
10+
11+
The above copyright notice and this permission notice shall be included in
12+
all copies or substantial portions of the Software.
13+
14+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
15+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
16+
FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT. IN NO EVENT SHALL THE
17+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
18+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
19+
FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
20+
IN THE SOFTWARE.
21+
-->
22+
23+
<!-- Edit button -->
24+
{% if page.edit_url %}
25+
<a
26+
href="{{ page.edit_url }}"
27+
title="{{ lang.t('edit.link.title') }}"
28+
class="md-content__button md-icon"
29+
>
30+
{% set icon = config.theme.icon.edit or "material/pencil" %}
31+
{% include ".icons/" ~ icon ~ ".svg" %}
32+
</a>
33+
{% endif %}

src/partials/content.html

+4-13
Original file line numberDiff line numberDiff line change
@@ -20,23 +20,14 @@
2020
IN THE SOFTWARE.
2121
-->
2222

23-
<!-- Edit button -->
24-
{% if page.edit_url %}
25-
<a
26-
href="{{ page.edit_url }}"
27-
title="{{ lang.t('edit.link.title') }}"
28-
class="md-content__button md-icon"
29-
>
30-
{% set icon = config.theme.icon.edit or "material/pencil" %}
31-
{% include ".icons/" ~ icon ~ ".svg" %}
32-
</a>
33-
{% endif %}
34-
3523
<!-- Tags -->
3624
{% if "tags" in config.plugins %}
3725
{% include "partials/tags.html" %}
3826
{% endif %}
3927

28+
<!-- Actions -->
29+
{% include "partials/actions.html" %}
30+
4031
<!--
4132
Hack: check whether the content contains a h1 headline. If it doesn't, the
4233
page title (or respectively site name) is used as the main headline.
@@ -45,7 +36,7 @@
4536
<h1>{{ page.title | d(config.site_name, true)}}</h1>
4637
{% endif %}
4738

48-
<!-- Markdown content -->
39+
<!-- Page content -->
4940
{{ page.content }}
5041

5142
<!-- Source file information -->

0 commit comments

Comments
 (0)