Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

edit_uri incorrect for included projects whose site_name includes directory separator #127

Open
duncanmmacleod opened this issue May 21, 2024 · 0 comments · May be fixed by #128
Open

edit_uri incorrect for included projects whose site_name includes directory separator #127

duncanmmacleod opened this issue May 21, 2024 · 0 comments · May be fixed by #128

Comments

@duncanmmacleod
Copy link

This is a great plugin, thank you for providing and maintaining it!

I am using this plugin to embed third-party docs projects 'deep' (not at the top-level) in the hierarchy, like this:

site_name: "Test example"
repo_url: 'https://example.com/level1'
edit_uri: 'edit/docs'

nav:
  - Top: index.md
  - Level 1:
    - Level 1: level1/index.md
    - Level 2: '!include projects/level2/mkdocs.yml'

theme:
  name: 'material'
  features:
    - content.action.edit
    - content.action.view

plugins:
  - monorepo

where projects/level2 is a git submodule linked to a separate project whose mkdocs.yml looks like this:

site_name: 'level1/level2'
repo_url: 'https://example.com/level2'
edit_uri: 'edit/docs'
nav:
  - index.md

This results in the projects/level2/docs/index.md file in the git tree rendering at level1/level2/index.html in the site HTML tree, which is what I want. However, in this case, the edit_url for the the level2/docs/index.md file is rendered as:

https://example.com/level2/edit/docs/level2/index.md

This is incorrect, it should be

https://example.com/level2/edit/docs/index.md

All of this is available on github at https://github.com/duncanmmacleod/mkdocs-monorepo-plugin-edit_uri-example.

If this isn't an improper use of the plugin (please just tell me if this is the case), I think the fix should be

diff --git a/mkdocs_monorepo_plugin/edit_uri.py b/mkdocs_monorepo_plugin/edit_uri.py
index 4b0bbe5..a6b84d7 100644
--- a/mkdocs_monorepo_plugin/edit_uri.py
+++ b/mkdocs_monorepo_plugin/edit_uri.py
@@ -43,7 +43,7 @@ class EditUrl:
     return path.relpath(abs_page_config_file_dir, abs_root_config_file_dir)

   def __get_page_src_path(self):
-    alias = self.page.url.split('/')[0]
+    alias = self.__get_page_dir_alias()
     path = self.page.file.src_path
     return path.replace('{}/'.format(alias), '')

but I don't really understand the implications of this change on other use cases. I'm attempting to manipulate the __tests__ to reproduce this configuration and hope to be able to post a merge request including the patch.

duncanmmacleod added a commit to duncanmmacleod/mkdocs-monorepo-plugin that referenced this issue May 21, 2024
fixes backstage#127 and adds regression test for nested site_name in included project
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant