From 9071837183fd33003390717e1550adc12d1fea07 Mon Sep 17 00:00:00 2001 From: matcornic Date: Mon, 4 Sep 2017 21:20:59 +0200 Subject: [PATCH] fix #61 --- exampleSite/content/_index.en.md | 4 ++-- exampleSite/content/_index.fr.md | 6 +++--- .../content/basics/configuration/_index.fr.md | 2 +- layouts/shortcodes/ref.html | 14 ++++++++++++++ layouts/shortcodes/relref.html | 8 +++++--- 5 files changed, 25 insertions(+), 9 deletions(-) create mode 100644 layouts/shortcodes/ref.html diff --git a/exampleSite/content/_index.en.md b/exampleSite/content/_index.en.md index 822792e7bb..a36357957c 100644 --- a/exampleSite/content/_index.en.md +++ b/exampleSite/content/_index.en.md @@ -13,7 +13,7 @@ This theme is a partial porting of the [Learn theme](http://learn.getgrav.org/) ## Main features -* [Automatic Search]({{%relref "basics/configuration/_index.md" %}}) +* [Automatic Search]({{%relref "basics/configuration/_index.md#activate-search" %}}) * [Multilingual mode]({{%relref "cont/i18n/_index.md" %}}) * **Unlimited menu levels** * **Automatic next/prev buttons to navigate through menu entries** @@ -21,7 +21,7 @@ This theme is a partial porting of the [Learn theme](http://learn.getgrav.org/) * [Attachments files]({{%relref "shortcodes/attachments.en.md" %}}) * [List child pages]({{%relref "shortcodes/children/_index.md" %}}) * [Mermaid diagram]({{%relref "shortcodes/mermaid.en.md" %}}) (flowchart, sequence, gantt) -* [Customizable look and feel and themes variants]({{%relref "basics/configuration/_index.md"%}}) +* [Customizable look and feel and themes variants]({{%relref "basics/style-customization/_index.md"%}}) * [Buttons]({{%relref "shortcodes/button.en.md" %}}), [Tip/Note/Info/Warning boxes]({{%relref "shortcodes/notice.en.md" %}}), [Expand]({{%relref "shortcodes/expand.en.md" %}}) ![Screenshot](https://github.com/matcornic/hugo-theme-learn/raw/master/images/screenshot.png?width=40pc&classes=shadow) diff --git a/exampleSite/content/_index.fr.md b/exampleSite/content/_index.fr.md index 5e642ebd48..40b2dc3521 100644 --- a/exampleSite/content/_index.fr.md +++ b/exampleSite/content/_index.fr.md @@ -11,9 +11,9 @@ Ce thème est un portage partiel du [thème Learn](http://learn.getgrav.org/) de {{% notice tip %}}Le thème Learn fonctionne grâce à la structure de page aborescentes pour organiser le contenu: tous les contenus sont des pages qui appartiennent à d'autres pages. [Plus d'infos]({{%relref "cont/pages/_index.md"%}}) {{% /notice %}} -## Fonctionnalité principales +## Fonctionnalités principales -* [Recherche automatique]({{%relref "basics/configuration/_index.md" %}}) +* [Recherche automatique]({{%relref "basics/configuration/_index.md#activer-recherche" %}}) * [Mode multi-langue]({{%relref "cont/i18n/_index.md" %}}) * **Nombre de niveau infini dans le menu** * **Boutons suivant/précédent automatiquement générés pour naviguer entre les items du menu** @@ -21,7 +21,7 @@ Ce thème est un portage partiel du [thème Learn](http://learn.getgrav.org/) de * [Fichiers joints]({{%relref "shortcodes/attachments.fr.md" %}}) * [Lister les pages filles]({{%relref "shortcodes/children/_index.md" %}}) * [Diagrammes Mermaid]({{%relref "shortcodes/mermaid.fr.md" %}}) (flowchart, sequence, gantt) -* [Style configurable and variantes de couleurs]({{%relref "basics/configuration/_index.md"%}}) +* [Style configurable and variantes de couleurs]({{%relref "basics/style-customization/_index.md"%}}) * [Boutons]({{%relref "shortcodes/button.fr.md" %}}), [Messages Astuce/Note/Info/Attention]({{%relref "shortcodes/notice.fr.md" %}}), [Expand]({{%relref "shortcodes/expand.fr.md" %}}) ![Screenshot](https://github.com/matcornic/hugo-theme-learn/raw/master/images/screenshot.png?width=40pc&classes=shadow) diff --git a/exampleSite/content/basics/configuration/_index.fr.md b/exampleSite/content/basics/configuration/_index.fr.md index efb1bddc80..fece4d090f 100644 --- a/exampleSite/content/basics/configuration/_index.fr.md +++ b/exampleSite/content/basics/configuration/_index.fr.md @@ -39,7 +39,7 @@ Notez que certains de ces paramètres sont expliqués en détails dans d'autres themeVariant = "" ``` -## Activer la recherche +## Activer la recherche {#activer-recherche} Si ce n'est pas déjà présent, ajoutez les lignes suivantes dans le fichier `config.toml`. diff --git a/layouts/shortcodes/ref.html b/layouts/shortcodes/ref.html new file mode 100644 index 0000000000..e7f769e739 --- /dev/null +++ b/layouts/shortcodes/ref.html @@ -0,0 +1,14 @@ +{{- if in (.Get 0) "/_index.md" -}} + {{- $paths := (split (.Get 0) "_index.md") -}} + {{- $pagepath := index $paths 0 -}} + {{- $anchor := index $paths 1 -}} + {{- with .Site.GetPage "section" (trim $pagepath "/") -}} + {{- ( printf "%s%s" $pagepath $anchor ) | relLangURL -}} + {{- end -}} +{{- else -}} + {{- with .Site.GetPage "section" (.Get 0) }} + {{- .URL -}} + {{- else -}} + {{- .Get 0 | relref .Page -}} + {{- end -}} +{{- end -}} \ No newline at end of file diff --git a/layouts/shortcodes/relref.html b/layouts/shortcodes/relref.html index 5cb8116290..e7f769e739 100644 --- a/layouts/shortcodes/relref.html +++ b/layouts/shortcodes/relref.html @@ -1,7 +1,9 @@ {{- if in (.Get 0) "/_index.md" -}} - {{- $path := (trim (.Get 0) "_index.md") -}} - {{- with .Site.GetPage "section" (trim $path "/") -}} - {{- .URL -}} + {{- $paths := (split (.Get 0) "_index.md") -}} + {{- $pagepath := index $paths 0 -}} + {{- $anchor := index $paths 1 -}} + {{- with .Site.GetPage "section" (trim $pagepath "/") -}} + {{- ( printf "%s%s" $pagepath $anchor ) | relLangURL -}} {{- end -}} {{- else -}} {{- with .Site.GetPage "section" (.Get 0) }}