Closed mihaigalos closed 4 months ago
Hee,
Have a look at the docs for customizing a theme.
Hi Tim,
I've used this maybe naive approach:
cat <<EOF >docs/mkdocs/settings/overrides/content.html
{% if page.meta.source %}
<div class="source-links">
{% for filename in page.meta.source %}
<span class="label label-primary">{{ filename }}</span>
{% endfor %}
</div>
{% endif %}
{% if page.meta.git_revision_date_localized %}
<small>Last update: {{ page.meta.git_revision_date_localized }}</small>
{% endif %}
{% if page.meta.git_created_date_localized %}
<small>Created: {{ page.meta.git_created_date_localized }}</small>
{% endif %}
{{ page.content }}
EOF
Then referenced it:
theme:
name: material
+ custom_dir: docs/mkdocs/settings/overrides
This path seems to be understood by mkdocs serve
, but the change dates don't end up towards the top of the page (still at the bottom of it). Could the path be wrong? - I've tried using custom_dir: mkdocs/settings/overrides
and I get an error while rebuilding the docs.
Try putting some plain text there, outside of the if blocks. Then you can see if your override works.
See the docs of mkdocs, or mkdocs-material for details on how to create overrides.
Also note that mkdocs-material has built-in support for this plugin, adding it to the bottom for you.
You can open an issue if you encounter a bug specific to this plugin
Hi Tim,
Thanks for the info. I got it running with:
docs/mkdocs/settings/overrides/partials/content.html
:
{% if "material/tags" in config.plugins and tags %}
{% include "partials/tags.html" %}
{% endif %}
{% include "partials/actions.html" %}
{% if "\x3ch1" not in page.content %}
<h1>{{ page.title | d(config.site_name, true)}}</h1>
{% endif %}
-{{ page.content }}
{% include "partials/source-file.html" %}
+{{ page.content }}
{% include "partials/feedback.html" %}
{% include "partials/comments.html" %}
Hi,
Is there any property one can use to output to top of the page? Potentially after the 1st h1?