diff --git a/app/controllers/llms_controller.rb b/app/controllers/llms_controller.rb index 024c24a..502172e 100644 --- a/app/controllers/llms_controller.rb +++ b/app/controllers/llms_controller.rb @@ -2,7 +2,7 @@ class LlmsController < ApplicationController allow_unauthenticated_access def show - @books = Book.published.ordered + @books = Book.accessable_or_published.ordered.includes(leaves: :leafable) render content_type: "text/plain" end end diff --git a/app/helpers/leaves_helper.rb b/app/helpers/leaves_helper.rb index 90fe652..9897e0f 100644 --- a/app/helpers/leaves_helper.rb +++ b/app/helpers/leaves_helper.rb @@ -12,9 +12,9 @@ def leaf_og_description(leaf, book) def leaf_og_image(leaf, book) if leaf.picture? && leaf.picture.image.attached? - "#{root_url}#{url_for(leaf.picture.image)}" + url_for(leaf.picture.image) elsif book.cover.attached? - "#{root_url}#{url_for(book.cover)}" + url_for(book.cover) else asset_url("covers/cover-#{book.theme}-og.png") end diff --git a/app/views/books/show.html.erb b/app/views/books/show.html.erb index 165993d..2250282 100644 --- a/app/views/books/show.html.erb +++ b/app/views/books/show.html.erb @@ -2,14 +2,15 @@ <% @layout_class = "book" %> <% content_for :head do %> + <%= tag.meta name: "description", content: (@book.subtitle.presence || @book.title) %> <%= tag.meta property: "og:title", content: @book.title %> - <%= tag.meta property: "og:description", content: @book.subtitle %> - <%= tag.meta property: "og:image", content: @book.cover.blank? ? asset_url("covers/cover-#{@book.theme}-og.png") : "#{root_url}#{url_for(@book.cover)}" %> + <%= tag.meta property: "og:description", content: (@book.subtitle.presence || @book.title) %> + <%= tag.meta property: "og:image", content: @book.cover.blank? ? asset_url("covers/cover-#{@book.theme}-og.png") : url_for(@book.cover) %> <%= tag.meta property: "og:url", content: book_slug_url(@book) %> <%= tag.meta property: "twitter:title", content: @book.title %> - <%= tag.meta property: "twitter:description", content: @book.subtitle %> - <%= tag.meta property: "twitter:image", content: @book.cover.blank? ? asset_url("covers/cover-#{@book.theme}-og.png") : "#{root_url}#{url_for(@book.cover)}" %> + <%= tag.meta property: "twitter:description", content: (@book.subtitle.presence || @book.title) %> + <%= tag.meta property: "twitter:image", content: @book.cover.blank? ? asset_url("covers/cover-#{@book.theme}-og.png") : url_for(@book.cover) %> <%= tag.meta property: "twitter:card", content: "summary_large_image" %> <% end %> diff --git a/app/views/leafables/show.html.erb b/app/views/leafables/show.html.erb index 3d699c8..1939426 100644 --- a/app/views/leafables/show.html.erb +++ b/app/views/leafables/show.html.erb @@ -1,6 +1,7 @@ <% content_for(:title) { page_title(@leaf, @book) } %> <% content_for :head do %> + <%= tag.meta name: "description", content: leaf_og_description(@leaf, @book) %> <%= tag.meta property: "og:title", content: page_title(@leaf, @book) %> <%= tag.meta property: "og:description", content: leaf_og_description(@leaf, @book) %> <%= tag.meta property: "og:url", content: leafable_slug_url(@leaf) %> diff --git a/app/views/llms/show.text.erb b/app/views/llms/show.text.erb index 9d6793f..e06cb9e 100644 --- a/app/views/llms/show.text.erb +++ b/app/views/llms/show.text.erb @@ -6,3 +6,12 @@ <% @books.each do |book| %> - [<%= book.title %>](<%= book_slug_url(book) %>)<%= book.subtitle.present? ? " — #{book.subtitle}" : "" %><%= book.author.present? ? " by #{book.author}" : "" %> <% end %> +<% @books.each do |book| %> + +--- + +## [<%= book.title %>](<%= book_slug_url(book) %>) +<% book.leaves.active.positioned.each do |leaf| %> +- [<%= leaf.title %>](<%= leafable_slug_url(leaf) %>) +<% end %> +<% end %>