<?php
/**
 * Single news article template.
 *
 * @package Fragrance_Trade
 */

if ( ! defined( 'ABSPATH' ) ) {
	exit;
}

get_header();
?>
<main id="primary" class="site-main">
	<?php while ( have_posts() ) : the_post(); ?>
		<article <?php post_class( 'page-content container news-single' ); ?>>
			<?php
			get_template_part(
				'template-parts/breadcrumb',
				null,
				array(
					'items' => array(
						array( 'label' => __( '首页', 'fragrance-trade' ), 'url' => home_url( '/' ) ),
						array( 'label' => __( '新闻资讯', 'fragrance-trade' ), 'url' => fragrance_trade_news_url() ),
						array( 'label' => get_the_title(), 'url' => null ),
					),
				)
			);
			?>
			<header class="news-single-header">
				<div class="news-meta">
					<?php $categories = get_the_category_list( ' · ' ); ?>
					<?php if ( $categories ) : ?>
						<span class="news-categories"><?php echo wp_kses_post( $categories ); ?></span>
					<?php endif; ?>
					<time datetime="<?php echo esc_attr( get_the_date( DATE_W3C ) ); ?>"><?php echo esc_html( get_the_date() ); ?></time>
				</div>
				<h1><?php the_title(); ?></h1>
			</header>

			<?php if ( has_post_thumbnail() ) : ?>
				<figure class="news-single-image">
					<?php the_post_thumbnail( 'large', array( 'class' => 'img-fluid', 'decoding' => 'async' ) ); ?>
				</figure>
			<?php endif; ?>

			<div class="news-single-content">
				<?php the_content(); ?>
				<?php
				wp_link_pages(
					array(
						'before' => '<nav class="page-links" aria-label="' . esc_attr__( '文章分页', 'fragrance-trade' ) . '">',
						'after'  => '</nav>',
					)
				);
				?>
			</div>

			<?php
			$previous_post = get_previous_post();
			$next_post     = get_next_post();
			if ( $previous_post || $next_post ) :
				?>
				<div class="news-post-navigation">
					<?php
					the_post_navigation(
						array(
							'prev_text'          => '<span class="nav-subtitle">' . esc_html__( '上一篇', 'fragrance-trade' ) . '</span><span class="nav-title">%title</span>',
							'next_text'          => '<span class="nav-subtitle">' . esc_html__( '下一篇', 'fragrance-trade' ) . '</span><span class="nav-title">%title</span>',
							'in_same_term'       => false,
							'taxonomy'           => 'category',
							'screen_reader_text' => __( '新闻文章导航', 'fragrance-trade' ),
						)
					);
					?>
				</div>
			<?php endif; ?>

			<section class="news-single-cta">
				<h2><?php esc_html_e( '需要了解适合车辆的贴膜方案？', 'fragrance-trade' ); ?></h2>
				<p><?php esc_html_e( '提供车型、使用场景和关注的问题，门店会结合实际情况说明可选项目。', 'fragrance-trade' ); ?></p>
				<a class="btn btn-b2b-primary" href="<?php echo esc_url( home_url( '/contact/' ) ); ?>"><?php esc_html_e( '咨询贴膜方案', 'fragrance-trade' ); ?></a>
			</section>
		</article>
	<?php endwhile; ?>
</main>
<?php get_footer(); ?>
