Module: Bridgetown::Site::SSR

Included in:
Bridgetown::Site
Defined in:
lib/bridgetown-core/concerns/site/ssr.rb

Defined Under Namespace

Modules: ClassMethods

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details

.included(base) ⇒ Object



5
6
7
# File 'lib/bridgetown-core/concerns/site/ssr.rb', line 5

def self.included(base)
  base.extend ClassMethods
end

Instance Method Details

#disable_ssrObject



54
55
56
57
# File 'lib/bridgetown-core/concerns/site/ssr.rb', line 54

def disable_ssr
  Bridgetown.logger.info "SSR:", "now disabled."
  @ssr_enabled = false
end

#enable_ssrObject



29
30
31
32
# File 'lib/bridgetown-core/concerns/site/ssr.rb', line 29

def enable_ssr
  Bridgetown.logger.info "SSR:", "enabled."
  @ssr_enabled = true
end

#ssr?Boolean

Returns:

  • (Boolean)


25
26
27
# File 'lib/bridgetown-core/concerns/site/ssr.rb', line 25

def ssr?
  @ssr_enabled == true
end

#ssr_setup(&block) ⇒ Object



34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
# File 'lib/bridgetown-core/concerns/site/ssr.rb', line 34

def ssr_setup(&block)
  config.serving = true
  Bridgetown::Hooks.trigger :site, :pre_read, self
  defaults_reader.tap do |d|
    d.path_defaults.clear
    d.read
  end
  reader.read_layouts
  collections.data.tap do |coll|
    coll.read
    self.data = coll.merge_data_resources
  end
  Bridgetown::Hooks.trigger :site, :post_read, self

  block&.call(self) # provide additional setup hook
  return if Bridgetown.env.production?

  Bridgetown::Watcher.watch(self, config, &block)
end