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

set_edit_path() has no effect when edit_uri_template is used #37

Open
frankkusters opened this issue Jan 30, 2025 · 0 comments
Open

set_edit_path() has no effect when edit_uri_template is used #37

frankkusters opened this issue Jan 30, 2025 · 0 comments

Comments

@frankkusters
Copy link

I'm using the Mkdocs option edit_uri_template, which is mutually exclusive with edit_uri.

set_edit_path() has no effect in my setup (the page.edit_url remains empty). It's caused by this section:

def on_page_content(self, html, page: Page, config: Config, files: Files):
repo_url = config.get("repo_url", None)
edit_uri = config.get("edit_uri", None)
src_path = pathlib.PurePath(page.file.src_path).as_posix()
if src_path in self._edit_paths:
path = self._edit_paths.pop(src_path)
if repo_url and edit_uri:
# Ensure urljoin behavior is correct

With mkdocs 1.6, it is possible to set file.edit_uri:
Enabling true generated files and expanding the File API

I'm not sure what version of mkdocs you are targeting. For now I'm working around it with this hook:

def on_files(files: Files, config: MkDocsConfig, **kwargs) -> Files:
    edit_paths = config.plugins['gen-files']._edit_paths
    for src_uri in list(edit_paths.keys()):
        edit_uri = edit_paths.pop(src_uri)
        files.get_file_from_path(src_uri).edit_uri = edit_uri
    return files
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

No branches or pull requests

1 participant