Skip to content

Commit

Permalink
Merge branch 'master' into 2.x-dev
Browse files Browse the repository at this point in the history
  • Loading branch information
caendesilva committed Feb 10, 2024
2 parents 33ecc1c + 30f0d40 commit 2cea704
Show file tree
Hide file tree
Showing 11 changed files with 381 additions and 197 deletions.
68 changes: 27 additions & 41 deletions .github/workflows/deploy-documentation-preview.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,25 +5,21 @@ on:
branches: [ "master" ]
paths:
- 'docs/**'
- '.github/workflows/deploy-documentation-preview.yml'

jobs:

build-documentation-preview:
# We could add a check to only rerun if docs have changed since last run on the PR
# But this would require a state storage, and the current version is good enough.
build-and-deploy-documentation-preview:
if: "! contains(github.event.pull_request.labels.*.name, 'pause-pages')"

environment:
name: pr-documentation-${{ github.event.pull_request.number }}
url: https://hydephp.github.io/develop/pr-${{ github.event.pull_request.number }}/dev-docs-preview
url: https://ci.hydephp.com/previews/develop/${{ github.event.pull_request.number }}

runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v3
- uses: shivammathur/setup-php@v2
with:
php-version: "8.1"

- name: Cache Composer packages
id: composer-cache
Expand All @@ -49,7 +45,7 @@ jobs:
- name: Update configuration files
run: |
echo "output_directories:" >> hyde.yml
echo " Hyde\Pages\DocumentationPage: dev-docs-preview" >> hyde.yml
echo " Hyde\Pages\DocumentationPage: ''" >> hyde.yml
sed -i "s/'header' => env('SITE_NAME', 'HydePHP').' Docs'/'header' => 'PR #${{ github.event.pull_request.number }} - Docs'/g" config/docs.php
- name: Remove published article component
Expand Down Expand Up @@ -87,46 +83,36 @@ jobs:
- name: Configure environment variables
run: |
echo 'SITE_NAME="HydePHP Documentation Preview"' >> .env
echo 'SITE_URL="https://hydephp.github.io/develop/pr-${{ github.event.pull_request.number }}/dev-docs-preview"' >> .env
echo 'SITE_URL="https://ci.hydephp.com/previews/develop/${{ github.event.pull_request.number }}"' >> .env
- name: Move documentation files
run: rm -rf _docs && mv -f docs _docs

- name: Compile the static site
run: php hyde build

- name: Upload artifacts
uses: actions/upload-artifact@v1
with:
name: 'preview-docs'
path: '_site/dev-docs-preview'


upload-generated-site:

runs-on: ubuntu-latest
needs:
- build-documentation-preview

steps:
- uses: actions/checkout@v3
with:
ref: 'gh-pages'
- name: Package the static site
run: zip -r site.zip _site

- name: Reset output directories
- name: Sign the artifact
run: |
rm -rf pr-${{ github.event.pull_request.number }}/dev-docs-preview
mkdir -p pr-${{ github.event.pull_request.number }}/dev-docs-preview
echo '${{ secrets.CI_PREVIEW_SIGNING_RSA_PRIVATE_KEY }}' > private.pem
openssl dgst -sha256 -sign private.pem -out signature.bin site.zip
unlink private.pem
- name: Download documentation artifact
uses: actions/download-artifact@v3
with:
name: preview-docs
path: pr-${{ github.event.pull_request.number }}/dev-docs-preview

- name: Commit changes
uses: EndBug/add-and-commit@v9
with:
pull: 'origin gh-pages'
add: 'pr-${{ github.event.pull_request.number }}/dev-docs-preview'
message: 'Upload documentation preview for PR ${{ github.event.pull_request.number }}'
- name: Upload the artifact
run: |
repository="develop"
bearerToken="${{ secrets.CI_SERVER_TOKEN }}"
pullRequest="${{ github.event.pull_request.number }}"
signature="$(openssl base64 -in signature.bin)"
artifact="site.zip"
curl -X POST --fail-with-body \
-H "Content-Type: multipart/form-data" \
-H "Authorization: Bearer $bearerToken" \
-F "repository=$repository" \
-F "pullRequest=$pullRequest" \
-F "artifact=@$artifact" \
-F "signature=$signature" \
https://ci.hydephp.com/api/deployment-previews
1 change: 0 additions & 1 deletion .github/workflows/hyde-stan.yml
Original file line number Diff line number Diff line change
Expand Up @@ -21,4 +21,3 @@ jobs:

- name: Run HydeFront linter
run: php packages/hydefront/.github/scripts/post-build.php

3 changes: 2 additions & 1 deletion docs/architecture-concepts/the-hydekernel.md
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ The HydeKernel is stored as a singleton in a static property in its own class an
Commonly, you'll use the `Hyde` facade which forwards calls to the singleton instance.
You can also use the `hyde()` function to get the Kernel, and call methods on it.

