Skip to content

Commit

Permalink
Merge pull request #964 from hydephp/merge-site-config-into-hyde-config
Browse files Browse the repository at this point in the history
Merge options from site.php config into hyde.php
  • Loading branch information
caendesilva authored Feb 11, 2023
2 parents dbd4435 + 70392e2 commit 0cff459
Show file tree
Hide file tree
Showing 53 changed files with 440 additions and 478 deletions.
1 change: 1 addition & 0 deletions RELEASE_NOTES.md
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@ These are changes that break backwards compatibility and that are likely to conc

- HydePHP now requires PHP 8.1 or higher.
- Almost all namespaces in the framework have been changed and restructured.
- The `config/site.php` file has been merged into `config/hyde.php`. See https://github.com/hydephp/develop/pull/964 for the upgrade guide.

#### Breaking internal changes
These are changes that break backwards compatibility but are unlikely to concern users using HydePHP to create sites.
Expand Down
2 changes: 1 addition & 1 deletion _pages/404.blade.php
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@
Sorry, the page you are looking for could not be found.
</p>

<a href="{{ config('site.url') ?? '/' }}">
<a href="{{ config('hyde.url') ?? '/' }}">
<button
class="bg-transparent text-grey-darkest font-bold uppercase tracking-wide py-3 px-6 border-2 border-grey-light hover:border-grey rounded-lg">
Go Home
Expand Down
138 changes: 133 additions & 5 deletions config/hyde.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,23 @@

/*
|--------------------------------------------------------------------------
| The HydePHP Configuration File
| __ __ __ ___ __ _____
| / // /_ _____/ /__ / _ \/ // / _ \
| / _ / // / _ / -_) ___/ _ / ___/
| /_//_/\_, /\_,_/\__/_/ /_//_/_/
| /___/
|--------------------------------------------------------------------------
|
| This configuration file lets you change and customize the behaviour
| of your HydePHP site. To customize the presentation options, like
| the site name, please see the new config/site.php file instead.
| Welcome to HydePHP! In this file, you can customize your new Static Site!
|
| HydePHP favours convention over configuration and as such requires virtually
| no configuration out of the box to get started. Though, you may want to
| change the options to personalize your site and make it your own!
|
| Tip: The settings here can also be overridden by creating a hyde.yml file
| in the root of your project directory. Note that these cannot call any
| PHP functions, so you can't use env() or similar helpers. Also, note
| that any settings in the yml file will override settings here.
|
*/

Expand All @@ -17,6 +28,123 @@

