<?php
/**
 * Generated by blog pipeline.
 */
get_header();
?>
<?php
	if ( ! defined( 'ABSPATH' ) ) {
		exit;
	}

	$page_id = get_queried_object_id();

	$short_description = get_post_meta(
		$page_id,
		'short_description',
		true
	);
?>
<header class="g-bfcacd1b" data-analytics-elevation="fcc9aa5a945e" data-analytics-category="commerce">
	<div class="g-fdc4b4e9" id="elem-461d428daae50004">
		<div class="g-5e50c799" data-test-component="dcd3b8c4f" data-element-category="navigation" data-bs-action="focus" data-test-toggle="dropdown" data-bs-event="pageview">
			<?php if ( has_post_thumbnail( $page_id ) ) : ?>
				<div class="g-afb4e002" id="elem-fb9ff5a5e09bd922">
					<figure class="g-2fb63495 g-4b68b70b">
						<?php
							echo get_the_post_thumbnail(
								$page_id,
								'',
								[
									'loading' => 'eager',
								]
							);
						?>
					</figure>
				</div>
			<?php endif; ?>
			<div class="g-5a3d3ac7" data-test-unit="78e29ef" data-bs-checked="4f396e" data-bs-track="0e07dc7d3">
				<h1 class="g-46336f1a g-e073ab23" id="elem-6859c332c24ab556">
					<?php echo esc_html( get_bloginfo( 'name' ) ); ?>
				</h1>
				<?php if ( ! empty( $short_description ) ) : ?>
					<div class="g-a02f370d g-175a508b" data-bs-qa="20be29e4ef9c" data-mui-source="61505409f" data-block-group="72affe1c5fb" data-widget-state="pending">
						<?php echo esc_html( $short_description ); ?>
					</div>
				<?php endif; ?>
				<div class="g-2574a250" id="elem-b9021bfc2be9a47e">
					<?php get_template_part( 'templates/searchform' ); ?>
				</div>
			</div>
		</div>
	</div>
</header>

<section id="about" class="g-bddcc6f6" data-mui-slide-to="a31b75bc4" data-mui-selector="cb2ecb19a" data-bs-size="large" data-bs-slide-to="2e1d5ed6" data-analytics-fixture="f69344e657">
    <div class="g-fdc4b4e9" id="elem-2529eee2e10bc28f">
        <div class="g-f49a6ccd" data-test-target="de8d9946" data-bs-disabled="443233e27feb" data-analytics-source="a5a7631ef0" data-analytics-variant="filled">
            <div class="g-22b9bac1" id="elem-ffb3c8adb0969d87">
                <h2 class="g-e073ab23 g-e8a97aec g-78b337df" data-mui-checked="af548156e77" data-bs-automation="c3835013" data-module-trigger="1612dd4e3">Your Starting Point for Everyday Cooking</h2>
                <p class="g-b41325c6 g-cfded025 g-e8a97aec" data-module-state="error" data-test-toggle="popover" data-section-animation="zoom">Kitchen Craft offers a collection of practical guides designed for those beginning their cooking journey. This page focuses on step-by-step methods for preparing simple meals, understanding knife handling, and selecting fresh produce. Each guide presents a structured approach to common kitchen tasks, allowing cooks to build familiarity with basic techniques. The content emphasizes clarity and repetition, providing a framework for developing confidence through practice. Whether you are learning to chop vegetables or trying a new recipe, these resources serve as a reference for everyday cooking routines.</p>
            </div>
        </div>
    </div>
    <div class="g-a078ae16 g-2064a201" data-analytics-value="c263de1c45c" data-block-state="pending" data-element-animation="fade" data-analytics-expanded="d9fd7d6429">
        <div class="g-fdc4b4e9 g-7c359df0" id="elem-b0e16a506c33c224">
            <figure class="g-41024f05 g-4b68b70b g-b6b01772 g-877c55e2 g-577873a7" data-module-position="left" data-bs-event="pageview" data-section-role="main" data-test-disabled="c3de61a4">
                <img src="<?php echo esc_url( get_template_directory_uri() . '/assets/images/generated/page-front-page-about--0-0.jpeg' ); ?>" alt="Adult man preparing vegetables using a knife and tablet in a contemporary kitchen setting." id="elem-63e87ac7b11f1834">
            </figure>
        </div>
    </div>
</section>

