feat(frontend): enable Livewire SPA navigation (wire:navigate)
This commit is contained in:
@@ -1,31 +1,31 @@
|
||||
<header class="site-header">
|
||||
<div class="container">
|
||||
<div class="site-brand">
|
||||
<a href="{{ route('home') }}" class="site-title">{{ $siteName }}</a>
|
||||
<a wire:navigate href="{{ route('home') }}" class="site-title">{{ $siteName }}</a>
|
||||
@if($siteDescription)
|
||||
<p class="site-desc">{{ $siteDescription }}</p>
|
||||
@endif
|
||||
</div>
|
||||
<nav class="site-nav">
|
||||
<a href="{{ route('home') }}" class="{{ request()->routeIs('home') ? 'active' : '' }}">首页</a>
|
||||
<a href="{{ route('archives') }}" class="{{ request()->routeIs('archives*') ? 'active' : '' }}">归档</a>
|
||||
<a href="{{ route('tags') }}" class="{{ request()->routeIs('tags*') ? 'active' : '' }}">标签</a>
|
||||
<a href="{{ route('links') }}" class="{{ request()->routeIs('links') ? 'active' : '' }}">友链</a>
|
||||
<a href="{{ route('comments') }}" class="{{ request()->routeIs('comments') ? 'active' : '' }}">评论</a>
|
||||
<a wire:navigate href="{{ route('home') }}" class="{{ request()->routeIs('home') ? 'active' : '' }}">首页</a>
|
||||
<a wire:navigate href="{{ route('archives') }}" class="{{ request()->routeIs('archives*') ? 'active' : '' }}">归档</a>
|
||||
<a wire:navigate href="{{ route('tags') }}" class="{{ request()->routeIs('tags*') ? 'active' : '' }}">标签</a>
|
||||
<a wire:navigate href="{{ route('links') }}" class="{{ request()->routeIs('links') ? 'active' : '' }}">友链</a>
|
||||
<a wire:navigate href="{{ route('comments') }}" class="{{ request()->routeIs('comments') ? 'active' : '' }}">评论</a>
|
||||
@include('partials.feed-links')
|
||||
<form class="site-search" action="{{ route('search') }}" method="get">
|
||||
<input type="search" name="q" placeholder="搜索..." value="{{ request('q', request('keyword', '')) }}">
|
||||
</form>
|
||||
@auth
|
||||
<a href="{{ route('profile') }}">{{ auth()->user()->name }}</a>
|
||||
<a wire:navigate href="{{ route('profile') }}">{{ auth()->user()->name }}</a>
|
||||
@include('partials.admin-link')
|
||||
<form action="{{ route('logout') }}" method="post" class="inline-form">
|
||||
@csrf
|
||||
<button type="submit" class="link-btn">退出</button>
|
||||
</form>
|
||||
@else
|
||||
<a href="{{ route('login') }}">登录</a>
|
||||
<a href="{{ route('register') }}">注册</a>
|
||||
<a wire:navigate href="{{ route('login') }}">登录</a>
|
||||
<a wire:navigate href="{{ route('register') }}">注册</a>
|
||||
@endauth
|
||||
</nav>
|
||||
</div>
|
||||
|
||||
@@ -5,7 +5,7 @@
|
||||
@if ($paginator->onFirstPage())
|
||||
<span class="disabled">«</span>
|
||||
@else
|
||||
<a href="{{ $paginator->previousPageUrl() }}" rel="prev">«</a>
|
||||
<a wire:navigate href="{{ $paginator->previousPageUrl() }}" rel="prev">«</a>
|
||||
@endif
|
||||
|
||||
@foreach ($elements as $element)
|
||||
@@ -17,14 +17,14 @@
|
||||
@if ($page == $paginator->currentPage())
|
||||
<span class="current">{{ $page }}</span>
|
||||
@else
|
||||
<a href="{{ $url }}">{{ $page }}</a>
|
||||
<a wire:navigate href="{{ $url }}">{{ $page }}</a>
|
||||
@endif
|
||||
@endforeach
|
||||
@endif
|
||||
@endforeach
|
||||
|
||||
@if ($paginator->hasMorePages())
|
||||
<a href="{{ $paginator->nextPageUrl() }}" rel="next">»</a>
|
||||
<a wire:navigate href="{{ $paginator->nextPageUrl() }}" rel="next">»</a>
|
||||
@else
|
||||
<span class="disabled">»</span>
|
||||
@endif
|
||||
|
||||
@@ -6,19 +6,19 @@
|
||||
@endphp
|
||||
<article class="post-card {{ $post->isPinned() ? 'sticky' : '' }} post-card-{{ $viewMode }}">
|
||||
@if($url = $post->coverImageUrl())
|
||||
<a href="{{ route('posts.show', $post->id) }}" class="post-cover">
|
||||
<a wire:navigate href="{{ route('posts.show', $post->id) }}" class="post-cover">
|
||||
<img src="{{ $url }}" alt="{{ $post->title }}" loading="lazy">
|
||||
</a>
|
||||
@endif
|
||||
<h2 class="post-title">
|
||||
@if($label = $post->stickyLabel())<span class="badge">{{ $label }}</span>@endif
|
||||
<a href="{{ route('posts.show', $post->id) }}">{{ $post->title }}</a>
|
||||
<a wire:navigate href="{{ route('posts.show', $post->id) }}">{{ $post->title }}</a>
|
||||
</h2>
|
||||
<div class="post-meta">
|
||||
<time datetime="{{ $post->published_at->toIso8601String() }}">{{ $post->published_at->format(blog_setting('normaltime', 'Y-m-d H:i')) }}</time>
|
||||
@if($post->category)
|
||||
<span>·</span>
|
||||
<a href="{{ route('category.show', $post->category->id) }}">{{ $post->category->name }}</a>
|
||||
<a wire:navigate href="{{ route('category.show', $post->category->id) }}">{{ $post->category->name }}</a>
|
||||
@endif
|
||||
<span>· 阅读 {{ $post->views }}</span>
|
||||
<span>· 评论 {{ $post->comment_count }}</span>
|
||||
@@ -33,9 +33,9 @@
|
||||
</div>
|
||||
@endif
|
||||
<div class="post-footer">
|
||||
<a href="{{ route('posts.show', $post->id) }}" class="read-more">阅读全文 »</a>
|
||||
<a wire:navigate href="{{ route('posts.show', $post->id) }}" class="read-more">阅读全文 »</a>
|
||||
@foreach($post->tags as $tag)
|
||||
<a href="{{ route('tags.show', $tag->name) }}" class="tag-link">#{{ $tag->name }}</a>
|
||||
<a wire:navigate href="{{ route('tags.show', $tag->name) }}" class="tag-link">#{{ $tag->name }}</a>
|
||||
@endforeach
|
||||
</div>
|
||||
</article>
|
||||
|
||||
@@ -5,7 +5,7 @@
|
||||
<ul class="widget-list">
|
||||
@forelse($categories as $category)
|
||||
<li>
|
||||
<a href="{{ route('category.show', $category->id) }}">{{ $category->name }}</a>
|
||||
<a wire:navigate href="{{ route('category.show', $category->id) }}">{{ $category->name }}</a>
|
||||
<span class="count">({{ $category->post_count }})</span>
|
||||
</li>
|
||||
@empty
|
||||
@@ -18,7 +18,7 @@
|
||||
<h3 class="widget-title">最新文章</h3>
|
||||
<ul class="widget-list">
|
||||
@forelse($recentPosts as $post)
|
||||
<li><a href="{{ route('posts.show', $post->id) }}">{{ $post->title }}</a></li>
|
||||
<li><a wire:navigate href="{{ route('posts.show', $post->id) }}">{{ $post->title }}</a></li>
|
||||
@empty
|
||||
<li>暂无文章</li>
|
||||
@endforelse
|
||||
@@ -30,7 +30,7 @@
|
||||
<ul class="widget-list">
|
||||
@forelse($recentComments as $comment)
|
||||
<li>
|
||||
<a href="{{ route('posts.show', $comment->post->id) }}#comment-{{ $comment->id }}">
|
||||
<a wire:navigate href="{{ route('posts.show', $comment->post->id) }}#comment-{{ $comment->id }}">
|
||||
{{ $comment->author_name }}:{{ Str::limit(strip_tags($comment->content), 30) }}
|
||||
</a>
|
||||
</li>
|
||||
@@ -44,7 +44,7 @@
|
||||
<h3 class="widget-title">标签云</h3>
|
||||
<div class="tag-cloud">
|
||||
@forelse($hotTags as $tag)
|
||||
<a href="{{ route('tags.show', $tag->name) }}" class="tag-link">{{ $tag->name }}</a>
|
||||
<a wire:navigate href="{{ route('tags.show', $tag->name) }}" class="tag-link">{{ $tag->name }}</a>
|
||||
@empty
|
||||
<span>暂无标签</span>
|
||||
@endforelse
|
||||
|
||||
Reference in New Issue
Block a user