0
0
Fork 0
mirror of https://github.com/discourse/discourse.git synced 2026-08-04 10:39:43 +08:00
discourse/lib/homepage_helper.rb
Penar Musaraj 99c63660d4
FEATURE: Allow fallback home routes for crawlers for custom homepage sites (#41234)
When using a custom homepage, the crawler view currently is limited, it
only shows the site's top menu. Instead, let's add a default fallback
route (/latest) and an admin site setting where the admin can pick
another fallback route. This should be better for SEO and discovery.
2026-06-29 09:57:40 -04:00

31 lines
792 B
Ruby
Vendored

# frozen_string_literal: true
class HomepageHelper
def self.resolve(request = nil, current_user = nil)
return "blank" if !current_user && SiteSetting.login_required?
if ThemeModifierHelper.new(request: request).custom_homepage
return custom_homepage_route(request)
end
enabled =
DiscoursePluginRegistry.apply_modifier(
:custom_homepage_enabled,
false,
request: request,
current_user: current_user,
)
return custom_homepage_route(request) if enabled
current_user ? SiteSetting.homepage : SiteSetting.anonymous_homepage
end
def self.custom_homepage_route(request)
if CrawlerDetection.crawler_layout_request?(request)
return SiteSetting.custom_homepage_crawler_route
end
"custom"
end
end