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

Add configuration options to add HTML to the head and scripts sections #1542

Merged
merged 16 commits into from
Feb 11, 2024

Conversation

caendesilva
Copy link
Member

@caendesilva caendesilva commented Feb 9, 2024

Add Head and Script HTML Hooks

This pull request adds support for the new configuration options head and scripts infor HydePHP v1.5.

In order to provide users with a more flexible way to add custom HTML to their site's <head> or just before the closing </body> tag, this pull request introduces new configuration options in the config/hyde.php file and the hyde.yml file.

Changes Made:

  • Added new head configuration option to the hyde.php file and the hyde.yml file
  • Added new scripts configuration option to the hyde.php file and the hyde.yml file

Usage:

To add custom HTML to your layouts, you can now utilize the head and scripts configuration options in the config/hyde.php file or the hyde.yml file.

Example of adding custom HTML in config/hyde.php:

'head' => '<!-- Custom HTML in the head -->',
'scripts' => '<!-- Custom HTML in the body -->',

Example of adding custom HTML in hyde.yml:

hyde:
  head: "<!-- Custom HTML in the head -->"
  scripts: "<!-- Custom HTML in the body -->"

Additionally, you can add multiple lines of HTML:

Example of adding multiple lines of HTML in config/hyde.php:

'head' => <<<HTML
    <!-- Custom HTML in the head -->
    <link rel="stylesheet" href="https://example.com/styles.css">
HTML,

Example of adding multiple lines of HTML in hyde.yml:

hyde:
  head: |
    <!-- Custom HTML in the head -->
    <link rel="stylesheet" href="https://example.com/styles.css">

Please note that the custom HTML added using these options will be applied to all pages. If you need to add HTML to a specific page, you will need to override the layout for that page.

Feel free to review and provide any feedback or suggestions for improvement. Thank you!

Technical Details

  • Files Modified: config/hyde.php, hyde.yml
  • Added Configuration Options: head, scripts

Copy link

codecov bot commented Feb 9, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Comparison is base (3bb136e) 100.00% compared to head (eb959a9) 100.00%.

Additional details and impacted files
@@              Coverage Diff              @@
##              master     #1542     +/-   ##
=============================================
  Coverage     100.00%   100.00%             
- Complexity      1740      3480   +1740     
=============================================
  Files            180       360    +180     
  Lines           4715      9430   +4715     
=============================================
+ Hits            4715      9430   +4715     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@caendesilva
Copy link
Member Author

882bafc may be implemented in a separate PR to keep this scope smaller. Clearing it from the branch now.

config/hyde.php Outdated Show resolved Hide resolved
@caendesilva caendesilva force-pushed the improved-head-and-scripts-includes branch from 27d7d6b to 587ce5d Compare February 9, 2024 11:31
Copy link
Member Author

@caendesilva caendesilva left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Add test to make sure this works on documentation pages. Edit: Tested to confirm

@caendesilva caendesilva temporarily deployed to pr-documentation-1542 February 9, 2024 11:59 — with GitHub Actions Inactive
@caendesilva caendesilva temporarily deployed to pr-documentation-1542 February 10, 2024 13:55 — with GitHub Actions Inactive
@caendesilva caendesilva changed the title Improved head and scripts includes Add configuration options to add HTML to the head and scripts sections Feb 10, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant