Merge pull request #2134 from freeCodeCamp/htmx

Add htmx documentation
This commit is contained in:
Simon Legner 2024-01-20 22:19:45 +01:00 committed by GitHub
commit ef799d1114
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
7 changed files with 84 additions and 0 deletions

View file

@ -1,4 +1,8 @@
[
[
"2024-01-20",
"New documentation: <a href=\"/htmx/\">htmx</a>"
],
[
"2024-01-12",
"New documentation: <a href=\"/hammerspoon/\">Hammerspoon</a>"

View file

@ -0,0 +1,13 @@
module Docs
class Htmx
class CleanHtmlFilter < Filter
def call
css('.zola-anchor').remove
doc.prepend_child("<h1>htmx</h1>") if root_page?
css('div:contains("NEWS:")').remove
css('h2:contains("sponsors"), #sponsor-table').remove
doc
end
end
end
end

View file

@ -0,0 +1,31 @@
module Docs
class Htmx
class EntriesFilter < Docs::EntriesFilter
def get_name
at_css('h1').content
end
def get_type
if slug.start_with?('attributes')
'Attributes'
elsif slug.start_with?('headers')
'Headers'
elsif slug.start_with?('events')
'Events'
elsif slug.start_with?('extensions')
'Extensions'
else
get_name
end
end
def additional_entries
css('h3[id]:has(code)').each_with_object [] do |node, entries|
name = node.at_css('code').content
id = node['id']
entries << [name, id]
end
end
end
end
end

35
lib/docs/scrapers/htmx.rb Normal file
View file

@ -0,0 +1,35 @@
module Docs
class Htmx < UrlScraper
self.name = 'htmx'
self.type = 'simple'
self.slug = 'htmx'
self.links = {
home: 'https://htmx.org/',
code: 'https://github.com/bigskysoftware/htmx'
}
self.release = '1.9.10'
self.base_url = "https://htmx.org/"
self.initial_paths = %w(reference/)
html_filters.push 'htmx/entries', 'htmx/clean_html'
options[:trailing_slash] = true
options[:container] = '.content'
options[:download_images] = false
options[:skip_patterns] = [
/\Aessays/,
/\Aexamples/,
/\Amigration-guide/,
/\Aposts/,
]
# https://github.com/bigskysoftware/htmx/blob/master/LICENSE
options[:attribution] = <<-HTML
Licensed under the Zero-Clause BSD
HTML
def get_latest_version(opts)
get_npm_version('htmx.org', opts)
end
end
end

Binary file not shown.

After

Width:  |  Height:  |  Size: 817 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.6 KiB

View file

@ -0,0 +1 @@
https://github.com/bigskysoftware/htmx/blob/v1.9.10/www/static/img/htmx_logo.2.png