Create app layout, move bookmark view into component
This commit is contained in:
parent
bd3f0e7fcd
commit
9d3fb270f6
28
app/View/Components/Bookmark.php
Normal file
28
app/View/Components/Bookmark.php
Normal 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');
|
||||
}
|
||||
}
|
@ -1,5 +1,9 @@
|
||||
@extends('layouts.app')
|
||||
|
||||
@section('content')
|
||||
|
||||
@foreach ($bookmarks as $bookmark)
|
||||
|
||||
@include('bookmarks.show')
|
||||
|
||||
<x-bookmark :bookmark="$bookmark" />
|
||||
@endforeach
|
||||
|
||||
@endsection
|
||||
|
@ -1,19 +1,5 @@
|
||||
@extends('layouts.app')
|
||||
|
||||
@section('content')
|
||||
<div class="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>
|
||||
<x-bookmark :bookmark="$bookmark" />
|
||||
@endsection
|
||||
|
19
resources/views/components/bookmark.blade.php
Normal file
19
resources/views/components/bookmark.blade.php
Normal 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>
|
@ -1,11 +1,12 @@
|
||||
<!doctype html>
|
||||
<html lang="en">
|
||||
<head>
|
||||
<title>urlslug</title>
|
||||
<title>urlsnail</title>
|
||||
@vite(['resources/sass/app.scss'])
|
||||
</head>
|
||||
<body>
|
||||
<div class="container">
|
||||
<h1>url snail</h1>
|
||||
@yield('content')
|
||||
</div>
|
||||
</body>
|
||||
|
Loading…
Reference in New Issue
Block a user