Skip to content

Commit

Permalink
fix(blog): improve
Browse files Browse the repository at this point in the history
  • Loading branch information
nedpals committed Apr 2, 2024
1 parent f7cbcd7 commit 9c0c12d
Show file tree
Hide file tree
Showing 6 changed files with 154 additions and 16 deletions.
74 changes: 74 additions & 0 deletions category.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,74 @@
<?php

// Redirect back to home page if there are no posts
if (!have_posts()) {
wp_redirect(home_url());
exit;
}

$next_link = previous_posts(display: false);
$prev_link = next_posts(display: false);
$paged = (get_query_var('paged')) ? get_query_var('paged') : 1;

get_header();
?>

<div class="relative devcon-default-bg min-h-screen -mt-16 pt-16 pb-24">
<div
style="background-image: url(<?php devcon_msummit2024_get_asset_url('bg_blog_1.webp') ?>)"
class="absolute inset-x-0 top-0 w-full bg-no-repeat bg-top bg-contain lg:bg-cover h-full"></div>

<div class="relative container flex flex-col items-center">
<header class="w-full pb-4">
<div class="entry-header pt-24 pb-8">
<a href="<?php echo get_permalink(get_page_by_path('/blog')) ?>" class="hover:underline text-2xl lg:text-4xl font-extrabold entry-title tracking-tight">
<span class="font-light">Mindanao Summit</span> <span class="font-extrabold">Blog</span>
</a>
</div>

<div class="pt-4 pb-8">
<h2 class="text-5xl lg:text-6xl"><?php single_cat_title() ?></h2>
</div>
</header>

<div class="w-full flex flex-wrap -mx-4 pb-8">
<?php
if (have_posts()) {
while (have_posts()) {
the_post();
?>

<div class="w-full md:w-1/2 lg:w-1/3 p-4">
<?php get_template_part('template-parts/blog/article-card', args: ['post' => $post, 'excerpt' => true]); ?>
</div>

<?php
}
}
?>
</div>

<!-- Pagination goes here -->
<div class="space-x-4">
<?php if ($paged > 1 && $next_link) { ?>
<a href="<?php echo $next_link; ?>" class="btn btn-primary is-outline">Newer Posts</a>
<?php } ?>

<?php if ($prev_link) { ?>
<a href="<?php echo $prev_link; ?>" class="btn btn-primary is-outline">More Posts</a>
<?php } ?>
</div>
</div>
</div>

<?php

if ($paged == 1) {
$sections = [ 'common/sponsors', 'landing-page/social_feed', 'common/cta' ];

foreach ( $sections as $section ) {
get_template_part( 'template-parts/' . $section );
}
}

get_footer();
59 changes: 49 additions & 10 deletions home.php
Original file line number Diff line number Diff line change
Expand Up @@ -19,20 +19,59 @@
class="absolute inset-x-0 top-0 w-full bg-no-repeat bg-top bg-contain lg:bg-cover h-full"></div>

<div class="relative container flex flex-col items-center">
<div class="entry-header w-full pt-24 pb-12">
<h1 class="text-5xl lg:text-6xl font-extrabold entry-title">Blog</h1>
</div>
<header class="w-full pb-4">
<div class="entry-header pt-24 pb-8">
<h1 class="text-5xl lg:text-6xl font-extrabold entry-title tracking-tight">
<span class="font-light">Mindanao Summit</span> <span class="font-extrabold">Blog</span>
</h1>
</div>

<?php if ($paged === 1) { ?>
<?php $categories = get_categories(); ?>
<div class="pb-8">
<div class="flex flex-wrap -mx-1">
<p class="px-1 py-2">Categories:</p>

<?php foreach ($categories as $category) { ?>
<div class="px-1 py-2">
<a href="<?php echo get_category_link($category->term_id); ?>"
class="border border-white/20 text-white/90 px-4 py-1 rounded-full hover:bg-white/10 hover:text-white/100 transition-colors">
<?php echo $category->name; ?>
</a>
</div>
<?php } ?>
</div>
</div>
<?php } ?>
</header>

<?php if (have_posts() && $paged == 1) : the_post(); ?>
<div class="w-full pb-8">
<?php get_template_part('template-parts/blog/article-card', 'horizontal', args: [
'post' => $post,
'class' => 'md:h-[30rem]'
]); ?>
</div>
<?php $featured_post = $post; ?>

