|
4 | 4 |
|
5 | 5 | namespace Hyde\Framework\Actions;
|
6 | 6 |
|
7 |
| -use function file_put_contents; |
8 | 7 | use Hyde\Framework\Actions\Concerns\CreateAction;
|
9 | 8 | use Hyde\Framework\Actions\Contracts\CreateActionContract;
|
10 | 9 | use Hyde\Framework\Features\Publications\Models\PublicationType;
|
@@ -56,66 +55,16 @@ protected function handleCreate(): void
|
56 | 55 |
|
57 | 56 | protected function createDetailTemplate(): void
|
58 | 57 | {
|
59 |
| - $contents = <<<'BLADE' |
60 |
| - @extends('hyde::layouts.app') |
61 |
| - @section('content') |
62 |
| - <main id="content" class="mx-auto max-w-7xl py-16 px-8"> |
63 |
| - <article class="prose dark:prose-invert"> |
64 |
| - @php/** @var \Hyde\Pages\PublicationPage $publication*/@endphp |
65 |
| - <h1>{{ $publication->title }}</h1> |
66 |
| - <p> |
67 |
| - {{ $publication->markdown }} |
68 |
| - </p> |
69 |
| - </article> |
70 |
| - |
71 |
| - <div class="prose dark:prose-invert my-8"> |
72 |
| - <hr> |
73 |
| - </div> |
74 |
| - |
75 |
| - <article class="prose dark:prose-invert"> |
76 |
| - <h3>Front Matter Data</h3> |
77 |
| - <div class="ml-4"> |
78 |
| - @foreach($publication->matter->data as $key => $value) |
79 |
| - <dt class="font-bold">{{ $key }}</dt> |
80 |
| - <dd class="ml-4"> |
81 |
| - {{ is_array($value) ? '(array) '. implode(', ', $value) : $value }} |
82 |
| - </dd> |
83 |
| - @endforeach |
84 |
| - </div> |
85 |
| - </article> |
86 |
| - </main> |
87 |
| - @endsection |
88 |
| - BLADE; |
89 |
| - |
90 |
| - $this->savePublicationFile('detail.blade.php', $contents); |
| 58 | + $this->savePublicationFile('detail.blade.php', 'resources/views/layouts/publication.blade.php'); |
91 | 59 | }
|
92 | 60 |
|
93 | 61 | protected function createListTemplate(): void
|
94 | 62 | {
|
95 |
| - $contents = <<<'BLADE' |
96 |
| - @extends('hyde::layouts.app') |
97 |
| - @section('content') |
98 |
| - <main id="content" class="mx-auto max-w-7xl py-16 px-8"> |
99 |
| - <div class="prose dark:prose-invert"> |
100 |
| - <h1>Publications for type {{ $page->type->name }}</h1> |
101 |
| - <ol> |
102 |
| - @php/** @var \Hyde\Pages\PublicationPage $publication*/@endphp |
103 |
| - @foreach($publications as $publication) |
104 |
| - <li> |
105 |
| - <x-link :href="$publication->getRoute()">{{ $publication->title }}</x-link> |
106 |
| - </li> |
107 |
| - @endforeach |
108 |
| - </ol> |
109 |
| - </div> |
110 |
| - </main> |
111 |
| - @endsection |
112 |
| - BLADE; |
113 |
| - |
114 |
| - $this->savePublicationFile('list.blade.php', $contents); |
| 63 | + $this->savePublicationFile('list.blade.php', 'resources/views/layouts/publication_list.blade.php'); |
115 | 64 | }
|
116 | 65 |
|
117 |
| - protected function savePublicationFile(string $filename, string $contents): int |
| 66 | + protected function savePublicationFile(string $filename, string $viewPath): void |
118 | 67 | {
|
119 |
| - return file_put_contents(Hyde::path("$this->directoryName/$filename"), "$contents\n"); |
| 68 | + copy(Hyde::vendorPath($viewPath), Hyde::path("$this->directoryName/$filename")); |
120 | 69 | }
|
121 | 70 | }
|
0 commit comments