Skip to content

Commit 439154a

Browse files
committed
Merge branch 'release/4.1.0'
2 parents 9d87765 + b556bd5 commit 439154a

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

57 files changed

+1584
-5334
lines changed

.env.example

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
# Dev server configuration
22
HMR_HOST=localhost
33
HMR_PORT=3000
4-
HMR_ENTRYPOINT=https://${HMR_HOST}:${HMR_PORT}
54

65
# Certificates
76
HMR_HTTPS_CERT=path_to_cert

.stylelintrc

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,5 +3,8 @@
33
"@ravorona/stylelint-config",
44
"stylelint-config-recommended-scss"
55
],
6-
"customSyntax": "postcss-scss"
6+
"customSyntax": "postcss-scss",
7+
"rules": {
8+
"import-notation": "string"
9+
}
710
}

CHANGELOG.md

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,19 @@
1+
## [4.1.0](https://github.com/ravorona/sage/compare/4.0.4...4.1.0) (2023-04-26)
2+
3+
4+
### Features
5+
6+
* Dependencies update ([17a0d1c](https://github.com/ravorona/sage/commit/17a0d1ceb79298291fcb92560de83038ac1f7cef)), closes [#14](https://github.com/ravorona/sage/issues/14)
7+
* Documentation update ([c7b08d2](https://github.com/ravorona/sage/commit/c7b08d21b79488cb79435ff3aaa26be88c7a8d70))
8+
* Localized vars example ([763625f](https://github.com/ravorona/sage/commit/763625fff087332e32e1c27e3ab472e0fac6e9b5))
9+
* Sage 10.5.1 ([193958f](https://github.com/ravorona/sage/commit/193958f28829780d21832233a4533059f05ba30d)), closes [#13](https://github.com/ravorona/sage/issues/13)
10+
* Vite watch option example for windows os user ([603c16c](https://github.com/ravorona/sage/commit/603c16c5af9eca7f2f6a03ea00f3d17d26dcf62f))
11+
12+
13+
### Bug Fixes
14+
15+
* Assets path in HMR Mode ([17907fa](https://github.com/ravorona/sage/commit/17907fa0b3e72a456ce7f82524711436af749dcc)), closes [#12](https://github.com/ravorona/sage/issues/12)
16+
117
### [4.0.4](https://github.com/ravorona/sage/compare/4.0.3...4.0.4) (2023-03-24)
218

319

README.md

Lines changed: 29 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -2,21 +2,24 @@
22

33
# 🧩 Wordpress Starter Theme
44

5-
- Based on [Sage](https://roots.io/sage/) version [10](https://github.com/roots/sage/)
6-
- Using [Vite](https://vitejs.dev)
5+
- Based on [Sage](https://roots.io/sage/) version [10](https://github.com/roots/sage/)
6+
- Using [Vite](https://vitejs.dev)
77

88
## Requirements
99

10-
- [Acorn](https://docs.roots.io/acorn/2.x/installation/) v2
11-
- [PHP](https://secure.php.net/manual/en/install.php) >= 8.0.2 (with [`php-mbstring`](https://secure.php.net/manual/en/book.mbstring.php) enabled)
12-
- [Composer](https://getcomposer.org/download/)
13-
- [Vite](https://vitejs.dev) >= 3.1.0
14-
- [Node.js](http://nodejs.org/) >= 14.0.0
15-
- [Yarn](https://yarnpkg.com/en/docs/install)
10+
- [Acorn](https://roots.io/acorn/docs/installation/) v3
11+
- [PHP](https://secure.php.net/manual/en/install.php) >= 8.0 (
12+
with [`php-mbstring`](https://secure.php.net/manual/en/book.mbstring.php) enabled)
13+
- [Composer](https://getcomposer.org/download/)
14+
- [Vite](https://vitejs.dev) >= 3.1.0
15+
- [Node.js](http://nodejs.org/) >= 16.0.0
16+
- [Yarn](https://yarnpkg.com/en/docs/install)
1617

1718
## Theme installation
1819

19-
Install Sage using Composer from your WordPress themes directory (replace `your-theme-name` below with the name of your theme):
20+
- **Make sure that you have [Acorn installed](https://roots.io/acorn/docs/installation/)**
21+
- Install Sage using Composer from your WordPress themes directory (replace `your-theme-name` below with the name of
22+
your theme):
2023

2124
```shell
2225
# @ app/themes/ or wp-content/themes/
@@ -66,35 +69,39 @@ themes/your-theme-name/ # → Root of your Sage based theme
6669

6770
## Theme development
6871

69-
- Run `yarn` from the theme directory to install dependencies
70-
- Update `vite.config.ts` for bundler fine tuning
72+
- Run `yarn` from the theme directory to install dependencies
73+
- Update `vite.config.ts` for bundler fine tuning
7174

7275
### Build commands
7376

74-
- `yarn dev` — Start dev server
75-
- `yarn build` — Compile assets
76-
- `yarn lint` — Lint stylesheets & javascripts
77-
- `yarn lint:css` — Lint stylesheets
78-
- `yarn lint:js` — Lint javascripts
77+
- `yarn dev` — Start dev server
78+
- `yarn build` — Compile assets
79+
- `yarn lint` — Lint stylesheets & javascripts
80+
- `yarn lint:css` — Lint stylesheets
81+
- `yarn lint:js` — Lint javascripts
7982

80-
### Hot reload mode
83+
### Hot Module Replacement
8184

8285
#### Project Side
86+
8387
Add the following variables in your project `.env`
8488

8589
```sh
86-
# If true hot reload is active
90+
# If true hot reload is active.
91+
# If not specified or set to false, and if the `public/manifest.json` file is missing, HMR is automatically enabled.
8792
HMR_ENABLED=true
8893

8994
# Endpoint where the bundler serve your assets
9095
HMR_ENTRYPOINT=http://example.com:3000
9196
```
9297

9398
#### Theme side
94-
For advanced dev server configuration, copy `.env.example` according to [Vite naming convention and loading order](https://vitejs.dev/guide/env-and-mode.html#env-files) and update variables
99+
100+
For advanced dev server configuration, copy `.env.example` according
101+
to [Vite naming convention and loading order](https://vitejs.dev/guide/env-and-mode.html#env-files) and update variables
95102

96103
## Documentation
97104

98-
- [Sage documentation](https://roots.io/sage/docs/)
99-
- [Controller documentation](https://github.com/soberwp/controller#usage)
100-
- [Vite](https://vitejs.dev/guide/)
105+
- [Sage documentation](https://roots.io/sage/docs/)
106+
- [Controller documentation](https://github.com/soberwp/controller#usage)
107+
- [Vite](https://vitejs.dev/guide/)
Lines changed: 24 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,30 @@
11
<?php
2+
/*
3+
* Copyright (c) 2023 яαvoroηα
4+
*
5+
* Permission is hereby granted, free of charge, to any person obtaining a copy of
6+
* this software and associated documentation files (the "Software"), to deal in
7+
* the Software without restriction, including without limitation the rights to
8+
* use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of
9+
* the Software, and to permit persons to whom the Software is furnished to do so,
10+
* subject to the following conditions:
11+
*
12+
* The above copyright notice and this permission notice shall be included in all
13+
* copies or substantial portions of the Software.
14+
*
15+
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16+
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
17+
* FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
18+
* COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
19+
* IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
20+
* CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
21+
*/
222

323
namespace App\Providers;
424

5-
use Roots\Acorn\ServiceProvider;
25+
use Roots\Acorn\Sage\SageServiceProvider;
626

7-
class ThemeServiceProvider extends ServiceProvider
27+
class ThemeServiceProvider extends SageServiceProvider
828
{
929
/**
1030
* Register any application services.
@@ -13,7 +33,7 @@ class ThemeServiceProvider extends ServiceProvider
1333
*/
1434
public function register()
1535
{
16-
//
36+
parent::register();
1737
}
1838

1939
/**
@@ -23,6 +43,6 @@ public function register()
2343
*/
2444
public function boot()
2545
{
26-
//
46+
parent::boot();
2747
}
2848
}

app/View/Components/Alert.php

Lines changed: 25 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,28 @@
11
<?php
2+
/*
3+
* Copyright (c) 2023 яαvoroηα
4+
*
5+
* Permission is hereby granted, free of charge, to any person obtaining a copy of
6+
* this software and associated documentation files (the "Software"), to deal in
7+
* the Software without restriction, including without limitation the rights to
8+
* use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of
9+
* the Software, and to permit persons to whom the Software is furnished to do so,
10+
* subject to the following conditions:
11+
*
12+
* The above copyright notice and this permission notice shall be included in all
13+
* copies or substantial portions of the Software.
14+
*
15+
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16+
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
17+
* FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
18+
* COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
19+
* IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
20+
* CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
21+
*/
222

323
namespace App\View\Components;
424

25+
use Illuminate\View\View;
526
use Roots\Acorn\View\Component;
627

728
class Alert extends Component
@@ -35,8 +56,9 @@ class Alert extends Component
3556
/**
3657
* Create the component instance.
3758
*
38-
* @param string $type
39-
* @param string $message
59+
* @param string $type
60+
* @param string $message
61+
*
4062
* @return void
4163
*/
4264
public function __construct($type = 'default', $message = null)
@@ -48,7 +70,7 @@ public function __construct($type = 'default', $message = null)
4870
/**
4971
* Get the view / contents that represent the component.
5072
*
51-
* @return \Illuminate\View\View|string
73+
* @return View|string
5274
*/
5375
public function render()
5476
{

app/View/Composers/App.php

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,24 @@
11
<?php
2+
/*
3+
* Copyright (c) 2023 яαvoroηα
4+
*
5+
* Permission is hereby granted, free of charge, to any person obtaining a copy of
6+
* this software and associated documentation files (the "Software"), to deal in
7+
* the Software without restriction, including without limitation the rights to
8+
* use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of
9+
* the Software, and to permit persons to whom the Software is furnished to do so,
10+
* subject to the following conditions:
11+
*
12+
* The above copyright notice and this permission notice shall be included in all
13+
* copies or substantial portions of the Software.
14+
*
15+
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16+
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
17+
* FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
18+
* COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
19+
* IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
20+
* CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
21+
*/
222

323
namespace App\View\Composers;
424

app/View/Composers/Post.php

Lines changed: 21 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,24 @@
11
<?php
2+
/*
3+
* Copyright (c) 2023 яαvoroηα
4+
*
5+
* Permission is hereby granted, free of charge, to any person obtaining a copy of
6+
* this software and associated documentation files (the "Software"), to deal in
7+
* the Software without restriction, including without limitation the rights to
8+
* use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of
9+
* the Software, and to permit persons to whom the Software is furnished to do so,
10+
* subject to the following conditions:
11+
*
12+
* The above copyright notice and this permission notice shall be included in all
13+
* copies or substantial portions of the Software.
14+
*
15+
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16+
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
17+
* FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
18+
* COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
19+
* IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
20+
* CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
21+
*/
222

323
namespace App\View\Composers;
424

@@ -54,7 +74,7 @@ public function title()
5474

5575
if (is_search()) {
5676
return sprintf(
57-
/* translators: %s is replaced with the search query */
77+
/* translators: %s is replaced with the search query */
5878
__('Search Results for %s', 'sage'),
5979
get_search_query()
6080
);

app/filters.php

Lines changed: 20 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,24 @@
11
<?php
2+
/*
3+
* Copyright (c) 2023 яαvoroηα
4+
*
5+
* Permission is hereby granted, free of charge, to any person obtaining a copy of
6+
* this software and associated documentation files (the "Software"), to deal in
7+
* the Software without restriction, including without limitation the rights to
8+
* use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of
9+
* the Software, and to permit persons to whom the Software is furnished to do so,
10+
* subject to the following conditions:
11+
*
12+
* The above copyright notice and this permission notice shall be included in all
13+
* copies or substantial portions of the Software.
14+
*
15+
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16+
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
17+
* FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
18+
* COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
19+
* IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
20+
* CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
21+
*/
222

323
/**
424
* Theme filters.
@@ -15,7 +35,6 @@
1535
return sprintf(' &hellip; <a href="%s">%s</a>', get_permalink(), __('Continued', 'sage'));
1636
});
1737

18-
1938
/**
2039
* Load scripts asset as module
2140
*

app/helpers.php

Lines changed: 18 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -1,26 +1,24 @@
11
<?php
22

33
/*
4-
* MIT License
4+
* Copyright (c) 2023 яαvoroηα
55
*
6-
* Copyright (c) 2022 яαvoroηα
6+
* Permission is hereby granted, free of charge, to any person obtaining a copy of
7+
* this software and associated documentation files (the "Software"), to deal in
8+
* the Software without restriction, including without limitation the rights to
9+
* use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of
10+
* the Software, and to permit persons to whom the Software is furnished to do so,
11+
* subject to the following conditions:
712
*
8-
* Permission is hereby granted, free of charge, to any person obtaining a copy of
9-
* this software and associated documentation files (the "Software"), to deal in
10-
* the Software without restriction, including without limitation the rights to use,
11-
* copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the
12-
* Software, and to permit persons to whom the Software is furnished to do so,
13-
* subject to the following conditions:
13+
* The above copyright notice and this permission notice shall be included in all
14+
* copies or substantial portions of the Software.
1415
*
15-
* The above copyright notice and this permission notice shall be included in all
16-
* copies or substantial portions of the Software.
17-
*
18-
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
19-
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
20-
* FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
21-
* COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
22-
* AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH
23-
* THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
16+
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17+
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
18+
* FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
19+
* COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
20+
* IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
21+
* CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
2422
*/
2523

2624
namespace App;
@@ -32,18 +30,19 @@
3230
*/
3331
function hmr_enabled(): bool
3432
{
35-
return env('HMR_ENABLED') ?: false;
33+
return env('HMR_ENABLED') ?: !file_exists(get_theme_file_path('/public/manifest.json'));
3634
}
3735

3836
/**
3937
* Build assets hmr uri
4038
*
4139
* @param string $asset
40+
*
4241
* @return string
4342
*/
4443
function hmr_assets(string $asset): string
4544
{
46-
$entrypoint = env('HMR_ENTRYPOINT');
45+
$entrypoint = env('HMR_ENTRYPOINT') ?: 'http://localhost:5173';
4746

4847
return $entrypoint ? "{$entrypoint}/{$asset}" : asset($asset);
4948
}

0 commit comments

Comments
 (0)