Statamic의 구성에서 콘텐츠 분리
🚧 이 기사는 진행 중인 작업입니다. 🚧
기술적 접근
내 접근 방식: 사용자가 편집할 수 있는 콘텐츠(
content/
의 마크다운 파일, 미디어 자산)는 프로덕션 서버에만 저장해야 하며 git 저장소에서 추적하면 안 됩니다.구성 파일만 추적하고 git을 통해 푸시해야 하며 항상 로컬에서 프로덕션으로 단방향으로 이동해야 합니다.
라이브 서버에서 git 병합 충돌을 처리하고 싶지 않습니다. 나는 단순히하지 않습니다 ;-)
업데이트: CraftCMS가 CraftCMS deployments docs에서 접근 방식을 완벽하게 설명한다는 것을 알았습니다. 이것이 제가 Statamic에서 구현하고 싶은 접근 방식입니다.


하지만 프로덕션 콘텐츠 데이터를 로컬 개발 환경으로 가져와 함께 플레이하고 개발하려면 어떻게 해야 할까요? useDDEVs pull feature를 사용하고 이 시리즈의 뒷부분에서 프로덕션 서버에서 SSH/rsync를 통해 콘텐츠를 가져옵니다.
컬렉션 정의 저장 변경
일반적으로 컬렉션 yaml 정의는 마크다운 파일 옆에 있는
content/collections
에 저장됩니다. 그러나 우리는 이것을 바꿀 수 있습니다. content/collections
에서 resources/collections
를 config/stache.php
로 변경해야 합니다. 다음은 중요한 라인입니다.'collections' => [
'class' => Stores\CollectionsStore::class,
'directory' => base_path('resources/collections'),
],
전체
config/stache.php
파일:<?php
use Statamic\Stache\Stores;
return [
/*
|--------------------------------------------------------------------------
| File Watcher
|--------------------------------------------------------------------------
|
| File changes will be noticed and data will be updated accordingly.
| This can be disabled to reduce overhead, but you will need to
| either update the cache manually or use the Control Panel.
|
*/
'watcher' => env('STATAMIC_STACHE_WATCHER', true),
/*
|--------------------------------------------------------------------------
| Stores
|--------------------------------------------------------------------------
|
| Here you may configure the stores that are used inside the Stache.
|
| https://statamic.dev/stache#stores
|
*/
// separate collections from entries
'stores' => [
'collections' => [
'class' => Stores\CollectionsStore::class,
'directory' => base_path('resources/collections'),
],
'entries' => [
'class' => Stores\EntriesStore::class,
'directory' => base_path('content/collections'),
],
],
/*
|--------------------------------------------------------------------------
| Indexes
|--------------------------------------------------------------------------
|
| Here you may define any additional indexes that will be inherited
| by each store in the Stache. You may also define indexes on a
| per-store level by adding an "indexes" key to its config.
|
*/
'indexes' => [
//
],
/*
|--------------------------------------------------------------------------
| Locking
|--------------------------------------------------------------------------
|
| In order to prevent concurrent requests from updating the Stache at
| the same and wasting resources, it will be "locked" so subsequent
| requests will have to wait until the first has been completed.
|
| https://statamic.dev/stache#locks
|
*/
'lock' => [
'enabled' => true,
'timeout' => 30,
],
];
그런 다음
content/collections/pages.yaml
에서 resources/collections/pages.yaml
로 이동해야 합니다.그리고
content/
-디렉토리를 제거하고 .gitignore
에 추가해야 합니다.# add to .gitignore:
/content
이러한 파일은 이미 추적되었으므로 프로젝트에서 전체 폴더를 제거하고 이러한 git 변경 사항을 커밋해야 합니다.
ddev exec rm -rf content/
누락된 부분: 환경 기반 권한
혼동을 피하기 위해 프로덕션 사이트의 제어판에서 구성 항목을 편집할 수 없어야 합니다.
이 작업은 로컬 개발 환경에서만 수행한 다음 그곳에서 git 저장소로 커밋해야 합니다.

현재 상태는 이것을 참조하십시오. 프로덕션 사이트뿐만 아니라 로컬에 대해 서로 다른 권한 집합을 구현해야 할 것 같습니다. 🤔
이에 대한 GitHub 토론을 열었습니다.
Implement a config option like "allowAdminChanges" - override permissions dynamically based on APP_ENV? #6289
면책 조항: 저는 Statamic 초보자입니다. 아마도 이 접근 방식에 대한 몇 가지 더 어려운 문제일 수 있습니다.
감사의 말
에 대해 Jonas Siewertsen에게 대단히 감사합니다. 그는 또한 무료로 A 및 오퍼 statamictutorials.com를 개최했습니다. 정말 고마워!
Reference
이 문제에 관하여(Statamic의 구성에서 콘텐츠 분리), 우리는 이곳에서 더 많은 자료를 발견하고 링크를 클릭하여 보았다 https://dev.to/mandrasch/separate-content-from-config-in-statamic-466e텍스트를 자유롭게 공유하거나 복사할 수 있습니다.하지만 이 문서의 URL은 참조 URL로 남겨 두십시오.
우수한 개발자 콘텐츠 발견에 전념
(Collection and Share based on the CC Protocol.)