Create app layout, move bookmark view into component

This commit is contained in:
Annika Backstrom 2024-05-25 14:59:27 +01:00
parent bd3f0e7fcd
commit 9d3fb270f6
Signed by: annika
GPG Key ID: 3561F004DE1D9AFE
5 changed files with 57 additions and 19 deletions

View File

@ -0,0 +1,28 @@
<?php
namespace App\View\Components;
use App\Models\Bookmark as ModelsBookmark;
use Closure;
use Illuminate\Contracts\View\View;
use Illuminate\View\Component;
class Bookmark extends Component
{
/**
* Create a new component instance.
*/
public function __construct(
public ModelsBookmark $bookmark
) {
//
}
/**
* Get the view / contents that represent the component.
*/
public function render(): View|Closure|string
{
return view('components.bookmark');
}
}

View File

@ -1,5 +1,9 @@
@extends('layouts.app')
@section('content')
@foreach ($bookmarks as $bookmark) @foreach ($bookmarks as $bookmark)
<x-bookmark :bookmark="$bookmark" />
@include('bookmarks.show')
@endforeach @endforeach
@endsection

View File

@ -1,19 +1,5 @@
@extends('layouts.app') @extends('layouts.app')
@section('content') @section('content')
<div class="bookmark"> <x-bookmark :bookmark="$bookmark" />
<p class="bookmark-title">{{ $bookmark->title }}</p>
<p class="bookmark-href"><a href="{{ $bookmark->href }}">{{ $bookmark->href }}</a></p>
@if ($bookmark->description)
<p class="bookmark-description">{{ $bookmark->description }}</p>
@endif
<p>{{ $bookmark->created_at }}</p>
<ul class="bookmark-tags">
@foreach ($bookmark->tags as $tag)
<li class="bookmark-tag">
{{ $tag->tag->name }}
</li>
@endforeach
</ul>
</div>
@endsection @endsection

View File

@ -0,0 +1,19 @@
<div class="bookmark">
<p class="bookmark-title">{{ $bookmark->title }}</p>
<p class="bookmark-href"><a href="{{ $bookmark->href }}">{{ $bookmark->href }}</a></p>
@if (!empty($bookmark->description))
<div class="bookmark-description">
<p>{{ strip_tags($bookmark->description) }}</p>
</div>
@endif
<p class="bookmark-date">
<time datetime="{{ $bookmark->created_at }}">{{ $bookmark->created_at->diffForHumans() }}</time>
</p>
<ul class="bookmark-tags">
@foreach ($bookmark->tags as $tag)
<li class="bookmark-tag">
{{ $tag->tag->name }}
</li>
@endforeach
</ul>
</div>

View File

@ -1,11 +1,12 @@
<!doctype html> <!doctype html>
<html lang="en"> <html lang="en">
<head> <head>
<title>urlslug</title> <title>urlsnail</title>
@vite(['resources/sass/app.scss']) @vite(['resources/sass/app.scss'])
</head> </head>
<body> <body>
<div class="container"> <div class="container">
<h1>url snail</h1>
@yield('content') @yield('content')
</div> </div>
</body> </body>