Call ruby function to discover permalink?

I am writing a VSCode extension that would like to discover the published URL of a Jekyll post. Turns out that is not an easy thing to do, in the general case. Does Jekyll expose an entry point that would allow an external process to obtain the published URL for a given document? I am happy to invoke a Ruby method and pass in the document URL, relative to the website root.

Jekyll CLI doesn’t support that.

VS Code aside, it would be easy to write a plugin in _plugins that has site as the object it is called with. Or your post filename as additional argument

And all it does then is print to stdout. the full domain, base url, and path for a given post. As one value.

Once you have that going you can figure out how to run the plugin via Ruby so you don’t have to wait for a jekyll build.

E.g.

bundle exec ruby _plugins/my-plugin.rb

Then take that further. Put the plugin as Ruby code inside your plugin. As a string in JS or as a file that exists wherever your extension is installed to. And you run your ruby or bundle command via the shell in JS

Then hopefully you can call the plugin/script from anywhere and it will know which Jekyll project is running for.


Alternatively if the user has jekyll sitemap plugin and a built site you can look for the post URL in the xml file.

Michael,

Thanks for the suggestions. I am writing a plugin to automatically maintain the redirects. No need for manually doing anything with Visual Studio. HTTP 301 redirect pages will be created automatically whenever a page or post is moved or deleted. WIP, still early days: GitHub - mslinn/jekyll_auto_redirect.

I am blogging as I go: Installing Rubocop As a Development Dependency

Mike