module Jekyll::Algolia::FileBrowser
def self.relative_path(filepath)
Public: Return the path of a Jekyll file relative to the Jekyll source
def self.relative_path(filepath) pathname = Pathname.new(filepath) config_source = Configurator.get('source') || '' jekyll_source = Pathname.new(File.expand_path(config_source)) # Removing any starting ./ if pathname.relative? fullpath = File.expand_path(File.join(jekyll_source, pathname)) return fullpath.gsub(%r{^#{jekyll_source}/}, '') end pathname.relative_path_from(jekyll_source).cleanpath.to_s end