Skip to content

Commit

Permalink
Merge pull request #95 from musimana/feature/AddBlocksToHomepage
Browse files Browse the repository at this point in the history
feat: Add AppBlocks to the Homepage
  • Loading branch information
musimana authored Jun 2, 2024
2 parents 6a99201 + 52ddf73 commit b623d68
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

namespace App\Http\Resources\Views\Public\Content;

use App\Http\Resources\Views\Public\Blocks\BlocksResource;
use App\Http\Resources\Views\Public\Summaries\PageSummaryResource;
use App\Interfaces\Resources\Items\ConstantItemInterface;
use App\Models\Page;
Expand All @@ -19,6 +20,7 @@ public function getItem(): array
$items = Page::query()->isNotHomepage()->whereNot('slug', 'about')->get();

return [
'blocks' => $page?->blocks ? (new BlocksResource)->getItems($page->blocks) : [],
'bodytext' => $page?->getContent() ?? '',
'heading' => $page?->getTitle() ?? config('app.name'),
'items' => $items
Expand Down
6 changes: 6 additions & 0 deletions resources/js/Pages/Public/Partials/ContentHomepage.vue
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
<script setup>
import AppBlocks from '@/Components/Blocks/AppBlocks.vue'
import AppSectionDivider from '@/Components/Sections/AppSectionDivider.vue'
import AppSectionHtml from '@/Components/Sections/AppSectionHtml.vue'
import BlockIndexPanels from '@/Components/Blocks/BlockIndexPanels.vue'
Expand All @@ -14,7 +15,12 @@ import BlockIndexPanels from '@/Components/Blocks/BlockIndexPanels.vue'
/>

<BlockIndexPanels
v-if="$page.props.content?.items.length"
:items="$page.props.content.items ?? []"
title="Features"
/>

<AppBlocks
v-if="$page.props.content.blocks ?? []"
/>
</template>
Original file line number Diff line number Diff line change
Expand Up @@ -14,14 +14,19 @@
test('getItem returns ok without a Page Model', function () {
$actual = (new HomepageContentResource)->getItem();

expect($actual['blocks'])
->toBeArray()
->toBeEmpty();

expect($actual['items'])
->toBeArray()
->toBeEmpty();

expect($actual)
->toHaveCamelCaseKeys()
->toHaveCount(4)
->toHaveCount(5)
->toMatchArray([
'blocks' => [],
'bodytext' => '',
'heading' => config('app.name'),
'items' => [],
Expand All @@ -38,14 +43,19 @@

$actual = (new HomepageContentResource)->getItem();

expect($actual['blocks'])
->toBeArray()
->toBeEmpty();

expect($actual['items'])
->toBeArray()
->toBeEmpty();

expect($actual)
->toHaveCamelCaseKeys()
->toHaveCount(4)
->toHaveCount(5)
->toMatchArray([
'blocks' => [],
'bodytext' => $page->content,
'heading' => $page->title,
'items' => [],
Expand Down

0 comments on commit b623d68

Please sign in to comment.