<?php
/**
 * WordPress posts page: news index.
 *
 * @package Fragrance_Trade
 */

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

$posts_page_id = absint( get_option( 'page_for_posts', 0 ) );
$page_title    = $posts_page_id ? get_the_title( $posts_page_id ) : __( '新闻资讯', 'fragrance-trade' );
if ( ! $page_title ) {
	$page_title = __( '新闻资讯', 'fragrance-trade' );
}

get_header();
?>
<main id="primary" class="site-main">
	<div class="page-content container news-page">
		<?php
		get_template_part(
			'template-parts/breadcrumb',
			null,
			array(
				'items' => array(
					array( 'label' => __( '首页', 'fragrance-trade' ), 'url' => home_url( '/' ) ),
					array( 'label' => $page_title, 'url' => null ),
				),
			)
		);
		?>
		<header class="news-page-header">
			<p class="section-eyebrow"><?php esc_html_e( '门店动态与用车知识', 'fragrance-trade' ); ?></p>
			<h1><?php echo esc_html( $page_title ); ?></h1>
			<p><?php esc_html_e( '了解门店活动、产品信息、施工知识与汽车膜日常护理建议。', 'fragrance-trade' ); ?></p>
		</header>

		<?php if ( have_posts() ) : ?>
			<div class="news-grid">
				<?php
				while ( have_posts() ) :
					the_post();
					get_template_part( 'template-parts/content', 'news-card' );
				endwhile;
				?>
			</div>
			<div class="news-pagination">
				<?php the_posts_pagination(); ?>
			</div>
		<?php else : ?>
			<section class="news-empty">
				<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>
		<?php endif; ?>
	</div>
</main>
<?php get_footer(); ?>
