Module: Roda::RodaPlugins::BridgetownRoutes

Defined in:
lib/roda/plugins/bridgetown_routes.rb

Defined Under Namespace

Modules: InstanceMethods, RequestMethods, ResponseMethods

Class Method Summary collapse

Class Method Details

.configure(app, _opts = {}) ⇒ Object



27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
# File 'lib/roda/plugins/bridgetown_routes.rb', line 27

def self.configure(app, _opts = {})
  app.root_hook do
    routes_dir = File.expand_path(
      bridgetown_site.config.routes.source_paths.first,
      bridgetown_site.config.source
    )
    file = routes_manifest.glob_routes(routes_dir, "index").first
    next unless file

    run_file_route(file, slug: "index")
  end

  if app.opts[:bridgetown_site]
    app.opts[:routes_manifest] ||=
      Bridgetown::Routes::Manifest.new(app.opts[:bridgetown_site])
    return
  end

  raise "Roda app failure: the bridgetown_ssr plugin must be registered before " \
        "bridgetown_routes"
end

.load_dependencies(app) ⇒ Object



20
21
22
23
24
25
# File 'lib/roda/plugins/bridgetown_routes.rb', line 20

def self.load_dependencies(app)
  app.plugin :slash_path_empty # now /hello and /hello/ are both matched
  app.plugin :placeholder_string_matchers
  app.plugin :flash
  app.plugin :route_csrf
end