tailwindcss.rb 1.7 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859
  1. module Docs
  2. class Tailwindcss < UrlScraper
  3. self.name = 'Tailwind CSS'
  4. self.type = 'tailwindcss'
  5. self.slug = 'tailwindcss'
  6. self.base_url = 'https://tailwindcss.com/docs'
  7. self.root_path = '/'
  8. self.release = '3.0.23'
  9. self.links = {
  10. home: 'tps://tailwindcss.com/',
  11. code: 'https://github.com/tailwindlabs/tailwindcss'
  12. }
  13. html_filters.push 'tailwindcss/entries', 'tailwindcss/clean_html'
  14. # Disable the clean text filter which removes empty nodes - we'll do it ourselves more selectively
  15. text_filters.replace("clean_text", "tailwindcss/noop")
  16. # Fix redirects from older tailwind 2 docs
  17. options[:fix_urls] = lambda do |url|
  18. if url.include? "installation/"
  19. break "/docs/installation"
  20. end
  21. if url.end_with? "/breakpoints"
  22. break "/docs/screens#{/#.*$/.match(url)}"
  23. end
  24. if url.end_with? "/adding-base-styles"
  25. break "/docs/adding-custom-styles#adding-base-styles"
  26. end
  27. if url.end_with? "/ring-opacity"
  28. break "/docs/ring-color#changing-the-opacity"
  29. end
  30. if url.match(/\/colors#?/)
  31. break "/docs/customizing-colors#{/#.*$/.match(url)}"
  32. end
  33. end
  34. options[:skip_patterns] = [
  35. # Skip setup instructions
  36. /\/browser-support$/,
  37. /\/editor-setup$/,
  38. /\/installation$/,
  39. /\/optimizing-for-production$/,
  40. /\/upgrade-guide/,
  41. /\/using-with-preprocessors/
  42. ]
  43. #Obtainable from https://github.com/tailwindlabs/tailwindcss/blob/master/LICENSE
  44. options[:attribution] = <<-HTML
  45. &copy; 2022 Tailwind Labs Inc.
  46. HTML
  47. def get_latest_version(opts)
  48. get_latest_github_release('tailwindlabs', 'tailwindcss', opts)
  49. end
  50. end
  51. end