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

Configuration and autodiscovery improvements #340

Merged
merged 80 commits into from
May 15, 2022

Conversation

caendesilva
Copy link
Member

@caendesilva caendesilva commented May 14, 2022

New features:

  • Allow the project root to be changed at runtime
  • Allow the source directories to be changed
  • You can now enable "pretty URLs" where links can be generated without the .html extension. See Add configurable "pretty URLs" #354

Changes:

Other:

  • Allow the creation of default directories to be disabled (useful when including the framework package in non-Hyde installations (like Buddy))

Will close the following:
Fix #343
Fix #336
Fix #330
Fix #349
Fix #353
Fix #350

Will also fix #307

While not utilizing the service container directly, what I was trying to accomplish by doing so has been implemented in this branch, and so I think it can also resolve #332

@caendesilva
Copy link
Member Author

caendesilva commented May 14, 2022

Added config option to change the source directories ```php public static string $sourceDirectory = config('hyde.findPostsIn', '_posts'); ```

Note that the test suite assumes the default directories, as does the HydeRC, meaning that changing source directories at this time will probably cause the realtime compiler to fail.

Still need to add test before I can merge

Edit: Might resolve #336

Edit: Nope, does not work. Sorry.

@caendesilva
Copy link
Member Author

caendesilva commented May 15, 2022

Okay, think I got a workflow for customizing source directories that I like and in a way that improves the original behaviour instead of completely changing it.

The pages are now registered in the HydeServiceProvider

$this->registerDefaultDirectories([
  BladePage::class => '_pages',
  MarkdownPage::class => '_pages',
  MarkdownPost::class => '_posts',
  DocumentationPage::class => '_docs',
]);

// If you change the Blade source directory, the config needs to be updated.
// It can be done using this helper found in the same service provider.
$this->discoverBladeViewsIn('_pages');

They are then stored in the same static class property that already exists

protected function registerDefaultDirectories(array $directoryMapping)
{
  foreach ($directoryMapping as $class => $location) {
    $class::$sourceDirectory = $location;
  }
}

You can then change these directories in many ways. My suggested way would be by adding your own service provider,
(make sure it's loaded after the Hyde one), use the RegistersDefaultDirectories trait, and change the directories in the register method.

Again, note that the test suite assumes the default directories, as does the HydeRC, meaning that changing source directories at this time will probably cause the realtime compiler to fail. You also need to take care when changing directories to avoid conflicts. For example, if you store both source documentation Markdown files in the same directory as blog posts Hyde won't know which layout to use.

@caendesilva caendesilva changed the title Configuration improvements Configuration and autodiscovery improvements May 15, 2022
@caendesilva
Copy link
Member Author

I also want to implement changing of the output directories

caendesilva and others added 2 commits May 15, 2022 14:46
caendesilva and others added 28 commits May 15, 2022 17:46
[ci skip] [skip ci]
…ramework into 330-add-option-for-pretty-urls
[ci skip] [skip ci]
…ramework into 330-add-option-for-pretty-urls
[ci skip] [skip ci]
[ci skip] [skip ci]
[ci skip] [skip ci]
@caendesilva caendesilva merged commit 0637af7 into master May 15, 2022
@caendesilva caendesilva deleted the configuration-improvements branch May 15, 2022 20:33
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment