You can not select more than 25 topics Topics must start with a chinese character,a letter or number, can include dashes ('-') and can be up to 35 characters long.

file_exists.rb 904 B

2 years ago
12345678910111213141516171819202122232425
  1. # source: https://github.com/michaelx/jekyll_file_exists/blob/dd363223754836a640de81ddab68fd95cebe7791/file_exists.rb
  2. module Jekyll
  3. class FileExistsTag < Liquid::Tag
  4. def initialize(tag_name, path, tokens)
  5. super
  6. @path = path
  7. end
  8. def render(context)
  9. # Pipe parameter through Liquid to make additional replacements possible
  10. url = Liquid::Template.parse(@path).render context
  11. # Adds the site source, so that it also works with a custom one
  12. site_source = context.registers[:site].config['source']
  13. dir_name = File.dirname(context.environments.first["page"]["path"])
  14. file_path = File.join(site_source, dir_name, url.strip)
  15. # Check if file exists (returns true or false)
  16. "#{File.exist?(file_path)}"
  17. end
  18. end
  19. end
  20. Liquid::Template.register_tag('file_exists', Jekyll::FileExistsTag)

js yarn包管理组件依赖分析

Contributors (1)