return [

/*
|--------------------------------------------------------------------------
| Site Name
|--------------------------------------------------------------------------
|
| This value sets the name of your site and is, for example, used in
| the compiled page titles and more. The default value is HydePHP.
|
*/

'name' => env('SITE_NAME', 'HydePHP'),

/*
|--------------------------------------------------------------------------
| Site Base URL
|--------------------------------------------------------------------------
|
| Setting a base URL is highly recommended, and is required to use some
| HydePHP features, like automatic sitemaps and RSS feeds.
|
| If you are serving your site from a subdirectory,
| you will need to include that in the path.
|
*/

'url' => env('SITE_URL', 'http://localhost'),

/*
|--------------------------------------------------------------------------
| Pretty URLs
|--------------------------------------------------------------------------
|
| When the setting is enabled, generated links in the compiled HTML site
| are without the .html extension. Since this breaks local browsing you
| can leave the setting disabled, and instead add the --pretty-urls flag
| when running the php hyde build command for deployment.
|
| Note that this can cause issues when you are serving from a subdirectory.
| See https://github.com/hydephp/develop/issues/228
|
*/

'pretty_urls' => false,

/*
|--------------------------------------------------------------------------
| Sitemap Generation
|--------------------------------------------------------------------------
|
| When the setting is enabled, a sitemap.xml file will automatically be
| generated when the site is built.
|
| This feature requires that a site base URL has been set.
|
*/

'generate_sitemap' => true,

/*
|--------------------------------------------------------------------------
| RSS Feed Generation
|--------------------------------------------------------------------------
|
| When enabled, an RSS feed with your Markdown blog posts will be
| generated when you compile your static site.
|
| This feature requires that a site base URL has been set.
|
*/

// Should the RSS feed be generated?
'generate_rss_feed' => true,

// What filename should the RSS file use?
'rss_filename' => 'feed.xml',

// The channel description. By default this is "Site Name + RSS Feed".
// 'rss_description' => '',

/*
|--------------------------------------------------------------------------
| Site Language
|--------------------------------------------------------------------------
|
| This value sets the language of your site and is used for the
| <html lang=""> element in the app layout. Default is 'en'.
|
*/

'language' => 'en',

/*
|--------------------------------------------------------------------------
| Site Output Directory
|--------------------------------------------------------------------------
|
| This setting specifies the output path for your site, useful to for
| example, store the site in the docs/ directory for GitHub Pages.
| The path is relative to the root of your project.
|
*/

'output_directory' => '_site',

/*
|--------------------------------------------------------------------------
| Media Directory
|--------------------------------------------------------------------------
|
| This setting specifies the directory where your media files are stored.
| Note that this affects both the source and output directories.
| The path is relative to the root of your project.
|
*/

'media_directory' => '_media',

/*
|--------------------------------------------------------------------------
| Built-in Server
Expand Down Expand Up @@ -65,7 +193,7 @@
// Meta::name('description', 'My Hyde Blog'),
// Meta::name('keywords', 'Static Sites, Blogs, Documentation'),
Meta::name('generator', 'HydePHP '.Hyde\Hyde::version()),
Meta::property('site_name', config('site.name', 'HydePHP')),
Meta::property('site_name', env('SITE_NAME', 'HydePHP')),
],

/*
Expand Down
143 changes: 0 additions & 143 deletions config/site.php

This file was deleted.

2 changes: 1 addition & 1 deletion docs/digging-deeper/advanced-customization.md
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ When run, Hyde will update the source directory setting in the config file, then
The media directory houses assets like images and stylesheets. The default directory is `_media`, and upon building the site,
Hyde will copy all files in this directory to `_site/media` (or whatever your configured output and media directories are).

You can change the path to this directory by setting the `media_directory` setting in `config/site.php`.
You can change the path to this directory by setting the `media_directory` setting in `config/hyde.php`.
Note that this change will affect both the source and output directories. For example, if you set the value to `assets`,
all files from `assets` will be copied to `_site/assets`.

Expand Down
24 changes: 12 additions & 12 deletions docs/digging-deeper/customization.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ navigation:
Hyde favours <a href="https://en.wikipedia.org/wiki/Convention_over_configuration">"Convention over Configuration"</a>
and comes preconfigured with sensible defaults. However, Hyde also strives to be modular and endlessly customizable if you need it. This page guides you through the many options available!

When referencing configuration options, we often use "dot notation" to specify the configuration file. For example, <code>config('site.name')</code> means that we are looking for the <code>name</code> option in the <code>config/site.php</code> file.
When referencing configuration options, we often use "dot notation" to specify the configuration file. For example, <code>config('hyde.name')</code> means that we are looking for the <code>name</code> option in the <code>config/hyde.php</code> file.

If you want to reference these configuration options in your Blade views, or other integrations, please take a look at the [Laravel Documentation](https://laravel.com/docs/9.x/configuration).

Expand All @@ -29,15 +29,14 @@ Below are two tables over the different configuration files. Click on a file nam

These are the main configuration files for HydePHP and lets you customize the look and feel of your site, as well as the behaviour of HydePHP.

| Config File | Description |
|--------------------------------------------------------------------------------------------------------------------|-------------------------------------------------------------------------------------|
| <a href="https://github.com/hydephp/hyde/blob/master/config/site.php" rel="nofollow noopener">site.php</a> | Configuration file for the site presentation settings, like site name and base URL. |
| <a href="https://github.com/hydephp/hyde/blob/master/config/hyde.php" rel="nofollow noopener">hyde.php</a> | HydePHP Framework settings, like what features to enable, and navigation menus. |
| <a href="https://github.com/hydephp/hyde/blob/master/config/docs.php" rel="nofollow noopener">docs.php</a> | Options for the HydePHP documentation site generator module. |
| <a href="https://github.com/hydephp/hyde/blob/master/config/markdown.php" rel="nofollow noopener">markdown.php</a> | Configure Markdown related services, as well as change the CommonMark extensions. |
| Config File | Description |
|--------------------------------------------------------------------------------------------------------------------|---------------------------------------------------------------------------------------------------------------------------------------|
| <a href="https://github.com/hydephp/hyde/blob/master/config/hyde.php" rel="nofollow noopener">hyde.php</a> | Main HydePHP configuration file. Used for things ranging from site name and base URL to navigation menus and what features to enable. |
| <a href="https://github.com/hydephp/hyde/blob/master/config/docs.php" rel="nofollow noopener">docs.php</a> | Options for the HydePHP documentation site generator module. |
| <a href="https://github.com/hydephp/hyde/blob/master/config/markdown.php" rel="nofollow noopener">markdown.php</a> | Configure Markdown related services, as well as change the CommonMark extensions. |
{.align-top}

>info Tip: The values in site.php can also be set in YAML by creating a hyde.yml file in the root of your project. See [#yaml-configuration](#yaml-configuration) for more information.
>info Tip: The values in hyde.php can also be set in YAML by creating a hyde.yml file in the root of your project. See [#yaml-configuration](#yaml-configuration) for more information.
### Laravel & Package Configuration Files

Expand Down Expand Up @@ -315,11 +314,12 @@ In the same file you can also change the config to be passed to the CommonMark e

## YAML Configuration

As a relatively new and experimental feature, the settings in the config/site.php can also be overridden by creating
a hyde.yml file in the root of your project directory. Note that these cannot reference environment variables,
and their values override any made in the PHP config.
The settings in the config/hyde.php file can also be overridden by creating a hyde.yml file in the root of your project directory.

Here is an example hyde.yml file matching the default site.yml:
Note that these cannot reference environment variables and you cannot interact with objects and services.
But that doesn't stop you from using both files if you want to. Just keep in mind that any values in yhe YAML file override any made in the PHP config.

Here is an example hyde.yml file showing some of the available options in the normal hyde.php file.

```yaml
# filepath hyde.yml
Expand Down
Loading

0 comments on commit 0cff459

Please sign in to comment.