Browse Source

Merge branch 'main' into #23

#23
みてるぞ 14 hours ago
parent
commit
4ec9c9c5e0
3 changed files with 19 additions and 2 deletions
  1. +10
    -2
      backend/app/controllers/posts_controller.rb
  2. +6
    -0
      frontend/public/.htaccess
  3. +3
    -0
      frontend/src/pages/posts/PostListPage.tsx

+ 10
- 2
backend/app/controllers/posts_controller.rb View File

@@ -19,8 +19,16 @@ class PostsController < ApplicationController
posts = posts.first(limit)
end

render json: { posts: posts.as_json(include: { tags: { only: [:id, :name, :category, :post_count] } }),
next_cursor: }
render json: { posts: posts.map { |post|
post.as_json(include: { tags: { only: [:id, :name, :category, :post_count] } }).tap { |json|
json['thumbnail'] =
if post.thumbnail.attached?
rails_storage_proxy_url(post.thumbnail, only_path: false)
else
nil
end
}
}, next_cursor: }
end

def random


+ 6
- 0
frontend/public/.htaccess View File

@@ -1,3 +1,9 @@
<IfModule mod_headers.c>
<FilesMatch "\.(css|js|jpg|png|webp|woff2?)$">
Header set Cache-Control "max-age=31536000, public"
</FilesMatch>
</IfModule>

<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /


+ 3
- 0
frontend/src/pages/posts/PostListPage.tsx View File

@@ -101,6 +101,9 @@ export default () => {
<img src={post.thumbnail || post.thumbnailBase || undefined}
alt={post.title || post.url}
title={post.title || post.url || undefined}
loading="eager"
fetchPriority="high"
decoding="async"
className="object-none w-full h-full" />
</Link>))}
</div>)


Loading…
Cancel
Save