From 524e2e14825df51f9d1d7619084313a43b2b059d Mon Sep 17 00:00:00 2001 From: Simon Legner Date: Wed, 12 Jun 2024 20:19:55 +0200 Subject: [PATCH] Update Next.js documentation (14.2.4) --- assets/javascripts/news.json | 2 +- lib/docs/filters/nextjs/clean_html.rb | 11 +++++++++++ lib/docs/filters/nextjs/entries.rb | 20 ++++++++++---------- lib/docs/scrapers/nextjs.rb | 12 +++++++++--- 4 files changed, 31 insertions(+), 14 deletions(-) diff --git a/assets/javascripts/news.json b/assets/javascripts/news.json index 5b175a75..d7ae6452 100644 --- a/assets/javascripts/news.json +++ b/assets/javascripts/news.json @@ -1,7 +1,7 @@ [ [ "2024-02-20", - "New documentation: Nextjs" + "New documentation: Next.js" ], [ "2024-01-24", diff --git a/lib/docs/filters/nextjs/clean_html.rb b/lib/docs/filters/nextjs/clean_html.rb index 6197de17..99523bdd 100644 --- a/lib/docs/filters/nextjs/clean_html.rb +++ b/lib/docs/filters/nextjs/clean_html.rb @@ -2,6 +2,8 @@ module Docs class Nextjs class CleanHtmlFilter < Filter def call + @doc = at_css('.prose') + css('.zola-anchor').remove doc.prepend_child("

NextJS2

") if root_page? css('div:contains("NEWS:")').remove @@ -12,6 +14,15 @@ module Docs css('div.feedback_inlineTriggerWrapper__o7yUx').remove css('header').remove #remove links from the top of the page css('nav').remove + + css('h1, h2, h3, h4').each { |node| node.content = node.content } + + css('pre > code').each do |node| + node.parent['data-language'] = 'typescript' + node.parent.content = node.parent.content + end + css('div[class^="code-block_header"]').remove + doc end end diff --git a/lib/docs/filters/nextjs/entries.rb b/lib/docs/filters/nextjs/entries.rb index 4e67f00d..03c6bc09 100644 --- a/lib/docs/filters/nextjs/entries.rb +++ b/lib/docs/filters/nextjs/entries.rb @@ -14,25 +14,25 @@ module Docs end def get_type - if subpath.include?('/architecture') + if slug.start_with?('architecture') 'Architecture' - elsif subpath.include?('/community') + elsif slug.start_with?('community') 'Community' - elsif subpath.include?('/getting-started') + elsif slug.start_with?('getting-started') 'Getting Started' - elsif subpath.include?('/messages') + elsif slug.start_with?('messages') 'Messages' - elsif subpath.include?('/app/building-your-application') + elsif slug.start_with?('app/building-your-application') 'Using App Router: Building your application' - elsif subpath.include?('/app/api-reference') + elsif slug.start_with?('app/api-reference') 'Using App Router: api-reference' - elsif subpath.include?('/app') + elsif slug.start_with?('app') 'Using App Router' - elsif subpath.include?('/pages/building-your-application') + elsif slug.start_with?('pages/building-your-application') 'Using Pages Router: Building your application' - elsif subpath.include?('/pages/api-reference') + elsif slug.start_with?('pages/api-reference') 'Using Pages Router: api-reference' - elsif subpath.include?('/pages') + elsif slug.start_with?('pages') 'Using Pages Router' else get_name diff --git a/lib/docs/scrapers/nextjs.rb b/lib/docs/scrapers/nextjs.rb index a20cf800..99d3f5ca 100644 --- a/lib/docs/scrapers/nextjs.rb +++ b/lib/docs/scrapers/nextjs.rb @@ -1,8 +1,9 @@ module Docs class Nextjs < UrlScraper - self.name = 'NextJS' + self.name = 'Next.js' + self.slug = 'nextjs' self.type = 'simple' - self.release = 'v14.1.0' + self.release = '14.2.4' self.base_url = 'https://nextjs.org/docs' self.initial_paths = %w(reference/) self.links = { @@ -11,10 +12,15 @@ module Docs } html_filters.push 'nextjs/entries', 'nextjs/clean_html' + options[:download_images] = false options[:attribution] = <<-HTML - © 2024 Vercel, Inc. + © 2024 Vercel, Inc.
Licensed under the MIT License. HTML + + def get_latest_version(opts) + get_npm_version('next', opts) + end end end