/* ======================================================
INTERNAL LINK (FIXED - TIDAK TERBLOK SUMMARY)
======================================================*/
function portal_internal_link($content) {

    if (!is_single() || is_admin()) return $content;

    global $post;

    $targets = [];

    foreach ((array)get_the_category($post->ID) as $cat) {
        $targets[] = ['k'=>$cat->name,'u'=>get_category_link($cat->term_id)];
    }

    foreach ((array)get_the_tags($post->ID) as $tag) {
        if (str_word_count($tag->name) < 2) continue;
        $targets[] = ['k'=>$tag->name,'u'=>get_tag_link($tag->term_id)];
    }

    $related = get_posts([
        'post_type'=>'post',
        'posts_per_page'=>3,
        'post__not_in'=>[$post->ID]
    ]);

    foreach ($related as $r) {
        $targets[] = [
            'k'=>get_the_title($r->ID),
            'u'=>get_permalink($r->ID)
        ];
    }

    $count = 0;

    foreach ($targets as $t) {

        if ($count >= 5) break;

        $content = preg_replace(
            '/\b('.preg_quote($t['k'],'/').')\b(?![^<]*>)/iu',
            '<a href="'.esc_url($t['u']).'">$1</a>',
            $content,
            1,
            $replaced
        );

        if (!empty($replaced)) $count++;
    }

    return $content;
}
add_filter('the_content', 'portal_internal_link', 15);/* ======================================================
SEO + OG CLEAN
======================================================*/
add_action('wp_head', function () {

    if (!is_single()) return;

    global $post;

    $title = get_the_title($post->ID);
    $desc  = wp_trim_words(strip_tags($post->post_content), 28);
    $img   = get_the_post_thumbnail_url($post->ID, 'full');

    echo '<meta name="description" content="'.esc_attr($desc).'">';
    echo '<meta property="og:title" content="'.esc_attr($title).'">';
    echo '<meta property="og:description" content="'.esc_attr($desc).'">';
    echo '<meta property="og:image" content="'.esc_url($img).'">';
    echo '<meta property="og:url" content="'.get_permalink($post->ID).'">';

}, 5);


/* ======================================================
SCHEMA
======================================================*/
add_action('wp_head', function () {

    if (!is_single()) return;

    global $post;

    $schema = [
        "@context"=>"https://schema.org",
        "@type"=>"NewsArticle",
        "headline"=>get_the_title($post->ID),
        "datePublished"=>get_the_date('c'),
        "dateModified"=>get_the_modified_date('c'),
        "mainEntityOfPage"=>get_permalink($post->ID)
    ];

    echo '<script type="application/ld+json">'.json_encode($schema).'</script>';

}, 6);/* ======================================================
OPEN GRAPH
======================================================*/
add_action('wp_head', function () {

    if (!is_single()) return;

    global $post;

    $title = get_the_title($post->ID);
    $desc  = wp_trim_words(strip_tags($post->post_content), 28);
    $url   = get_permalink($post->ID);

    $img = get_the_post_thumbnail_url($post->ID, 'full');
    if (!$img) {
        $img = 'https://via.placeholder.com/1200x630.png?text=No+Image';
    }

    echo '<meta property="og:type" content="article">';
    echo '<meta property="og:title" content="'.esc_attr($title).'">';
    echo '<meta property="og:description" content="'.esc_attr($desc).'">';
    echo '<meta property="og:url" content="'.esc_url($url).'">';
    echo '<meta property="og:image" content="'.esc_url($img).'">';
    echo '<meta name="twitter:card" content="summary_large_image">';

}, 1);<?xml version="1.0" encoding="UTF-8"?><?xml-stylesheet type="text/xsl" href="//topikseru.com/wp-content/plugins/wordpress-seo/css/main-sitemap.xsl"?>
<sitemapindex xmlns="http://www.sitemaps.org/schemas/sitemap/0.9">
	<sitemap>
		<loc>https://topikseru.com/post-sitemap.xml</loc>
		<lastmod>2026-06-16T10:22:56+00:00</lastmod>
	</sitemap>
	<sitemap>
		<loc>https://topikseru.com/post-sitemap2.xml</loc>
		<lastmod>2025-03-19T23:44:34+00:00</lastmod>
	</sitemap>
	<sitemap>
		<loc>https://topikseru.com/post-sitemap3.xml</loc>
		<lastmod>2025-07-07T11:25:58+00:00</lastmod>
	</sitemap>
	<sitemap>
		<loc>https://topikseru.com/post-sitemap4.xml</loc>
		<lastmod>2025-08-11T16:02:46+00:00</lastmod>
	</sitemap>
	<sitemap>
		<loc>https://topikseru.com/post-sitemap5.xml</loc>
		<lastmod>2025-09-16T11:53:54+00:00</lastmod>
	</sitemap>
	<sitemap>
		<loc>https://topikseru.com/post-sitemap6.xml</loc>
		<lastmod>2025-10-26T13:47:49+00:00</lastmod>
	</sitemap>
	<sitemap>
		<loc>https://topikseru.com/post-sitemap7.xml</loc>
		<lastmod>2025-12-02T19:16:32+00:00</lastmod>
	</sitemap>
	<sitemap>
		<loc>https://topikseru.com/post-sitemap8.xml</loc>
		<lastmod>2026-01-24T16:11:52+00:00</lastmod>
	</sitemap>
	<sitemap>
		<loc>https://topikseru.com/post-sitemap9.xml</loc>
		<lastmod>2026-03-17T17:57:11+00:00</lastmod>
	</sitemap>
	<sitemap>
		<loc>https://topikseru.com/post-sitemap10.xml</loc>
		<lastmod>2026-04-24T11:12:19+00:00</lastmod>
	</sitemap>
	<sitemap>
		<loc>https://topikseru.com/post-sitemap11.xml</loc>
		<lastmod>2026-05-17T06:51:37+00:00</lastmod>
	</sitemap>
	<sitemap>
		<loc>https://topikseru.com/post-sitemap12.xml</loc>
		<lastmod>2026-06-16T07:17:20+00:00</lastmod>
	</sitemap>
	<sitemap>
		<loc>https://topikseru.com/post-sitemap13.xml</loc>
		<lastmod>2026-06-16T10:22:56+00:00</lastmod>
	</sitemap>
	<sitemap>
		<loc>https://topikseru.com/page-sitemap.xml</loc>
		<lastmod>2026-06-07T09:53:52+00:00</lastmod>
	</sitemap>
	<sitemap>
		<loc>https://topikseru.com/category-sitemap.xml</loc>
		<lastmod>2026-06-16T10:22:56+00:00</lastmod>
	</sitemap>
	<sitemap>
		<loc>https://topikseru.com/post_format-sitemap.xml</loc>
		<lastmod>2025-07-18T14:48:51+00:00</lastmod>
	</sitemap>
	<sitemap>
		<loc>https://topikseru.com/newstopic-sitemap.xml</loc>
		<lastmod>2026-05-26T18:09:09+00:00</lastmod>
	</sitemap>
</sitemapindex>
<!-- XML Sitemap generated by Yoast SEO -->