Skip to content

Commit ab9382e

Browse files
authored
Merge pull request #2180 from snzow/main
Add NextJs Documentation
2 parents 58a1678 + 0ee3c23 commit ab9382e

File tree

8 files changed

+94
-0
lines changed

8 files changed

+94
-0
lines changed

assets/javascripts/news.json

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,8 @@
11
[
2+
[
3+
"2024-02-20",
4+
"New documentation: <a href=\"/nextjs/\">Nextjs</a>"
5+
],
26
[
37
"2024-01-24",
48
"New documentation: <a href=\"/playwright/\">Playwright</a>"

lib/docs/filters/nextjs/clean_html.rb

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
module Docs
2+
class Nextjs
3+
class CleanHtmlFilter < Filter
4+
def call
5+
css('.zola-anchor').remove
6+
doc.prepend_child("<h1>NextJS2</h1>") if root_page?
7+
css('div:contains("NEWS:")').remove
8+
css('h2:contains("sponsors"), #sponsor-table').remove
9+
css('div.sticky').remove #remove the floating menu
10+
css('div.-mt-4').remove #remove the navigation line
11+
css('footer').remove
12+
css('div.feedback_inlineTriggerWrapper__o7yUx').remove
13+
css('header').remove #remove links from the top of the page
14+
css('nav').remove
15+
doc
16+
end
17+
end
18+
end
19+
end

lib/docs/filters/nextjs/entries.rb

Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
module Docs
2+
class Nextjs
3+
class EntriesFilter < Docs::EntriesFilter
4+
def get_name
5+
name = at_css('h1').content
6+
name.strip!
7+
#name
8+
subpath_items = subpath.split('/', -1)
9+
if subpath_items.length >= 5
10+
subpath_items[3].capitalize + ': ' + name # e.g. Routing: Defining Routes
11+
else
12+
name
13+
end
14+
end
15+
16+
def get_type
17+
if subpath.include?('/architecture')
18+
'Architecture'
19+
elsif subpath.include?('/community')
20+
'Community'
21+
elsif subpath.include?('/getting-started')
22+
'Getting Started'
23+
elsif subpath.include?('/messages')
24+
'Messages'
25+
elsif subpath.include?('/app/building-your-application')
26+
'Using App Router: Building your application'
27+
elsif subpath.include?('/app/api-reference')
28+
'Using App Router: api-reference'
29+
elsif subpath.include?('/app')
30+
'Using App Router'
31+
elsif subpath.include?('/pages/building-your-application')
32+
'Using Pages Router: Building your application'
33+
elsif subpath.include?('/pages/api-reference')
34+
'Using Pages Router: api-reference'
35+
elsif subpath.include?('/pages')
36+
'Using Pages Router'
37+
else
38+
get_name
39+
end
40+
end
41+
end
42+
end
43+
end

lib/docs/scrapers/nextjs.rb

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
module Docs
2+
class Nextjs < UrlScraper
3+
self.name = 'NextJS'
4+
self.type = 'simple'
5+
self.release = 'v14.1.0'
6+
self.base_url = 'https://nextjs.org/docs'
7+
self.initial_paths = %w(reference/)
8+
self.links = {
9+
home: 'https://www.nextjs.org/',
10+
code: 'https://github.com/vercel/next.js'
11+
}
12+
13+
html_filters.push 'nextjs/entries', 'nextjs/clean_html'
14+
15+
options[:attribution] = <<-HTML
16+
&copy; 2024 Vercel, Inc.
17+
Licensed under the MIT License.
18+
HTML
19+
end
20+
end

package-lock.json

Lines changed: 6 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

public/icons/docs/nextjs/16.png

537 Bytes
Loading
1.33 KB
Loading

public/icons/docs/nextjs/SOURCE

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
https://assets.vercel.com/image/upload/v1662130559/nextjs/Icon_dark_background.png
2+
https://github.com/vercel/next.js/blob/canary/examples/cms-enterspeed/public/favicon/favicon.ico

0 commit comments

Comments
 (0)