Skip to content

Commit f442f12

Browse files
committed
add custom index template config option
1 parent b4f1fc8 commit f442f12

File tree

4 files changed

+7
-2
lines changed

4 files changed

+7
-2
lines changed

src/StaticBuilder.php

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -70,8 +70,11 @@ public function getIndexPage(): string
7070
$indexPage = null;
7171

7272
if ($this->siteConfig->site_index !== null) {
73+
$pageTpl = $this->siteConfig->site_index_tpl ?? 'content/single.html.twig';
7374
$page = $this->contentProvider->fetch($this->siteConfig->site_index);
74-
$indexPage = $this->getSinglePage($page);
75+
$indexPage = $this->twigServiceProvider->render($pageTpl, [
76+
'content' => $page,
77+
]);
7578
}
7679

7780
if ($indexPage === null) {

tests/Pest.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -90,6 +90,7 @@ function getCustomIndexPageApp(): App
9090
{
9191
$config = getDefaultAppConfig();
9292
$config['site_index'] = 'posts/test0';
93+
$config['site_index_tpl'] = 'content/index.html.twig';
9394

9495
$app = new App($config);
9596
$app->addService('builder', new StaticBuilder());
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
template index

tests/Unit/StaticBuilderTest.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@
4646
expect(is_file($app->builder->outputPath . '/index.html'))->toBeTrue();
4747

4848
$content = file_get_contents($app->builder->outputPath . '/index.html');
49-
expect($content)->toMatch("/template single/");
49+
expect($content)->toMatch("/template index/");
5050
});
5151

5252
test('StaticBuilder builds paginated tag pages', function () {

0 commit comments

Comments
 (0)