statamic / ssg

The official Statamic Static Site Generator
229 stars 23 forks source link

Per-site views failing to be considered when using SSG #127

Open davebarrau opened 1 year ago

davebarrau commented 1 year ago

The Multi-Site docs state that you can arrange your directory structure so that if resources/views/<site name>/ exists, it will preference that over resources/views/.

This currently works in statamic/cms for the control panel + anything web-based, but not for ssg:generate for me (using statamic/cms:v3.4.4 and statamic/ssg:1.3.0).

I believe this may have been a regression when https://github.com/statamic/cms/commit/01cc304545a60850d5df16cbe05e2dd9d6b38f02 was introduced, as that commit moved addViewPaths() to a web middleware and removed the call from DataResponse::toResponse(). I believe ssg:generate uses DataResponse::toResponse() (via Page::write()) but does nothing with this new middleware, which means the per-site view path is not set correctly when using the static site generator.

Adding ->addViewPaths() back in to DataResponse::toResponse() fixes it for me (edit: scratch that, it reintroduces the exponential loop issue that was previously fixed), but I'm not sure if it was removed for a reason (perhaps to fix another bug?).

michaelr0 commented 1 year ago

Closed #128 in favour of this issue.

I’ll copy what I experienced from that issue into this comment.