Package: mkdocs-crosslink-plugin
mkdocs-crosslink-pluginThis package allows you to add links to other MkDocs sites (or sites created with similar page generator).UsageFirst install the PyPI package:pipinstallmkdocs-crosslink-pluginAdd something like the following to yourmkdocs.yml:plugins:-search-crosslink:crosslinks:-name:alphasource_dir:site_a/docstarget_url:http://localhost:8000/site_a/use_directory_urls:False-name:"example"source_dir:/var/www/html/example.com/target_url:https://example.com/use_directory_urls:TrueEach crosslink has the following attributes:name: How you reference the site.
By default the schema isx-NAME:FILE_NAME(so for examplex-alpha:my-image.png).source_diris the directory containing the Markdown files.target_urlis the path, where the site corresponding to thesource_dirfiles are hosted.use_directory_urlsshould correspond to the target site'suse_directory_urlssettings.If enabledpath/index.mdwill be mapped topath/andpath/test.mdwill be mapped topath/test/.If disabledpath/index.mdwill be mapped topath/index.htmlandpath/test.mdwill be mapped topath/test.html.Starting with version 0.0.2 you can also define multiple crosslinks at once, by using a glob-like syntax.
Inject a*character in thename,source_dir, andtarget_url.
The plugin will then look for directories matching thesource_dirglob, create a crosslink for each one that was not defined before, and replace the*in thenameandtarget_urlwith the same value that it matched in thesource_dirvalue.Starting with version 0.0.2 there is also a builtinlocalcrosslink, which can be used to reference files in the current site, similar to other autolink tools.On your pages you can reference links and images to other sites with thex-SITE_NAME:FILE_NAMEsyntax.
For example to load the imagemy-image.pngsomewhere from thehttps://example.com/(crosslinkexample) you would use the syntax:![My Image](x-example:my-image.png)If multiple files with the exact same name exist, there is currently now way to reference the correct one.
In the future I plan to let you specify a part of the path to select the correct file.
From 0.0.2 on: For index files (index.mdorindex.html) you can reference them by the name of the parent's directory followed by a slash.
So/path/to/some/index.mdcan be referenced assome/.Compatibility with other autolink pluginsIn theory, this plugin should work side by side with other autolink plugins.
This is because the default schemax-NAME:is basically a fake URL schema that any other plugins should not touch.
At the same time this plugin ignores normal links, which are processed by other autolink plugins.Known problems exist withmkdocs-ezlinks-pluginbecause it expects custom URL schemas to be followed by//(likex-NAME://) as can be seen by themailto:issue.
You can work around this, by using links followed by a double slash and setting the correct suffix in the plugin settings:plugins:-search-crosslink:suffix:"://"crosslinks:-name:"site_a"...TestingSome very basic tests are indocs(main site),site_a(crosslink alpha), andsite_b(crosslink bravo).
You can build and serve the test site by running./build.sh.Notable changesVersion 0.0.3Just some bug fixesVersion 0.0.2Added builtinlocalcrosslinkReferenceindex.mdas<PARENT_DIR_NAME>/Added glob support for crosslinksAdded profiling option (show_profiling_results: True)