<?php
if (!is_sticky($featured_post->ID)):
$featured_post_query = new WP_Query([
'tag' => 'featured',
'posts_per_page' => 1
]);

if ($featured_post_query->have_posts()):
wp_reset_postdata();
$featured_post_query->the_post();
$featured_post = $featured_post_query->post;
endif;
endif;
?>

<div class="w-full pb-8 mb-8 border-b border-white/20">
<?php get_template_part('template-parts/blog/article-card', 'horizontal', args: [
'post' => $featured_post,
'class' => 'md:h-[30rem]'
]); ?>
</div>
<?php endif ?>

<div class="flex flex-wrap -mx-4 pb-8">
<div class="w-full flex flex-wrap -mx-4 pb-8">
<?php
if (have_posts()) {
while (have_posts()) {
Expand Down
12 changes: 8 additions & 4 deletions resources/css/app.css
Original file line number Diff line number Diff line change
Expand Up @@ -583,8 +583,7 @@ body {
@apply w-3/4;
}

.section-heading:after,
.entry-header:after {
.section-heading:after {
content: "";
@apply block max-w-[24rem] lg:max-w-3xl w-full h-2 mt-10 bg-gradient-to-r from-[rgba(255,221,0,1)] via-[rgba(113,180,6,0.7813)] to-transparent;
}
Expand Down Expand Up @@ -673,9 +672,14 @@ ul.footer-menu {
}

.single.single-post .cat-links {
@apply space-x-2 pb-6;
@apply pb-6 flex flex-wrap;
}

.single.single-post .cat-links a {
@apply border border-white/40 hover:border-white/30 bg-white/20 hover:bg-white/10 transition-colors px-4 py-2 font-semibold rounded-lg;
@apply mx-1 my-1 self-start rounded-full border border-[hsl(52deg,100%,50%)] text-[hsl(52deg,100%,50%)] hover:bg-[hsl(52deg,100%,50%)] hover:text-[#18073F] transition-colors px-4 py-1;
}

.entry-header:after {
content: "";
@apply block max-w-[24rem] lg:max-w-3xl w-full h-2 mt-6 bg-gradient-to-r from-[rgba(255,221,0,1)] via-[rgba(113,180,6,0.7813)] to-transparent;
}
19 changes: 18 additions & 1 deletion single.php
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,24 @@
get_header();
?>

<main id="primary" class="relative site-main -mt-16 pt-16">
<div style="background-image: url(<?php devcon_msummit2024_get_asset_url('bg_blog_1.webp') ?>)"
class="bg-no-repeat bg-top bg-cover h-full -mt-20 pt-20">
<div class="max-w-7xl mx-auto w-full px-4 lg:px-0 pt-8 pb-4 flex justify-between">
<a href="<?php echo get_permalink(get_page_by_path('/blog')) ?>" class="hover:underline text-2xl md:text-3xl tracking-tight entry-title">
<span class="font-light">Mindanao Summit</span> <span class="font-extrabold">Blog</span>
</a>

<!-- go back to blog -->
<a href="<?php echo get_permalink(get_page_by_path('/blog')) ?>" class="hover:underline text-white/90 flex items-center">
<svg xmlns="http://www.w3.org/2000/svg" class="h-6 w-6 inline-block" fill="none" viewBox="0 0 24 24" stroke="currentColor">
<path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M10 19l-7-7m0 0l7-7m-7 7h18"/>
</svg>
<span class="pl-2">Back to Blog</span>
</a>
</div>
</div>

<main id="primary" class="relative site-main">
<div
style="background-image: url(<?php devcon_msummit2024_get_asset_url('bg-blog.png') ?>)"
class="absolute inset-x-0 top-0 w-full bg-no-repeat bg-top bg-contain h-full"></div>
Expand Down
4 changes: 4 additions & 0 deletions tag.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
<?php

// Redirect back to blog homepage
wp_redirect(home_url());
2 changes: 1 addition & 1 deletion template-parts/content.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
?>

<article id="post-<?php the_ID(); ?>" <?php post_class('min-h-screen'); ?>>
<header class="max-w-6xl w-full mx-auto px-6 py-10 lg:py-20">
<header class="container w-full mx-auto px-6 py-10 lg:py-20">
<?php
/* translators: used between list items, there is a space after the comma */
$categories_list = get_the_category_list( esc_html__( ' ', 'devcon-msummit2024' ) );
Expand Down

0 comments on commit 9c0c12d

Please sign in to comment.