Skip to content

Commit

Permalink
Fix Turbo documentation
Browse files Browse the repository at this point in the history
  • Loading branch information
marcoroth committed Mar 9, 2024
1 parent 24bb518 commit b606527
Show file tree
Hide file tree
Showing 18 changed files with 62 additions and 9 deletions.
4 changes: 2 additions & 2 deletions app/content/pages/documentation/turbo.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ title: Turbo
<div>
<h3 class="font-bold text-lg">Handbook</h3>

<% TurboHandbookModel.all.sort_by(&:request_path).each do |page| %>
<% TurboHandbookModel.all.sort_by(&:order).each do |page| %>
<li>
<a href="<%= page.request_path %>"> <%= page.data.fetch("title") %></a>
</li>
Expand All @@ -19,7 +19,7 @@ title: Turbo
<div>
<h3 class="font-bold text-lg">Reference</h3>

<% TurboReferenceModel.all.sort_by(&:request_path).each do |page| %>
<% TurboReferenceModel.all.sort_by(&:order).each do |page| %>
<li>
<a href="<%= page.request_path %>"> <%= page.data.fetch("title") %></a>
</li>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,10 +1,11 @@
---
title: Building
order: 7
---

<%= render Page::ContainerComponent.new(page: current_page) do |page| %>
<div class="prose prose-invert max-w-full mt-6">
<%== turbo_documentation_page("handbook/06_building.md") %>
<%== turbo_documentation_page("handbook/07_building.md") %>
<%= render partial: "turbo_site_navigation", locals: { current_page: current_page, model: TurboHandbookModel } %>
</div>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
---
title: Drive
order: 2
---

<%= render Page::ContainerComponent.new(page: current_page) do |page| %>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,10 +1,11 @@
---
title: Frames
order: 4
---

<%= render Page::ContainerComponent.new(page: current_page) do |page| %>
<div class="prose prose-invert max-w-full mt-6">
<%== turbo_documentation_page("handbook/03_frames.md") %>
<%== turbo_documentation_page("handbook/04_frames.md") %>
<%= render partial: "turbo_site_navigation", locals: { current_page: current_page, model: TurboHandbookModel } %>
</div>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,10 +1,11 @@
---
title: Installing
order: 8
---

<%= render Page::ContainerComponent.new(page: current_page) do |page| %>
<div class="prose prose-invert max-w-full mt-6">
<%== turbo_documentation_page("handbook/07_installing.md") %>
<%== turbo_documentation_page("handbook/08_installing.md") %>
<%= render partial: "turbo_site_navigation", locals: { current_page: current_page, model: TurboHandbookModel } %>
</div>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
---
title: Introduction
order: 1
---

<%= render Page::ContainerComponent.new(page: current_page) do |page| %>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,10 +1,11 @@
---
title: Native
order: 6
---

<%= render Page::ContainerComponent.new(page: current_page) do |page| %>
<div class="prose prose-invert max-w-full mt-6">
<%== turbo_documentation_page("handbook/05_native.md") %>
<%== turbo_documentation_page("handbook/06_native.md") %>
<%= render partial: "turbo_site_navigation", locals: { current_page: current_page, model: TurboHandbookModel } %>
</div>
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
---
title: Page Refreshes
order: 3
---

<%= render Page::ContainerComponent.new(page: current_page) do |page| %>
<div class="prose prose-invert max-w-full mt-6">
<%== turbo_documentation_page("handbook/03_page_refreshes.md") %>
<%= render partial: "turbo_site_navigation", locals: { current_page: current_page, model: TurboHandbookModel } %>
</div>
<% end %>
Original file line number Diff line number Diff line change
@@ -1,10 +1,11 @@
---
title: Streams
order: 5
---

<%= render Page::ContainerComponent.new(page: current_page) do |page| %>
<div class="prose prose-invert max-w-full mt-6">
<%== turbo_documentation_page("handbook/04_streams.md") %>
<%== turbo_documentation_page("handbook/05_streams.md") %>
<%= render partial: "turbo_site_navigation", locals: { current_page: current_page, model: TurboHandbookModel } %>
</div>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
---
title: Attributes
order: 5
---

<%= render Page::ContainerComponent.new(page: current_page) do |page| %>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
---
title: Drive
order: 1
---

<%= render Page::ContainerComponent.new(page: current_page) do |page| %>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
---
title: Events
order: 4
---

<%= render Page::ContainerComponent.new(page: current_page) do |page| %>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
---
title: Frames
order: 2
---

<%= render Page::ContainerComponent.new(page: current_page) do |page| %>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
---
title: Streams
order: 3
---

<%= render Page::ContainerComponent.new(page: current_page) do |page| %>
Expand Down
6 changes: 5 additions & 1 deletion app/helpers/turbo_documentation_helper.rb
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,10 @@

module TurboDocumentationHelper
def turbo_documentation_page(page)
render_markdown(Net::HTTP.get(URI("https://raw.githubusercontent.com/hotwired/turbo-site/main/_source/#{page}")).split("---").last.force_encoding("utf-8"))
ref = "692c6ffe873d4671d6c749eb045c073bae0e032e"
content = Net::HTTP.get(URI("https://raw.githubusercontent.com/hotwired/turbo-site/#{ref}/_source/#{page}"))
content_without_frontmatter = content.split("---").from(2).join("---")

render_markdown(content_without_frontmatter.force_encoding("utf-8"))
end
end
2 changes: 1 addition & 1 deletion app/views/sitepress/site/_turbo_site_navigation.html.erb
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
<% pages = model.all.sort_by { |page| page.page.asset.path.to_s }.to_a %>
<% pages = model.all.sort_by { |page| page.data.fetch(:order) }.to_a %>
<% page = pages.find { |page| page.page.asset.path == current_page.asset.path } %>
<% prev_page = pages[pages.index(page) - 1] %>
Expand Down
25 changes: 25 additions & 0 deletions config/routes.rb
Original file line number Diff line number Diff line change
@@ -1,4 +1,29 @@
Rails.application.routes.draw do
scope "/documentation/turbo/reference" do
get "/01_drive", to: redirect("/documentation/turbo/handbook/drive")
get "/02_frames", to: redirect("/documentation/turbo/handbook/frames")
get "/03_streams", to: redirect("/documentation/turbo/handbook/streams")
get "/04_events", to: redirect("/documentation/turbo/handbook/events")
get "/05_attributes", to: redirect("/documentation/turbo/handbook/attributes")
end

scope "/documentation/turbo/handbook" do
get "/03_frames", to: redirect("/documentation/turbo/handbook/frames")
get "/04_frames", to: redirect("/documentation/turbo/handbook/frames")

get "/04_streams", to: redirect("/documentation/turbo/handbook/streams")
get "/05_streams", to: redirect("/documentation/turbo/handbook/streams")

get "/05_native", to: redirect("/documentation/turbo/handbook/native")
get "/06_native", to: redirect("/documentation/turbo/handbook/native")

get "/06_building", to: redirect("/documentation/turbo/handbook/building")
get "/07_building", to: redirect("/documentation/turbo/handbook/building")

get "/07_installing", to: redirect("/documentation/turbo/handbook/installing")
get "/08_installing", to: redirect("/documentation/turbo/handbook/installing")
end

sitepress_pages
sitepress_root

Expand Down
Binary file modified public/sitemap.xml.gz
Binary file not shown.

0 comments on commit b606527

Please sign in to comment.