mirror of
https://github.com/freeCodeCamp/devdocs
synced 2024-11-16 19:48:10 +01:00
Merge pull request #1838 from freeCodeCamp/astro
Add Astro documentation (1.4.7)
This commit is contained in:
commit
ffde393d75
8 changed files with 102 additions and 0 deletions
|
@ -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>"
|
||||
|
|
|
@ -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',
|
||||
|
|
28
lib/docs/filters/astro/clean_html.rb
Normal file
28
lib/docs/filters/astro/clean_html.rb
Normal 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
|
25
lib/docs/filters/astro/entries.rb
Normal file
25
lib/docs/filters/astro/entries.rb
Normal 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
|
38
lib/docs/scrapers/astro.rb
Normal file
38
lib/docs/scrapers/astro.rb
Normal 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
|
||||
© 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
|
BIN
public/icons/docs/astro/16.png
Normal file
BIN
public/icons/docs/astro/16.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 900 B |
BIN
public/icons/docs/astro/16@2x.png
Normal file
BIN
public/icons/docs/astro/16@2x.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 1 KiB |
2
public/icons/docs/astro/SOURCE
Normal file
2
public/icons/docs/astro/SOURCE
Normal file
|
@ -0,0 +1,2 @@
|
|||
https://docs.astro.build/favicon.ico
|
||||
https://docs.astro.build/favicon.svg
|
Loading…
Reference in a new issue