dynamic load articles
This commit is contained in:
@@ -5,7 +5,8 @@
|
|||||||
<div class="flex justify-center space-x-2 mb-6">
|
<div class="flex justify-center space-x-2 mb-6">
|
||||||
{{ with .Params.categories }}
|
{{ with .Params.categories }}
|
||||||
{{ range first 2 . }}
|
{{ range first 2 . }}
|
||||||
<span class="bg-blue-100 text-blue-800 text-sm font-medium px-3 py-1 rounded-full">{{ . }}</span>
|
<a href="/{{ . | anchorize }}"><span class="bg-blue-100 text-blue-800 text-sm font-medium px-3 py-1 rounded-full">{{ . }}</span></a>
|
||||||
|
|
||||||
{{ end }}
|
{{ end }}
|
||||||
{{ end }}
|
{{ end }}
|
||||||
</div>
|
</div>
|
||||||
|
|||||||
@@ -29,53 +29,50 @@
|
|||||||
<h2 class="text-3xl font-bold text-gray-900 mb-10 text-center">Featured Articles</h2>
|
<h2 class="text-3xl font-bold text-gray-900 mb-10 text-center">Featured Articles</h2>
|
||||||
|
|
||||||
<div class="grid grid-cols-1 lg:grid-cols-2 gap-8 mb-12">
|
<div class="grid grid-cols-1 lg:grid-cols-2 gap-8 mb-12">
|
||||||
<!-- Featured Article 1 -->
|
{{ range first 2 (where .Site.Data.wordpress.posts "status" "publish") }}
|
||||||
<div class="bg-white rounded-xl overflow-hidden shadow-lg article-card">
|
{{ $author := index .Site.Data.wordpress.authors .author }}
|
||||||
<div class="featured-article">
|
{{ $categories := slice }}
|
||||||
<img src="https://images.unsplash.com/photo-1677442135135-416f8aa26a5b?ixlib=rb-4.0.3&ixid=MnwxMjA3fDB8MHxwaG90by1wYWdlfHx8fGVufDB8fHx8&auto=format&fit=crop&w=1000&q=80" alt="AI Technology" class="w-full h-64 object-cover">
|
{{ range .categories }}
|
||||||
</div>
|
{{ $categoryID := . }}
|
||||||
<div class="p-6">
|
{{ range $.Site.Data.wordpress.categories }}
|
||||||
<div class="flex flex-wrap gap-2 mb-4">
|
{{ if eq .id $categoryID }}
|
||||||
<span class="bg-blue-100 text-blue-800 text-xs font-medium px-2 py-1 rounded">AI</span>
|
{{ $categories = $categories | append .name }}
|
||||||
<span class="bg-green-100 text-green-800 text-xs font-medium px-2 py-1 rounded">Future of Work</span>
|
{{ end }}
|
||||||
</div>
|
{{ end }}
|
||||||
<h3 class="text-xl font-bold text-gray-900 mb-3">How Tech Shapes the Future of Work in 2024</h3>
|
{{ end }}
|
||||||
<p class="text-gray-600 mb-4">Exploring the latest technological advancements and their impact on the modern workplace, from AI to remote collaboration tools.</p>
|
|
||||||
<div class="flex items-center justify-between">
|
|
||||||
<div class="flex items-center text-sm text-gray-500">
|
|
||||||
<img src="https://i.pravatar.cc/24?img=5" alt="Author" class="rounded-full mr-2">
|
|
||||||
<span>Sarah Johnson</span>
|
|
||||||
<span class="mx-2">•</span>
|
|
||||||
<span>Oct 16, 2024</span>
|
|
||||||
</div>
|
|
||||||
<a href="#" class="text-blue-600 hover:text-blue-800 font-medium text-sm">Read more →</a>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
|
|
||||||
<!-- Featured Article 2 -->
|
|
||||||
<div class="bg-white rounded-xl overflow-hidden shadow-lg article-card">
|
<div class="bg-white rounded-xl overflow-hidden shadow-lg article-card">
|
||||||
<div class="featured-article">
|
<div class="featured-article">
|
||||||
<img src="https://images.unsplash.com/photo-1581092580497-e0d23cbdf1dc?ixlib=rb-4.0.3&ixid=MnwxMjA3fDB8MHxwaG90by1wYWdlfHx8fGVufDB8fHx8&auto=format&fit=crop&w=1000&q=80" alt="AI Ethics" class="w-full h-64 object-cover">
|
{{ if .featured_image }}
|
||||||
|
<img src="{{ .featured_image }}" alt="{{ .title.rendered | plainify }}" class="w-full h-64 object-cover">
|
||||||
|
{{ else }}
|
||||||
|
<img src="/assets/images/col-1.jpg" alt="{{ .title.rendered | plainify }}" class="w-full h-64 object-cover">
|
||||||
|
{{ end }}
|
||||||
</div>
|
</div>
|
||||||
<div class="p-6">
|
<div class="p-6">
|
||||||
<div class="flex flex-wrap gap-2 mb-4">
|
<div class="flex flex-wrap gap-2 mb-4">
|
||||||
<span class="bg-purple-100 text-purple-800 text-xs font-medium px-2 py-1 rounded">AI</span>
|
{{ range first 2 $categories }}
|
||||||
<span class="bg-red-100 text-red-800 text-xs font-medium px-2 py-1 rounded">Ethics</span>
|
<span class="bg-blue-100 text-blue-800 text-xs font-medium px-2 py-1 rounded">{{ . }}</span>
|
||||||
|
{{ end }}
|
||||||
</div>
|
</div>
|
||||||
<h3 class="text-xl font-bold text-gray-900 mb-3">The Ethics of Artificial Intelligence in Hiring</h3>
|
<h3 class="text-xl font-bold text-gray-900 mb-3">{{ .title.rendered | plainify }}</h3>
|
||||||
<p class="text-gray-600 mb-4">Exploring the benefits and potential pitfalls of using AI to recruit and evaluate candidates in the modern workplace.</p>
|
<p class="text-gray-600 mb-4">{{ .excerpt.rendered | plainify | truncate 150 }}</p>
|
||||||
<div class="flex items-center justify-between">
|
<div class="flex items-center justify-between">
|
||||||
<div class="flex items-center text-sm text-gray-500">
|
<div class="flex items-center text-sm text-gray-500">
|
||||||
<img src="https://i.pravatar.cc/24?img=8" alt="Author" class="rounded-full mr-2">
|
{{ if $author.avatar_url }}
|
||||||
<span>Michael Chen</span>
|
<img src="{{ $author.avatar_url }}" alt="{{ $author.name }}" class="w-6 h-6 rounded-full mr-2">
|
||||||
|
{{ else }}
|
||||||
|
<img src="https://i.pravatar.cc/24" alt="{{ $author.name }}" class="w-6 h-6 rounded-full mr-2">
|
||||||
|
{{ end }}
|
||||||
|
<span>{{ $author.name }}</span>
|
||||||
<span class="mx-2">•</span>
|
<span class="mx-2">•</span>
|
||||||
<span>Sep 3, 2024</span>
|
<span>{{ .date | time.Format "Jan 2, 2006" }}</span>
|
||||||
</div>
|
</div>
|
||||||
<a href="#" class="text-blue-600 hover:text-blue-800 font-medium text-sm">Read more →</a>
|
<a href="{{ .link }}" class="text-blue-600 hover:text-blue-800 font-medium text-sm">Read more →</a>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
{{ end }}
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div class="text-center">
|
<div class="text-center">
|
||||||
@@ -93,54 +90,46 @@
|
|||||||
<h2 class="text-3xl font-bold text-gray-900 mb-10 text-center">Latest Articles</h2>
|
<h2 class="text-3xl font-bold text-gray-900 mb-10 text-center">Latest Articles</h2>
|
||||||
|
|
||||||
<div class="grid grid-cols-1 md:grid-cols-2 lg:grid-cols-3 gap-8 mb-12">
|
<div class="grid grid-cols-1 md:grid-cols-2 lg:grid-cols-3 gap-8 mb-12">
|
||||||
<!-- Article 1 -->
|
{{ range first 6 (after 2 (where .Site.Data.wordpress.posts "status" "publish")) }}
|
||||||
|
{{ $author := index .Site.Data.wordpress.authors .author }}
|
||||||
|
{{ $categories := slice }}
|
||||||
|
{{ range .categories }}
|
||||||
|
{{ $categoryID := . }}
|
||||||
|
{{ range $.Site.Data.wordpress.categories }}
|
||||||
|
{{ if eq .id $categoryID }}
|
||||||
|
{{ $categories = $categories | append .name }}
|
||||||
|
{{ end }}
|
||||||
|
{{ end }}
|
||||||
|
{{ end }}
|
||||||
|
|
||||||
<div class="bg-white rounded-xl overflow-hidden shadow-md article-card">
|
<div class="bg-white rounded-xl overflow-hidden shadow-md article-card">
|
||||||
<img src="https://images.unsplash.com/photo-1581091226033-d5c48150dbaa?ixlib=rb-4.0.3&ixid=MnwxMjA3fDB8MHxwaG90by1wYWdlfHx8fGVufDB8fHx8&auto=format&fit=crop&w=1000&q=80" alt="Productivity" class="w-full h-48 object-cover">
|
{{ if .featured_image }}
|
||||||
|
<img src="{{ .featured_image }}" alt="{{ .title.rendered | plainify }}" class="w-full h-48 object-cover">
|
||||||
|
{{ else }}
|
||||||
|
<img src="/assets/images/col-1.jpg" alt="{{ .title.rendered | plainify }}" class="w-full h-48 object-cover">
|
||||||
|
{{ end }}
|
||||||
<div class="p-6">
|
<div class="p-6">
|
||||||
<div class="flex flex-wrap gap-2 mb-3">
|
<div class="flex flex-wrap gap-2 mb-3">
|
||||||
<span class="bg-blue-100 text-blue-800 text-xs font-medium px-2 py-1 rounded">Productivity</span>
|
{{ range first 1 $categories }}
|
||||||
|
<span class="bg-blue-100 text-blue-800 text-xs font-medium px-2 py-1 rounded">{{ . }}</span>
|
||||||
|
{{ end }}
|
||||||
</div>
|
</div>
|
||||||
<h3 class="text-lg font-bold text-gray-900 mb-3">10 Tools to Boost Your Productivity in 2024</h3>
|
<h3 class="text-lg font-bold text-gray-900 mb-3">{{ .title.rendered | plainify }}</h3>
|
||||||
<p class="text-gray-600 text-sm mb-4">Discover the latest apps and software that can help you work smarter, not harder.</p>
|
<p class="text-gray-600 text-sm mb-4">{{ .excerpt.rendered | plainify | truncate 100 }}</p>
|
||||||
<div class="flex items-center justify-between text-sm text-gray-500">
|
<div class="flex items-center justify-between text-sm text-gray-500">
|
||||||
<span>May 12, 2024</span>
|
<span>{{ .date | time.Format "Jan 2, 2006" }}</span>
|
||||||
<span>5 min read</span>
|
<span>{{ .reading_time | default "5" }} min read</span>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
{{ end }}
|
||||||
|
</div>
|
||||||
|
|
||||||
<!-- Article 2 -->
|
<div class="text-center">
|
||||||
<div class="bg-white rounded-xl overflow-hidden shadow-md article-card">
|
<a href="/articles" class="inline-flex items-center text-blue-600 hover:text-blue-800 font-medium">
|
||||||
<img src="https://images.unsplash.com/photo-1533750349088-cd871a92f312?ixlib=rb-4.0.3&ixid=MnwxMjA3fDB8MHxwaG90by1wYWdlfHx8fGVufDB8fHx8&auto=format&fit=crop&w=1000&q=80" alt="Remote Work" class="w-full h-48 object-cover">
|
View all articles
|
||||||
<div class="p-6">
|
<i class="fas fa-arrow-right ml-2"></i>
|
||||||
<div class="flex flex-wrap gap-2 mb-3">
|
</a>
|
||||||
<span class="bg-green-100 text-green-800 text-xs font-medium px-2 py-1 rounded">Remote Work</span>
|
|
||||||
</div>
|
|
||||||
<h3 class="text-lg font-bold text-gray-900 mb-3">Building Company Culture in a Remote World</h3>
|
|
||||||
<p class="text-gray-600 text-sm mb-4">How forward-thinking companies are maintaining strong cultures with distributed teams.</p>
|
|
||||||
<div class="flex items-center justify-between text-sm text-gray-500">
|
|
||||||
<span>July 24, 2024</span>
|
|
||||||
<span>7 min read</span>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
|
|
||||||
<!-- Article 3 -->
|
|
||||||
<div class="bg-white rounded-xl overflow-hidden shadow-md article-card">
|
|
||||||
<img src="https://images.unsplash.com/photo-1552664730-d307ca884978?ixlib=rb-4.0.3&ixid=MnwxMjA3fDB8MHxwaG90by1wYWdlfHx8fGVufDB8fHx8&auto=format&fit=crop&w=1000&q=80" alt="Web3" class="w-full h-48 object-cover">
|
|
||||||
<div class="p-6">
|
|
||||||
<div class="flex flex-wrap gap-2 mb-3">
|
|
||||||
<span class="bg-purple-100 text-purple-800 text-xs font-medium px-2 py-1 rounded">Web3</span>
|
|
||||||
<span class="bg-yellow-100 text-yellow-800 text-xs font-medium px-2 py-1 rounded">Blockchain</span>
|
|
||||||
</div>
|
|
||||||
<h3 class="text-lg font-bold text-gray-900 mb-3">Understanding Web3: The Next Evolution of the Internet</h3>
|
|
||||||
<p class="text-gray-600 text-sm mb-4">What businesses need to know about the decentralized web and its potential impact.</p>
|
|
||||||
<div class="flex items-center justify-between text-sm text-gray-500">
|
|
||||||
<span>Aug 5, 2024</span>
|
|
||||||
<span>9 min read</span>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</section>
|
</section>
|
||||||
|
|||||||
Reference in New Issue
Block a user