Skip to content

Commit

Permalink
feat: add initial impl of blog post page
Browse files Browse the repository at this point in the history
  • Loading branch information
nedpals committed Mar 31, 2024
1 parent ff701d7 commit ac80980
Show file tree
Hide file tree
Showing 17 changed files with 492 additions and 79 deletions.
Empty file added comments.php
Empty file.
2 changes: 1 addition & 1 deletion home.php
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@

$page_sections = [
'upper' => ['overview', 'preevents'],
'lower' => ['agenda', 'speakers', 'tickets', 'testimonials', 'sponsors-cta', 'faqs', 'countdown', 'social_feed', 'sponsors', 'cta']
'lower' => ['agenda', 'speakers', 'tickets', 'testimonials', 'sponsors-cta', 'faqs', 'countdown', 'social_feed', 'sponsors', 'common/cta']
];
?>

Expand Down
88 changes: 33 additions & 55 deletions inc/template-tags.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,27 +11,27 @@
/**
* Prints HTML with meta information for the current post-date/time.
*/
function devcon_msummit2024_posted_on() {
function devcon_msummit2024_posted_on($class_name = '', bool $link = true, WP_Post|null $post = null) {
$time_string = '<time class="entry-date published updated" datetime="%1$s">%2$s</time>';
if ( get_the_time( 'U' ) !== get_the_modified_time( 'U' ) ) {
$time_string = '<time class="entry-date published" datetime="%1$s">%2$s</time><time class="updated" datetime="%3$s">%4$s</time>';
}

$time_string = sprintf(
$time_string,
esc_attr( get_the_date( DATE_W3C ) ),
esc_html( get_the_date() ),
esc_attr( get_the_modified_date( DATE_W3C ) ),
esc_html( get_the_modified_date() )
esc_attr( get_the_date( DATE_W3C , $post) ),
esc_html( get_the_date(post: $post) ),
esc_attr( get_the_modified_date( DATE_W3C , $post) ),
esc_html( get_the_modified_date(post: $post) )
);

$posted_on = sprintf(
/* translators: %s: post date. */
esc_html_x( 'Posted on %s', 'post date', 'devcon-msummit2024' ),
'<a href="' . esc_url( get_permalink() ) . '" rel="bookmark">' . $time_string . '</a>'
esc_html_x( '%s', 'post date', 'devcon-msummit2024' ),
$link ? '<a href="' . esc_url( get_permalink($post) ) . '" rel="bookmark">' . $time_string . '</a>' : $time_string
);

echo '<span class="posted-on">' . $posted_on . '</span>'; // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped
echo '<span class="posted-on '.$class_name.'">' . $posted_on . '</span>'; // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped

}
endif;
Expand All @@ -40,14 +40,17 @@ function devcon_msummit2024_posted_on() {
/**
* Prints HTML with meta information for the current author.
*/
function devcon_msummit2024_posted_by() {
$byline = sprintf(
function devcon_msummit2024_posted_by($class_name = '', bool $link = true, WP_Post|null $post = null) {
$author_meta = esc_html(get_the_author_meta( 'display_name', $post ? $post->post_author : get_the_author_meta( 'ID' ) ));
$pby_string = $link ? '<a class="url fn n" href="' . esc_url( get_author_posts_url($post ? $post->post_author : get_the_author_meta( 'ID' ) ) ) . '">' . $author_meta . '</a>' : $author_meta;

$byline = sprintf(
/* translators: %s: post author. */
esc_html_x( 'by %s', 'post author', 'devcon-msummit2024' ),
'<span class="author vcard"><a class="url fn n" href="' . esc_url( get_author_posts_url( get_the_author_meta( 'ID' ) ) ) . '">' . esc_html( get_the_author() ) . '</a></span>'
esc_html_x( '%s', 'post author', 'devcon-msummit2024' ),
'<span class="author vcard">'.$pby_string.'</span>'
);

echo '<span class="byline"> ' . $byline . '</span>'; // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped
echo '<span class="byline '.$class_name.'"> ' . $byline . '</span>'; // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped

}
endif;
Expand All @@ -59,12 +62,6 @@ function devcon_msummit2024_posted_by() {
function devcon_msummit2024_entry_footer() {
// Hide category and tag text for pages.
if ( 'post' === get_post_type() ) {
/* translators: used between list items, there is a space after the comma */
$categories_list = get_the_category_list( esc_html__( ', ', 'devcon-msummit2024' ) );
if ( $categories_list ) {
/* translators: 1: list of categories. */
printf( '<span class="cat-links">' . esc_html__( 'Posted in %1$s', 'devcon-msummit2024' ) . '</span>', $categories_list ); // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped
}

/* translators: used between list items, there is a space after the comma */
$tags_list = get_the_tag_list( '', esc_html_x( ', ', 'list item separator', 'devcon-msummit2024' ) );
Expand All @@ -73,42 +70,23 @@ function devcon_msummit2024_entry_footer() {
printf( '<span class="tags-links">' . esc_html__( 'Tagged %1$s', 'devcon-msummit2024' ) . '</span>', $tags_list ); // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped
}
}

if ( ! is_single() && ! post_password_required() && ( comments_open() || get_comments_number() ) ) {
echo '<span class="comments-link">';
comments_popup_link(
sprintf(
wp_kses(
/* translators: %s: post title */
__( 'Leave a Comment<span class="screen-reader-text"> on %s</span>', 'devcon-msummit2024' ),
array(
'span' => array(
'class' => array(),
),
)
),
wp_kses_post( get_the_title() )
)
);
echo '</span>';
}

edit_post_link(
sprintf(
wp_kses(
/* translators: %s: Name of current post. Only visible to screen readers */
__( 'Edit <span class="screen-reader-text">%s</span>', 'devcon-msummit2024' ),
array(
'span' => array(
'class' => array(),
),
)
),
wp_kses_post( get_the_title() )
),
'<span class="edit-link">',
'</span>'
);
//
// edit_post_link(
// sprintf(
// wp_kses(
// /* translators: %s: Name of current post. Only visible to screen readers */
// __( 'Edit <span class="screen-reader-text">%s</span>', 'devcon-msummit2024' ),
// array(
// 'span' => array(
// 'class' => array(),
// ),
// )
// ),
// wp_kses_post( get_the_title() )
// ),
// '<span class="edit-link">',
// '</span>'
// );
}
endif;

Expand Down
Binary file added resources/assets/bg_related.webp
Binary file not shown.
10 changes: 9 additions & 1 deletion resources/css/app.css
Original file line number Diff line number Diff line change
Expand Up @@ -670,4 +670,12 @@ ul.footer-menu {
.btn.btn-white:hover {
@apply bg-gray-200;
}
}
}

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

.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;
}
Empty file added sidebar.php
Empty file.
35 changes: 13 additions & 22 deletions single.php
Original file line number Diff line number Diff line change
Expand Up @@ -10,28 +10,19 @@
get_header();
?>

<main id="primary" class="site-main">

<?php
while ( have_posts() ) :
the_post();

get_template_part( 'template-parts/content', get_post_type() );

the_post_navigation(
array(
'prev_text' => '<span class="nav-subtitle">' . esc_html__( 'Previous:', 'devcon-msummit2024' ) . '</span> <span class="nav-title">%title</span>',
'next_text' => '<span class="nav-subtitle">' . esc_html__( 'Next:', 'devcon-msummit2024' ) . '</span> <span class="nav-title">%title</span>',
)
);

// If comments are open or we have at least one comment, load up the comment template.
if ( comments_open() || get_comments_number() ) :
comments_template();
endif;

endwhile; // End of the loop.
?>
<main id="primary" class="relative site-main -mt-16 pt-16">
<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>

<div class="relative">
<?php
while ( have_posts() ) :
the_post();
get_template_part( 'template-parts/content', get_post_type() );
endwhile; // End of the loop.
?>
</div>

</main><!-- #main -->

Expand Down
78 changes: 78 additions & 0 deletions template-parts/blog/related.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,78 @@
<?php
$posts = yarpp_get_related(['limit' => 3, 'post_type' => ['post']]);

if (!$posts) {
return;
}
?>
<div class="relative devcon-default-bg">
<div style="background-image: url(<?php devcon_msummit2024_get_asset_url('bg_related.webp') ?>)"
class="absolute top-0 inset-x-0 bg-no-repeat bg-cover h-full w-full"></div>

<div class="relative py-24">
<div class="relative">
<div class="relative section-heading">
<h2 class="w-full lg:w-3/4">Related Articles</h2>
</div>

<div class="absolute top-0 inset-x-0 max-w-[82rem] w-full mx-auto flex items-start justify-end">
<img class="h-auto" src="<?php devcon_msummit2024_get_asset_url('dots_right.png') ?>" />
</div>
</div>

<div class="relative container flex flex-col">
<div class="absolute top-0 inset-x-0 h-full flex items-end">
<img src="<?php devcon_msummit2024_get_asset_url('dots_left.png') ?>" />
</div>

<div class="relative flex flex-wrap items-stretch pt-8 -mx-4">
<?php foreach ($posts as $post) { ?>
<div class="w-full md:w-1/3 p-4">
<a href="<?php the_permalink($post); ?>"
rel="bookmark norewrite"
title="<?php the_title_attribute(['post' => $post]); ?>"
class="flex flex-col h-full shadow-lg transition-transform scale-100 hover:scale-[1.05]">

<div class="relative">
<?php $category = get_the_category($post->ID) ?>
<?php $thumbnail_url = get_the_post_thumbnail_url(); ?>

<!-- TODO: add placeholder -->
<div class="pb-[calc(9/16*100%)] bg-black rounded-t-xl bg-cover bg-no-repeat"
style="background-image: url(<?php echo $thumbnail_url ?>)">
<?php if (!empty($category)) { ?>
<div class="uppercase font-bold relative bg-gradient-to-r from-[hsl(52deg,100%,50%)] to-transparent text-black rounded-t-xl px-6 py-2">
<?php echo $category[0]->name ?>
</div>
<?php } ?>
</div>
</div>

<div class="h-full rounded-b-xl px-0.5 pb-0.5 bg-gradient-to-b from-transparent to-[hsl(52deg,100%,50%)]">
<div class="h-full flex flex-col w-full p-6 rounded-b-xl bg-[#18073F]">
<h3 class="text-xl w-full uppercase font-bold pb-3"><?php echo get_the_title($post); ?></h3>

<div class="pt-4 pb-8 text-sm text-white/70 w-full border-t border-white/20">
<?php devcon_msummit2024_posted_on('pr-2 border-r border-white/70', false, $post); ?>
<?php devcon_msummit2024_posted_by('pl-2', false, $post); ?>
</div>

<div class="px-4 btn btn-primary mt-auto flex items-center justify-between">
<span>Read More</span>
<svg width="25" height="22" viewBox="0 0 25 22" fill="none" xmlns="http://www.w3.org/2000/svg">
<path d="M20.5493 12.0582H1.31329C1.0388 12.0582 0.775552 11.943 0.581457 11.7378C0.387362 11.5327 0.27832 11.2545 0.27832 10.9644C0.27832 10.6744 0.387362 10.3962 0.581457 10.191C0.775552 9.98592 1.0388 9.87069 1.31329 9.87069H20.5493L13.0002 1.89507C12.8059 1.68969 12.6967 1.41114 12.6967 1.12069C12.6967 0.830242 12.8059 0.551691 13.0002 0.346313C13.1946 0.140938 13.4581 0.0255585 13.733 0.0255585C14.0078 0.0255585 14.2714 0.140938 14.4657 0.346313L23.7805 10.1901C23.8769 10.2917 23.9533 10.4124 24.0055 10.5452C24.0577 10.6781 24.0846 10.8206 24.0846 10.9644C24.0846 11.1083 24.0577 11.2508 24.0055 11.3836C23.9533 11.5165 23.8769 11.6372 23.7805 11.7388L14.4657 21.5826C14.2714 21.7879 14.0078 21.9033 13.733 21.9033C13.4581 21.9033 13.1946 21.7879 13.0002 21.5826C12.8059 21.3772 12.6967 21.0986 12.6967 20.8082C12.6967 20.5177 12.8059 20.2392 13.0002 20.0338L20.5493 12.0582Z" fill="currentColor"/>
</svg>
</div>
</div>

</div>
</a>
</div>
<?php } ?>
</div>

<a href="<?php echo get_post_type_archive_link('post') ?>" class="relative btn btn-primary is-outline mt-8 self-center">More Articles</a>
</div>
</div>
</div>

File renamed without changes.
79 changes: 79 additions & 0 deletions template-parts/content.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,79 @@
<?php
/**
* Template part for displaying posts
*
* @link https://developer.wordpress.org/themes/basics/template-hierarchy/
*
* @package _s
*/

$thumbnail_url = get_the_post_thumbnail_url();
?>

<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">
<?php
/* translators: used between list items, there is a space after the comma */
$categories_list = get_the_category_list( esc_html__( ' ', 'devcon-msummit2024' ) );
if ( $categories_list ) {
/* translators: 1: list of categories. */
printf( '<div class="cat-links">' . esc_html__( '%1$s', 'devcon-msummit2024' ) . '</div>', $categories_list ); // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped
}
?>
<h1 class="text-4xl lg:text-6xl font-extrabold entry-title">
<?php
if ( is_singular() ) :
the_title( '', '' );
else :
the_title( '<a href="' . esc_url( get_permalink() ) . '" rel="bookmark">', '</a>' );
endif;
?>
</h1>

<?php
if ( 'post' === get_post_type() ) :
?>
<div class="entry-meta pt-8 flex items-center divide-x">
<?php
devcon_msummit2024_posted_by('pr-2');
devcon_msummit2024_posted_on('pl-2');
?>
</div><!-- .entry-meta -->
<?php endif; ?>
</header><!-- .entry-header -->

<?php if ($thumbnail_url) { ?>
<div
style="background-image: url(<?php echo $thumbnail_url ?>)"
class="pt-[calc(9/16*100%)] lg:pt-[calc(541/1512*100%)] bg-cover bg-center bg-no-repeat">
</div>
<?php } ?>

<div class="prose lg:prose-lg mx-auto <?php if ($thumbnail_url) { ?>pt-10 lg:pt-20<?php } ?> pb-20 px-6 md:px-0">
<?php
the_content(
sprintf(
wp_kses(
/* translators: %s: Name of current post. Only visible to screen readers */
__( 'Continue reading<span class="screen-reader-text"> "%s"</span>', '_s' ),
array(
'span' => array(
'class' => array(),
),
)
),
wp_kses_post( get_the_title() )
)
);
?>
</div><!-- .entry-content -->

<footer class="entry-footer">
<div class="container pb-10">
<?php devcon_msummit2024_entry_footer(); ?>
</div>

<?php get_template_part('template-parts/common/cta'); ?>
<?php get_template_part('template-parts/blog/related'); ?>
</footer><!-- .entry-footer -->
</article><!-- #post-<?php the_ID(); ?> -->
31 changes: 31 additions & 0 deletions yarpp-template-example.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
<?php
/*
YARPP Template: Starter Template
Description: A simple starter example template that you can edit.
Author: YARPP Team
*/
?>

<?php
/*
Templating in YARPP enables developers to uber-customize their YARPP display using PHP and template tags.
The tags we use in YARPP templates are the same as the template tags used in any WordPress template. In fact, any WordPress template tag will work in the YARPP Loop. You can use these template tags to display the excerpt, the post date, the comment count, or even some custom metadata. In addition, template tags from other plugins will also work.
If you've ever had to tweak or build a WordPress theme before, you’ll immediately feel at home.
// Special template tags which only work within a YARPP Loop:
1. the_score() // this will print the YARPP match score of that particular related post
2. get_the_score() // or return the YARPP match score of that particular related post
Notes:
1. If you would like Pinterest not to save an image, add `data-pin-nopin="true"` to the img tag.
*/

if (!have_posts()) {
return;
}
?>

Loading

0 comments on commit ac80980

Please sign in to comment.