Repository: ovasquez/mkdocs-merge

Issue:
Add support for section index pages
Hey there!

Firstly, thank you so much for this amazing tool!

In our company, we use it in combo with [MkDocs Material](https://squidfunk.github.io/mkdocs-material/). Not sure about original MkDocs, but in this version, there is an option to set index pages for sections. To get a better understanding, please take a look at [feature description](https://squidfunk.github.io/mkdocs-material/setup/setting-up-navigation/#section-index-pages).

It's very simple, and what it means, is that basically you may now have a nav entry in `mkdocs.yml` that looks like this:
```yaml
nav:
  - Home: index.md
  - Section:
    - section/index.md                             #   <--- this right here is new!
    - Page 1: section/page-1.md
    ...
    - Page n: section/page-n.md
```

Those kind of entries are currently not supported and result in "Error merging the "nav" entry in the site:   xxxx".

I've taken a quick look at the code - to me seems like a new elif in recursive function `update_navs` should be added where `nav` can be instance of `str`, or sth like that. 

I hope you'll have a bit of time to consider this.

Thanks!

Comments:

Patch:
diff --git a/mkdocsmerge/merge.py b/mkdocsmerge/merge.py
index 5ed4499..279b9d4 100644
--- a/mkdocsmerge/merge.py
+++ b/mkdocsmerge/merge.py
@@ -147,7 +147,10 @@ def update_navs(navs, site_root, print_func):
     """
     if isinstance(navs, list):
         for page in navs:
-            update_navs(page, site_root, print_func)
+            if isinstance(page, str):
+                navs[navs.index(page)] = site_root + "/" + page
+            else:
+                update_navs(page, site_root, print_func)
     elif isinstance(navs, dict):
         for name, path in navs.items():
             if isinstance(path, str):


Test patch:
diff --git a/mkdocsmerge/tests/merge_test.py b/mkdocsmerge/tests/merge_test.py
index 62138e9..dee9cf0 100644
--- a/mkdocsmerge/tests/merge_test.py
+++ b/mkdocsmerge/tests/merge_test.py
@@ -113,3 +113,31 @@ class TestSiteMerges(unittest.TestCase):
         mkdocsmerge.merge.merge_single_site(
             global_nav, site_name, site_nav, True)
         self.assertEqual(global_nav, expected)
+
+    def test_update_pages_with_section_indexes(self):
+        """
+        Verifies the correct updating of the section index pages' paths.
+        """
+        # Create original and expected data structures
+        subpage = 'new_root'
+        subpage_path = subpage + '/'
+        nav = [{'Home': 'index.md'},
+               {'Projects': [
+                   'projects/index.md',
+                   {'Nested': [
+                       'projects/nested/index.md',
+                       {'Third': 'projects/nest/third.md'}
+                   ]}
+               ]}]
+
+        expected = [{'Home': subpage_path + 'index.md'},
+                    {'Projects': [
+                        subpage_path + 'projects/index.md',
+                        {'Nested': [
+                            subpage_path + 'projects/nested/index.md',
+                            {'Third': subpage_path + 'projects/nest/third.md'}
+                        ]}
+                    ]}]
+
+        mkdocsmerge.merge.update_navs(nav, subpage, lambda x: None)
+        self.assertEqual(nav, expected)