Merge pull request #1838 from freeCodeCamp/astro

Add Astro documentation (1.4.7)
This commit is contained in:
Simon Legner 2022-10-10 23:05:57 +02:00 committed by GitHub
commit ffde393d75
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
8 changed files with 102 additions and 0 deletions

View file

@ -1,4 +1,8 @@
[
[
"2022-10-10",
"New documentation: <a href=\"/astro/\">Astro</a>"
],
[
"2022-10-09",
"New documentations: <a href=\"/fastapi/\">FastAPI</a>, <a href=\"/vitest/\">Vitest</a>"

View file

@ -101,6 +101,11 @@ credits = [
'2018 The Apache Software Foundation<br>Apache and the Apache feather logo are trademarks of The Apache Software Foundation.',
'Apache',
'https://www.apache.org/licenses/LICENSE-2.0'
], [
'Astro',
'2022 withastro',
'MIT',
'https://github.com/withastro/docs/blob/main/LICENSE'
], [
'Async',
'2010-2018 Caolan McMahon',

View file

@ -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

View file

@ -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

View file

@ -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
&copy; 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

Binary file not shown.

After

Width:  |  Height:  |  Size: 900 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 1 KiB

View file

@ -0,0 +1,2 @@
https://docs.astro.build/favicon.ico
https://docs.astro.build/favicon.svg