Since the instance is also bound into the Laravel Application Service Container you can also use Dependency Injection by type-hinting the `HydeKernel::class`.
Since the instance is also bound into the Laravel Application Service Container you can also use Dependency Injection by type-hinting the `HydeKernel::class`.

Here are some examples of how you can call methods on the Kernel. All methods call the same method on the same instance, so it's just a matter of preference.

Expand All @@ -43,6 +43,7 @@ hyde()->version();

The Kernel instance is constructed in `bootstrap.php`, and is available globally as `$hyde`.


## The kernel lifecycle

Whenever we talk about the kernel being "booted" we are talking about the kernel's role in the autodiscovery process.
Expand Down
16 changes: 8 additions & 8 deletions docs/creating-content/documentation-pages.md
Original file line number Diff line number Diff line change
Expand Up @@ -100,12 +100,8 @@ and where the data is from as well as where it can be overridden.
The sidebar is automatically generated from the files in the `_docs` directory. You will probably want to change the order
of these items. You can do this in two ways, either in the config or with front matter using the navigation array settings.

### Table of contents

Hyde automatically generates a table of contents for the page and adds it to the sidebar.

The behaviour of this can be changed in the configuration file.
See [the customization page](customization#navigation-menu--sidebar) for more details.
Since this feature shares a lot of similarities and implementation details with the navigation menu,
I recommend you read the [navigation menu documentation](navigation) page as well to learn more about the fundamentals and terminology.

### Sidebar ordering

Expand Down Expand Up @@ -137,7 +133,7 @@ Sidebar grouping allows you to group items in the sidebar into categories. This
The Hyde docs for instance use this.

The feature is enabled automatically when one or more of your documentation pages have the `navigation.group` property set
in the front matter. This will then switch to a slightly more compact sidebar layout with pages sorted into categories.
in the front matter, or when subdirectories are used. This will then switch to a slightly more compact sidebar layout with pages sorted into categories.
Any pages without the group front matter will get put in the "Other" group.

### Sidebar footer customization
Expand Down Expand Up @@ -169,7 +165,9 @@ You can also automatically group your documentation pages by placing source file

For example, putting a Markdown file in `_docs/getting-started/`, is equivalent to adding the same front matter seen above.

>info Note that when the [flattened output paths](#using-flattened-output-paths) setting is enabled (which it is by default), the file will still be compiled to the `_site/docs/` directory like it would be if you didn't use the subdirectories.
>info Note that when the [flattened output paths](#using-flattened-output-paths) setting is enabled (which it is by default), the file will still be compiled to the `_site/docs/` directory like it would be if you didn't use the subdirectories. Note that this means that you can't have two documentation pages with the same filename as they overwrite each other.

>info Tip: When using subdirectory-based dropdowns, you can set their priority using the directory name as the array key.

### Hiding items

Expand Down Expand Up @@ -252,6 +250,8 @@ Please note that this option is not added to the config file by default, as it's

### Table of contents settings

Hyde automatically generates a table of contents for the page and adds it to the sidebar.

In the `config/docs.php` file you can configure the behaviour, content, and the look and feel of the sidebar table of contents.
You can also disable the feature completely.

Expand Down
2 changes: 1 addition & 1 deletion docs/digging-deeper/advanced-markdown.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
---
navigation:
label: "Advanced Markdown"
priority: 26
priority: 27
---

# Advanced Markdown
Expand Down
151 changes: 7 additions & 144 deletions docs/digging-deeper/customization.md
Original file line number Diff line number Diff line change
Expand Up @@ -212,7 +212,7 @@ Still, you will likely want to customize some parts of these menus, and thankful
- To customize the navigation menu, use the setting `navigation.order` in the `hyde.php` config.
- When customizing the navigation menu, you should use the [route key](core-concepts#route-keys) of the page.

Learn more in the [Navigation Menu](navigation-menus) documentation.
Learn more in the [Navigation Menu](navigation) documentation.

#### Customizing the documentation sidebar

Expand All @@ -221,156 +221,15 @@ Learn more in the [Navigation Menu](navigation-menus) documentation.

Learn more in the [Documentation Pages](documentation-pages) documentation.

>info Tip: When using subdirectory-based dropdowns, you can set their priority using the directory name as the array key.
### Primer on priorities

All navigation menu items have an internal priority value that determines its order in the navigation.
Lower values means that the item will be higher up in the menu. The default for pages is `999` which puts them last.
However, some pages are autoconfigured to have a lower priority, for example, the `index` page defaults to a priority of `0`,

#### Basic syntax for changing the priorities

The cleanest way is to use the list-style syntax where each item will get the priority calculated according to its position in the list, plus an offset of `500`.
The offset is added to make it easier to place pages earlier in the list using front matter or with explicit priority settings.

```php
[
'readme', // Gets priority 500
'installation', // Gets priority 501
'getting-started', // Gets priority 502
]
```

#### Explicit syntax for changing the priorities

You can also specify explicit priorities by adding a value to the array key:

```php
[
'readme' => 10, // Gets priority 10
'installation' => 15, // Gets priority 15
'getting-started' => 20, // Gets priority 20
]
```

You can also combine these options if you want:

```php
[
'readme' => 10, // Gets priority 10
'installation', // Gets priority 500
'getting-started', // Gets priority 501
]
```

You can also set the priority of a page directly in the front matter. This will override any dynamically inferred or
config defined priority. While this is useful for one-offs, it can make it harder to reorder items later on.
It's up to you which method you prefer to use. This setting can be used both for the navigation menu and the sidebar.

```markdown
---
navigation:
priority: 25
---
```

#### Changing the menu item labels

Hyde makes a few attempts to find a suitable label for the navigation menu items to automatically create helpful titles.
You can override the label using the `navigation.label` front matter property.

From the Hyde config you can also override the label of navigation links using the by mapping the route key
to the desired title. Note that the front matter property will take precedence over the config property.

```php
// filepath config/hyde.php
'navigation' => [
'labels' => [
'index' => 'Start',
'docs/index' => 'Documentation',
]
]
```

#### Excluding Items (Blacklist)

Sometimes, especially if you have a lot of pages, you may want to prevent links from showing up in the main navigation menu.
To remove items from being automatically added, simply add the page's route key to the blacklist.
As you can see, the `404` page has already been filled in for you.

```php
// filepath config/hyde.php
'navigation' => [
'exclude' => [
'404'
]
]
```

You can also specify that a page should be excluded by setting the page front matter.

```markdown
---
navigation:
hidden: true
---

#### Adding Custom Navigation Menu Links

You can easily add custom navigation menu links similar how we add Authors. Simply add a `NavItem` model to the `navigation.custom` array.

When linking to an external site, you should use the `NavItem::forLink()` method facade. The first two arguments are the
destination and label, both required. Third argument is the priority, which is optional, and defaults to 500.

```php
// filepath config/hyde.php
use Hyde\Framework\Features\Navigation\NavItem;

'navigation' => [
'custom' => [
NavItem::forLink('https://github.com/hydephp/hyde', 'GitHub', 200),
]
]
```

Simplified, this will then be rendered as follows:

```html
<a href="https://github.com/hydephp/hyde">GitHub</a>
```

#### Automatic navigation menu dropdowns

HydePHP has a neat feature to automatically place pages in dropdowns based on subdirectories.

For pages that can be in the main site menu, ths feature needs to be enabled in the `hyde.php` config file.

```php
// filepath config/hyde.php

'navigation' => [
'subdirectories' => 'dropdown',
],
```

Now if you create a page called `_pages/about/contact.md` it will automatically be placed in a dropdown called "About".

#### Automatic documentation sidebar grouping

This feature works similarly to the automatic navigation menu dropdowns, but instead place the sidebar items in named groups.
This feature is enabled by default, so you only need to place your pages in subdirectories to have them grouped.

For example: `_docs/getting-started/installation.md` will be placed in a group called "Getting Started".

## Additional Advanced Options

The following configuration options in the `confg/hyde.php` file are intended for advanced users and
The following configuration options in the `confg/hyde.php` file are intended for advanced users and
should only be modified if you fully understand their impact. The code examples show the default values.

### `media_extensions`

This option allows you to specify file extensions considered as media files, which will be copied to the output directory.
This option allows you to specify file extensions considered as media files, which will be copied to the output directory.
To add more extensions, either append them to the existing array or override the entire array.

```php
Expand Down Expand Up @@ -423,6 +282,7 @@ use \Hyde\Framework\Services\AssetService;
'hydefront_cdn_url' => AssetService::HYDEFRONT_CDN_URL,
```


## Blade Views

Hyde uses the Laravel Blade templating engine. Most parts of the included templates have been extracted into components to be customized easily.
Expand All @@ -436,12 +296,14 @@ php hyde publish:views

The files will then be available in the `resources/views/vendor/hyde` directory.


## Frontend Styles

Hyde is designed to not only serve as a framework but a whole starter kit and comes with a Tailwind starter template
for you to get up and running quickly. If you want to customize these, you are free to do so.
Please see the [Managing Assets](managing-assets) page to learn more.


## Markdown Configuration

Hyde uses [League CommonMark](https://commonmark.thephpleague.com/) for converting Markdown into HTML, and
Expand Down Expand Up @@ -504,6 +366,7 @@ arbitrary PHP code specified in Markdown to be executed. It's easy to enable how

See the [Blade in Markdown](advanced-markdown#blade-support) documentation for more information on how to use this feature.


## YAML Configuration

The settings in the `config/hyde.php` file can also be set by using a `hyde.yml` file in the root of your project directory.
Expand Down
Loading

0 comments on commit 2cea704

Please sign in to comment.