lib/lookbook/entities/preview_entity.rb in lookbook-2.0.0.beta.9 vs lib/lookbook/entities/preview_entity.rb in lookbook-2.0.0.rc.1

- old
+ new

@@ -17,13 +17,13 @@ @code_object = code_object @preview_class = code_object.path.constantize @file_path = Pathname(code_object.file) @base_directories = Engine.preview_paths - cleaned_path = relative_file_path.to_s - .gsub(/\/(component_preview|preview)(\..*)$/, "") - .gsub(/(_component_preview|_preview)(\..*)$/, "") + cleaned_path = preview_class.name.underscore.strip + .gsub(/(_component_preview|_preview)(\..+)?$/, "") + .gsub(/\/(component_preview|preview|component)(\..+)?$/, "") @lookup_path = PathUtils.to_lookup_path(cleaned_path) end # @!group Scenarios @@ -147,10 +147,10 @@ preview_class.name end # @api private def file_name_base - @_file_name_slug ||= file_name(true).gsub(/(_component_preview|component_preview|preview)$/, "") + @_file_name_slug ||= file_name(true).gsub(/(_component_preview|component_preview|_preview|preview|component)$/, "") end # @api private def display_options global_options = Lookbook.config.preview_display_options