Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Change blade source directory to _pages #90

Merged
merged 7 commits into from
Apr 9, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions config/view.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
return [
'paths' => [
resource_path('views'),
base_path('_pages'),
],

'compiled' => env(
Expand Down
2 changes: 1 addition & 1 deletion src/Actions/CreatesDefaultDirectories.php
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ class CreatesDefaultDirectories
'_site/posts',
'_site/media',
'_site/docs',
'resources/views/pages',
'_pages',
];

/**
Expand Down
2 changes: 1 addition & 1 deletion src/Actions/CreatesNewPageSourceFile.php
Original file line number Diff line number Diff line change
Expand Up @@ -108,7 +108,7 @@ public function createMarkdownFile(): int|false
*/
public function createBladeFile(): int|false
{
$this->path = Hyde::path("resources/views/pages/$this->slug.blade.php");
$this->path = Hyde::path("_pages/$this->slug.blade.php");

$this->canSaveFile($this->path);

Expand Down
2 changes: 1 addition & 1 deletion src/Actions/GeneratesNavigationMenu.php
Original file line number Diff line number Diff line change
Expand Up @@ -162,7 +162,7 @@ private function getListOfCustomPages(): array
{
$array = [];

foreach (glob(Hyde::path('resources/views/pages/*.blade.php')) as $path) {
foreach (glob(Hyde::path('_pages/*.blade.php')) as $path) {
$array[] = basename($path, '.blade.php');
}

Expand Down
2 changes: 1 addition & 1 deletion src/Actions/PublishesHomepageView.php
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ public function execute(): bool|int

return Hyde::copy(
Hyde::vendorPath(static::$homePages[$this->selected]['path']),
Hyde::path('resources/views/pages/index.blade.php'),
Hyde::path('_pages/index.blade.php'),
$this->force
);
}
Expand Down
4 changes: 2 additions & 2 deletions src/Commands/HydePublishHomepageCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -101,12 +101,12 @@ protected function askToRebuildSite()

protected function canExistingIndexFileBeOverwritten(): bool
{
if (! file_exists(Hyde::path('resources/views/pages/index.blade.php')) || $this->option('force')) {
if (! file_exists(Hyde::path('_pages/index.blade.php')) || $this->option('force')) {
return true;
}

return FileCacheService::checksumMatchesAny(FileCacheService::unixsumFile(
Hyde::path('resources/views/pages/index.blade.php')
Hyde::path('_pages/index.blade.php')
)) ?? $this->option('force');
}
}
4 changes: 2 additions & 2 deletions src/Commands/HydePublishTestFilesCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -59,12 +59,12 @@ public function handle(): int
// outside of testing I think it's okay.
copy(
Hyde::path('vendor/hyde/framework/resources/views/homepages/post-feed.blade.php'),
Hyde::path('resources/views/pages/index.blade.php')
Hyde::path('_pages/index.blade.php')
);

copy(
Hyde::path('vendor/hyde/framework/resources/views/pages/404.blade.php'),
Hyde::path('resources/views/pages/404.blade.php')
Hyde::path('_pages/404.blade.php')
);

$this->info('Done!');
Expand Down
2 changes: 1 addition & 1 deletion src/Commands/HydeRebuildStaticSiteCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -113,7 +113,7 @@ public function validate(): void
if (! (str_starts_with($this->path, '_docs') ||
str_starts_with($this->path, '_posts') ||
str_starts_with($this->path, '_pages') ||
str_starts_with($this->path, 'resources/views/pages')
str_starts_with($this->path, '_pages')
)) {
throw new Exception("Path [$this->path] is not in a valid source directory.", 400);
}
Expand Down
2 changes: 1 addition & 1 deletion src/HydeServiceProvider.php
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ public function boot()
], 'hyde-components');

$this->publishes([
__DIR__.'/../resources/views/pages/404.blade.php' => resource_path('views/pages/404.blade.php'),
__DIR__.'/../_pages/404.blade.php' => resource_path('views/pages/404.blade.php'),
], 'hyde-page-404');
}
}
2 changes: 1 addition & 1 deletion src/Models/BladePage.php
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ public function __construct(string $view)
$this->view = $view;
}

public static string $sourceDirectory = 'resources/views/pages';
public static string $sourceDirectory = '_pages';
public static string $fileExtension = '.blade.php';
public static string $parserClass = self::class;

Expand Down
10 changes: 5 additions & 5 deletions src/Services/BuildService.php
Original file line number Diff line number Diff line change
Expand Up @@ -59,15 +59,15 @@ public static function findModelFromFilePath(string $filepath): string|false
return MarkdownPost::class;
}

if (str_starts_with($filepath, '_pages')) {
return MarkdownPage::class;
}

if (str_starts_with($filepath, '_docs')) {
return DocumentationPage::class;
}

if (str_starts_with($filepath, 'resources/views/pages')) {
if (str_starts_with($filepath, '_pages') && str_ends_with($filepath, '.md')) {
return MarkdownPage::class;
}

if (str_starts_with($filepath, '_pages') && str_ends_with($filepath, '.blade.php')) {
return BladePage::class;
}

Expand Down
2 changes: 1 addition & 1 deletion src/Services/CollectionService.php
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ public static function getBladePageList(): array
{
$array = [];

foreach (glob(Hyde::path('resources/views/pages/*.blade.php')) as $filepath) {
foreach (glob(Hyde::path('_pages/*.blade.php')) as $filepath) {
$array[] = basename($filepath, '.blade.php');
}

Expand Down
2 changes: 1 addition & 1 deletion src/StaticPageBuilder.php
Original file line number Diff line number Diff line change
Expand Up @@ -123,7 +123,7 @@ private function compilePage(): string
*/
private function compileView(): string
{
return view('pages/'.$this->page->view, [
return view($this->page->view, [
'currentPage' => $this->page->view,
])->render();
}
Expand Down