Skip to content

Commit

Permalink
Merge pull request #7 from arnoson/master
Browse files Browse the repository at this point in the history
Add options for defer async etc.
  • Loading branch information
RobertCordes authored Aug 11, 2020
2 parents 390c328 + a5035fd commit a55afcf
Showing 1 changed file with 8 additions and 4 deletions.
12 changes: 8 additions & 4 deletions index.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,12 +8,16 @@
* Get the appropriate HTML tag with the right path for the (versioned) Mix file.
*
* @param string $path Path as it appears in the mix-manifest.json
*
* @param string|bool|array $options Pass an array of attributes for the tag
* or a string/bool. A string behaves in the same way as in Kirby's `css()`
* and `js()` helper functions: for css files it will be used as the value
* of the media attribute, for js files it will determine wether or not the
* script is async.
* @return string Either a <link> or a <script> tag, depending on the $path
*
* @throws \Exception
*/
function mix($path)
function mix($path, $options = null)
{
$kirby = kirby();

Expand Down Expand Up @@ -103,9 +107,9 @@ function mix($path)
$pathExtension = F::extension($mixFilePath);

if (Str::contains($pathExtension, 'css')) {
$mixFileLink = css($mixFilePath);
$mixFileLink = css($mixFilePath, $options);
} elseif (Str::contains($pathExtension, 'js')) {
$mixFileLink = js($mixFilePath);
$mixFileLink = js($mixFilePath, $options);
} else {
if (option('debug')) {
throw new Exception("File type not recognized");
Expand Down

0 comments on commit a55afcf

Please sign in to comment.