mirror of https://github.com/freeCodeCamp/devdocs
parent
d9f2f33510
commit
03d3f206d1
@ -0,0 +1,28 @@
|
||||
module Docs
|
||||
class Astro
|
||||
class CleanHtmlFilter < Filter
|
||||
def call
|
||||
@doc = at_css('article > section')
|
||||
|
||||
css('.anchor-link').remove
|
||||
|
||||
css('pre').each do |node|
|
||||
node.content = node.css('.line').map(&:content).join("\n")
|
||||
node['data-language'] = node.ancestors('figure').first['class'][/lang-(\w+)/, 1]
|
||||
node.remove_attribute('style')
|
||||
end
|
||||
|
||||
css('figcaption').each do |node|
|
||||
node.name = 'div'
|
||||
node['class'] = '_pre-heading'
|
||||
end
|
||||
|
||||
css('figure').each do |node|
|
||||
node.before(node.children).remove
|
||||
end
|
||||
|
||||
doc
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
@ -0,0 +1,25 @@
|
||||
module Docs
|
||||
class Astro
|
||||
class EntriesFilter < Docs::EntriesFilter
|
||||
def get_name
|
||||
name = at_css('h1').content
|
||||
name.sub! %r{\s*#\s*}, ''
|
||||
name
|
||||
end
|
||||
|
||||
def get_type
|
||||
aside = at_css('aside')
|
||||
a = aside.at_css('a[aria-current="page"]', 'a[data-current-parent="true"]')
|
||||
a.ancestors('details').at_css('summary').content
|
||||
end
|
||||
|
||||
def additional_entries
|
||||
at_css('article').css('h2, h3').each_with_object [] do |node, entries|
|
||||
type = node.content.strip
|
||||
type.sub! %r{\s*#\s*}, ''
|
||||
entries << ["#{name}: #{type}", node['id']]
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
@ -0,0 +1,38 @@
|
||||
module Docs
|
||||
class Astro < UrlScraper
|
||||
self.name = 'Astro'
|
||||
self.slug = 'astro'
|
||||
self.type = 'simple'
|
||||
self.links = {
|
||||
home: 'https://docs.astro.build/',
|
||||
code: 'https://github.com/withastro/astro'
|
||||
}
|
||||
|
||||
# https://github.com/withastro/astro/blob/main/LICENSE
|
||||
options[:attribution] = <<-HTML
|
||||
© 2021 Fred K. Schott<br>
|
||||
Licensed under the MIT License.
|
||||
HTML
|
||||
|
||||
self.release = '1.4.7'
|
||||
self.base_url = 'https://docs.astro.build/en/'
|
||||
self.initial_paths = %w(getting-started/)
|
||||
|
||||
html_filters.push 'astro/entries', 'astro/clean_html'
|
||||
|
||||
def get_latest_version(opts)
|
||||
get_npm_version('astro', opts)
|
||||
end
|
||||
|
||||
private
|
||||
|
||||
def parse(response)
|
||||
if response.url == self.base_url
|
||||
# root_page is a redirect
|
||||
response.body.gsub! %r{.*}, '<body><article><section><h1>Astro</h1><p> Astro is a website build tool for the modern web — powerful developer experience meets lightweight output.</p></section></article></body>'
|
||||
end
|
||||
super
|
||||
end
|
||||
|
||||
end
|
||||
end
|
After Width: | Height: | Size: 900 B |
After Width: | Height: | Size: 1.0 KiB |
@ -0,0 +1,2 @@
|
||||
https://docs.astro.build/favicon.ico
|
||||
https://docs.astro.build/favicon.svg
|
Loading…
Reference in new issue