Skip to content

Commit

Permalink
Merge branch 'main' into swap-active-support-core-exts
Browse files Browse the repository at this point in the history
  • Loading branch information
jaredcwhite committed Apr 16, 2024
2 parents adc2c88 + ec7b5af commit b1e8541
Showing 1 changed file with 21 additions and 2 deletions.
23 changes: 21 additions & 2 deletions bridgetown-core/lib/bridgetown-core/resource/base.rb
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,12 @@ class Base # rubocop:todo Metrics/ClassLength
attr_reader :fast_refresh_order

# @return [String]
attr_accessor :content, :untransformed_content, :output
attr_accessor :untransformed_content

attr_writer :content

# @return [String]
attr_accessor :output

DATE_FILENAME_MATCHER = %r!^(?>.+/)*?(\d{2,4}-\d{1,2}-\d{1,2})-([^/]*)(\.[^.]+)$!

Expand All @@ -37,6 +42,8 @@ def initialize(model:)
@data = Signalize.signal(
collection.data? ? HashWithDotAccess::Hash.new : front_matter_defaults
)
# we track content subscriptions under the hood numerically…cleans up internal issues
@content_signal = Signalize.signal(0)
@slots = []

trigger_hooks :post_init
Expand Down Expand Up @@ -106,7 +113,18 @@ def data=(new_data)
# @data.value = front_matter_defaults
mark_for_fast_refresh!
end
@data.value = @data.value.merge(new_data)

Signalize.batch do
@content_signal.value += 1
@data.value = @data.value.merge(new_data)
end
@data.peek
end

# @return [String] the resource content minus its layout
def content
@content_signal.value # subscribe for Fast Refresh
@content
end

# @return [Bridgetown::Resource::Base]
Expand Down Expand Up @@ -142,6 +160,7 @@ def transform! # rubocop:todo Metrics/CyclomaticComplexity
end

transformer.process! unless collection.data?
slots.clear
@previously_transformed = true
rescue StandardError, SyntaxError => e
internal_error = e
Expand Down

0 comments on commit b1e8541

Please sign in to comment.