statamic / ssg

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

Multisite view overrides not working with statmic ssg #128

Closed michaelr0 closed 1 year ago

michaelr0 commented 1 year ago

Bug description

It looks like there is an issue with generating multisite pages with the SSG package, when trying to use view overrides for particular sites/pages.

The below PR's might be related as those appeared to have removed the viewPath's in favour of moving it into a middleware and solving a SSG performance issue.

https://github.com/statamic/cms/pull/7030 https://github.com/statamic/ssg/pull/120

How to reproduce

Logs

No response

Environment

php please support:details

Environment
Application Name: Statamic
Laravel Version: 9.52.4
PHP Version: 8.1.16
Composer Version: 2.5.4
Environment: local
Debug Mode: ENABLED
URL: mysite.test
Maintenance Mode: OFF

Cache
Config: NOT CACHED
Events: NOT CACHED
Routes: NOT CACHED
Views: NOT CACHED

Drivers
Broadcasting: log
Cache: statamic
Database: mysql
Logs: stack / single
Mail: smtp
Queue: sync
Session: file

Statamic
Addons: 1
Antlers: runtime
Stache Watcher: Enabled
Static Caching: Disabled
Version: 3.4.5 PRO

Statamic Addons
statamic/ssg: 1.3.0

Installation

Fresh statamic/statamic site via CLI

Antlers Parser

regex (default)

Additional details

No response

duncanmcclean commented 1 year ago

This issue might belong better on the statamic/ssg repository - I'll leave it for the Statamic Team to move it if they feel necessary.

michaelr0 commented 1 year ago

This and https://github.com/statamic/ssg/issues/127 are the for the same issue.

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 statamic/cms@01cc304 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

Closing in favour of https://github.com/statamic/ssg/issues/127