<section class="g-788a367d" data-analytics-fixture="d928d7" data-component-target="fea3594aeeab" data-test-dimension="fdfd8e9" data-widget-priority="high">
    <div class="g-fdc4b4e9" id="elem-c24cbceac731b374">
        <h2 class="g-e073ab23 g-08a08cf4" data-mui-value="4c0191" data-widget-position="top" data-mui-e2e="eedf2f4e02ab" data-component-state="error" data-block-priority="high">All categories</h2>
        <div class="g-9945c444" id="elem-4037727e0ca4b1d0">
            <?php
                $categories = get_categories(
                    [
                        'orderby'    => 'count',
                        'order'      => 'DESC',
                        'hide_empty' => true,
                    ]
                );

                if ( $categories ) :
                    ?>
                    <?php foreach ( $categories as $category ) : ?>
                    <?php $icon = get_term_meta( $category->term_id, 'icon', true ); ?>
                    <a
                        href="<?php echo esc_url( get_category_link( $category->term_id ) ); ?>"
                        class="g-d2cf4d69"
                    >
                        <div class="g-bfba73f0 g-52883ce1">
                            <?php if ( ! empty( $icon ) ) : ?>
                                <span class="g-4cc9fdd5">
                                    <?php echo esc_html( $icon ); ?>
                                </span>
                            <?php endif; ?>

                            <?php echo esc_html( $category->name ); ?>
                        </div>
                    </a>
                <?php endforeach; ?>
                <?php endif; ?>
        </div>
    </div>
</section>

<?php

	if ( ! defined( 'ABSPATH' ) ) {
		exit;
	}
	/**
	 * Popular post
	 */
	$popular_posts = get_posts(
		[
			'post_type'           => 'post',
			'posts_per_page'      => 1,
			'meta_key'            => 'is_popular',
			'meta_value'          => '1',
			'ignore_sticky_posts' => true,
		]
	);
	/**
	 * Latest posts
	 */
	$latest_posts = get_posts(
		[
			'post_type'           => 'post',
			'posts_per_page'      => 3,
			'post_status'         => 'publish',
			'ignore_sticky_posts' => true,
			'post__not_in'        => ! empty( $popular_posts )
				? [ $popular_posts[0]->ID ]
				: [],
		]
	);

?>
<section class="g-677249c0" data-bs-selected="177b5b64" data-mui-expanded="d907f414c56" data-bs-wrap="d7f718121f">
	<div class="g-fdc4b4e9" id="elem-9a6fed4ccbba3ef1">
		<div class="g-107154b3" data-test-action="expand" data-bs-cy="c5c2914f6d">
			<?php if ( ! empty( $popular_posts ) ) : ?>
				<div
					class="g-b5e8097e"
					aria-labelledby="popular-post-title"
				>
					<div class="g-6028dac2" id="elem-dbbed12ebf8d3b7c">
						<h2
							id="popular-post-title"
							class="g-1b2cb12c g-e073ab23"
							data-test-category="navigation" data-module-state="success" data-block-type="tertiary" data-test-loading="86b7b44"
						>
						Popular posts
						</h2>
					</div>
					<div class="g-05b055cb g-3bf98ad4" id="elem-08382892a4c6ee66">
						<?php
							$post = $popular_posts[0];
							setup_postdata( $post );
							get_template_part(
								'templates/post-card',
								null,

							);
							wp_reset_postdata();
						?>
					</div>
				</div>
			<?php endif; ?>
			<?php if ( ! empty( $latest_posts ) ) : ?>
				<aside
					class="g-584cbd16"
					aria-labelledby="latest-posts-title"
				>
					<div class="g-900b1c00 g-b8646578" data-test-automation="de057c50" data-block-status="deleted" data-bs-cy="48f1550449">
						<h2
							id="latest-posts-title"
							class="g-1b2cb12c g-6d6980ed"
							id="elem-b5a44073ae1f2c70"
						>
						Latest posts
						</h2>
					</div>
					<?php
						foreach ( $latest_posts as $key => $post ) :
							setup_postdata( $post );
							?>
							<?php
							if ( $key !== 0 ) {
								echo '<hr class="g-ee6b358b" />';
							}
							get_template_part(
								'templates/post-card',
								null,
								[
									'size' => 'small',
								]
							);
							?>
						<?php
						endforeach;
						wp_reset_postdata();
					?>
				</aside>
			<?php endif; ?>
		</div>
		<?php
			$posts_page_id = get_option( 'page_for_posts' );

			if ( $posts_page_id ) :
				?>
				<div class="g-7fc0513d" data-mui-action="submit" data-test-unit="9409c53cc">
					<a href="<?php echo esc_url( get_permalink( $posts_page_id ) ); ?>" class="g-c43b1a32" id="elem-1efcddcaa80acd54">
						<span>View all</span>
					</a>
				</div>
			<?php endif; ?>
	</div>
</section>

<?php
	if ( ! defined( 'ABSPATH' ) ) {
		exit;
	}

	$render_page_content = static function ( string $content ): void {
		if ( $content === '' ) {
			return;
		}
		?>
		<div class="g-fdc4b4e9">
			<article id="post-<?php the_ID(); ?>" class="content-wrapper g-e0b1052a">
				<?php echo apply_filters( 'the_content', $content ); ?>
			</article>
		</div>
		<?php
	};

	if ( in_the_loop() ) {
		$render_page_content( get_the_content() );
	} elseif ( have_posts() ) {
		while ( have_posts() ) {
			the_post();
			$render_page_content( get_the_content() );
		}
	}
?>
<?php get_footer(); ?>
