diff --git a/README.md b/README.md index 4ef09020ee78438614e49ccbaa0062e32ea9e8a6..2ad96de641b2936d6ace3cadb102a92b29be9109 100644 --- a/README.md +++ b/README.md @@ -8,6 +8,33 @@ Pour expérimenter rapidement mkdocs avec le DSFR, vous pouvez cloner le [projet d'exemple](https://gitlab-forge.din.developpement-durable.gouv.fr/pub/numeco/mkdocs-dsfr-exemple). + +## Configuration du dépôt et des liens d'édition + +Dans le fichier `mkdocs.yml`, trois configurations importantes sont définies pour permettre aux utilisateurs de naviguer vers le dépôt source et d'éditer les pages directement : + +* `repo_url`: URL du dépôt Git où le code source de la documentation est hébergé. +* `edit_uri`: Chemin relatif vers le dossier contenant les fichiers Markdown de la documentation dans le dépôt Git. +* `edit_text`: Texte à afficher pour le lien d'édition. + +### Exemple de configuration + +Dans ce projet, les configurations sont définies comme suit : + +<pre><div class="bg-black rounded-md mb-4"><div class="flex items-center relative text-gray-200 bg-gray-800 px-4 py-2 text-xs font-sans justify-between rounded-t-md"><span>yaml</span><button class="flex ml-auto gap-2"><svg stroke="currentColor" fill="none" stroke-width="2" viewBox="0 0 24 24" stroke-linecap="round" stroke-linejoin="round" class="h-4 w-4" height="1em" width="1em" xmlns="http://www.w3.org/2000/svg"><path d="M16 4h2a2 2 0 0 1 2 2v14a2 2 0 0 1-2 2H6a2 2 0 0 1-2-2V6a2 2 0 0 1 2-2h2"></path><rect x="8" y="2" width="8" height="4" rx="1" ry="1"></rect></svg>Copy code</button></div><div class="p-4 overflow-y-auto"><code class="!whitespace-pre hljs language-yaml">repo_url: https://gitlab-forge.din.developpement-durable.gouv.fr/pub/numeco/mkdocs-dsfr/ +edit_uri: blob/main/docs/ +edit_text: Éditer dans Gitlab Forge +</code></div></div></pre> + +### Comment cela fonctionne + +* `repo_url` pointe vers le dépôt GitLab où se trouve le code source de la documentation. +* `edit_uri` indique le chemin relatif vers les fichiers Markdown dans ce dépôt. +* `edit_text` spécifie le texte qui sera affiché pour le lien d'édition. + +Si l'une de ces variables n'est pas remplie, le lien d'édition n'apparaîtra pas. + + ## Configuration du thème DSFR MkDocs Ce document décrit les différentes options de configuration pour le thème DSFR MkDocs. diff --git a/dsfr/base.html b/dsfr/base.html index 8d98050b21ee8a14bb634ac7a8467378c2a4874b..48b48f54db30b2c18f7a08a02f1022287d46116f 100644 --- a/dsfr/base.html +++ b/dsfr/base.html @@ -36,7 +36,6 @@ </title> {# {% block extrahead %}{% endblock %} #} {# {%- block libs %} - <script src="{{ 'js/jquery-1.10.2.min.js'|url }}" defer></script> <script src="{{ 'js/bootstrap.min.js'|url }}" defer></script> {%- endblock %} #} </head> diff --git a/dsfr/css/theme.css b/dsfr/css/theme.css index 3f096805c638d7c763558b8adab856f593f1ec50..7276238243606c86eab5a1719772163ff176b229 100644 --- a/dsfr/css/theme.css +++ b/dsfr/css/theme.css @@ -230,3 +230,11 @@ th { .revision-date { text-align: center; } + +@media (min-width: 62em) { + .fr-header .fr-nav { + display: flex; + align-items: center; + justify-content: space-between; + } +} diff --git a/dsfr/nav.html b/dsfr/nav.html index b62a897c90c38416c4aeb1a60c32cd5e4de9dce1..021469c0178ff1bf0650f80333abe0496bc4850b 100644 --- a/dsfr/nav.html +++ b/dsfr/nav.html @@ -1,4 +1,4 @@ -<nav class="fr-nav" id="navigation-547" role="navigation" aria-label="Menu principal"> +<nav class="fr-nav navbar-header" id="navigation-547" role="navigation" aria-label="Menu principal"> <ul class="fr-nav__list"> {% for nav_item in nav %} {% if not nav_item.children %} @@ -21,4 +21,11 @@ {% endif %} {% endfor %} </ul> + {% if page.file and config.repo_url and config.edit_uri %} + <a href="{{ config.repo_url }}{{ config.edit_uri }}{{ page.file.src_path }}" target="_blank" rel="noopener"> + {{ config.edit_text }} + </a> + {% endif %} + + </nav> diff --git a/mkdocs.yml b/mkdocs.yml index 8fb58eabc9d47237b72b718b89925390539c69f2..7725740c58b3c8d97448ec88a5298c8139d1d7c1 100644 --- a/mkdocs.yml +++ b/mkdocs.yml @@ -3,8 +3,9 @@ site_url: https://www.mkdocs.org/ site_description: Project documentation with Markdown. site_author: MkDocs Team -repo_url: https://github.com/mkdocs/mkdocs/ -edit_uri: blob/master/docs/ +repo_url: https://gitlab-forge.din.developpement-durable.gouv.fr/pub/numeco/mkdocs-dsfr/ +edit_uri: blob/main/docs/ +edit_text: Éditer dans Gitlab Forge theme: