You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
refactor: overhaul asset management system with extensible strategy pattern
Major refactoring of the blog generation asset pipeline to improve flexibility and maintainability:
**Core Interface Changes:**
- Renamed `IAssetInclusionStrategy` → `IAssetStrategy` with nullable return type
- Updated method signatures across asset interfaces for clarity and consistency
- Renamed `ReferencedAsset` record → `PageAsset` to better reflect its purpose
- Renamed `PostPageDataModel` → `HtmlMarkdownDataTemplateModel` for generic use
**Asset Strategy System:**
- Deleted `ReferenceOnlyInclusionStrategy.cs` (replaced with new architecture)
- Added `KnownAssetStrategy.cs`: configurable strategy using known asset ID lists
- Supports both included and referenced asset file ID sets
- Includes fallback behavior options (Reference/Include/Drop)
- Added `FaultStrategy.cs`: enum for unknown asset handling (None/LogWarn/LogError/Throw)
**Asset Detection Improvements:**
- Enhanced `RegexAssetLinkDetector` with improved path matching patterns
- Added protocol scheme detection to filter out absolute URLs
- Added standalone filename pattern detection
- Fixed relative path resolution in `RelativePathAssetResolver`
**Processing Pipeline Refactoring:**
- Moved asset detection earlier in pipeline to include template file assets
- Changed `AssetAwareHtmlTemplatedMarkdownFile` to scan both template and markdown
- Updated post-processing to return nullable for dropped assets
- Refactored `PagesCommand` to configure new asset strategy with separate ID sets
**Command Structure:**
- Deleted legacy `PostPageCommand.cs`, `PostPageFolder.cs`, `IndexHtmlFile.cs`, `PostPageAssetFolder.cs`
- Added new `PageCommand.cs` for single-page generation
- Updated `WacsdkBlogCommands` to use new command structure
**Dependencies:**
- Added `OwlCore.Extensions` package reference for enhanced functionality
**Tests:**
- Updated test references from `InclusionStrategy` → `AssetStrategy`
- Created temporary `ReferenceOnlyAssetStrategy` for test compatibility
This refactoring enables fine-grained control over asset handling, supporting scenarios like template-based asset inclusion vs markdown-based asset referencing, with configurable fallback behavior for unknown assets.
/// Gets or sets the fallback used when the asset is unknown but <see cref="UnknownAssetFaultStrategy"/> does not have <see cref="FaultStrategy.Throw"/>.
varfaultMessage=$"Unknown asset encountered: {nameof(referencedAsset.Name)}{referencedAsset.Name}, {nameof(referencedAsset.Id)}{referencedAsset.Id}. Please add this ID to either {nameof(IncludedAssetFileIds)} or {nameof(ReferencedAssetFileIds)}.";
0 commit comments