diff --git a/src/base.html b/src/base.html index e6c278a4a..897b3688f 100644 --- a/src/base.html +++ b/src/base.html @@ -300,23 +300,7 @@ {% block source %} {% if page and page.meta and page.meta.source %} - {% set repo = config.repo_url %} - {% if repo | last == "/" %} - {% set repo = repo[:-1] %} - {% endif %} - {% set path = page.meta.path | default([""]) %} - {% set file = page.meta.source %} - {% set repo_icon = config.extra.repo_icon | default( - "fontawesome/brands/git-alt" - ) %} - - {{ lang.t("meta.source") }} - {% include ".icons/" ~ repo_icon ~ ".svg" %} - + {% include "partials/source-link.html" %} {% endif %} {% endblock %} @@ -332,26 +316,13 @@ {{ page.content }} - - {% if page and page.meta and ( - page.meta.git_revision_date_localized or - page.meta.revision_date - ) %} - {% set label = lang.t("source.revision.date") %} -
-
- - - - {% if page.meta.git_revision_date_localized %} - {{ label }}: {{ page.meta.git_revision_date_localized }} - - - {% elif page.meta.revision_date %} - {{ label }}: {{ page.meta.revision_date }} - {% endif %} - -
+ + {% if page and page.meta %} + {% if page.meta.git_revision_date_localized or + page.meta.revision_date + %} + {% include "partials/source-date.html" %} + {% endif %} {% endif %} {% endblock %} diff --git a/src/partials/source-date.html b/src/partials/source-date.html new file mode 100644 index 000000000..2a5f0eef0 --- /dev/null +++ b/src/partials/source-date.html @@ -0,0 +1,40 @@ + + +{% import "partials/language.html" as lang with context %} + + +{% set label = lang.t("source.revision.date") %} +
+
+ + + + {% if page.meta.git_revision_date_localized %} + {{ label }}: {{ page.meta.git_revision_date_localized }} + + + {% elif page.meta.revision_date %} + {{ label }}: {{ page.meta.revision_date }} + {% endif %} + +
diff --git a/src/partials/source-link.html b/src/partials/source-link.html new file mode 100644 index 000000000..9807bd705 --- /dev/null +++ b/src/partials/source-link.html @@ -0,0 +1,42 @@ + + +{% import "partials/language.html" as lang with context %} + + +{% set repo = config.repo_url %} +{% if repo | last == "/" %} + {% set repo = repo[:-1] %} +{% endif %} +{% set path = page.meta.path | default([""]) %} +{% set file = page.meta.source %} +{% set repo_icon = config.extra.repo_icon | default( + "fontawesome/brands/git-alt" +) %} + + {{ lang.t("meta.source") }} + {% include ".icons/" ~ repo_icon ~ ".svg" %} +