<commit_before><?php

page::$methods['canonical_rel'] = function($page, $filter_value, $page_num) {
	return '<link rel="canonical" href="' . $page->url() . (($page_num && $page_num != 1) ? '/page/' . $page_num : '') . '">' . "\n";
/**
 * HTML head page title
 *
 * Field requirements:
 * - $site->title() *
 * - $site->tagline() *      ---> (part of) home page's title (and used to generate fallback for meta description)
 * - $page->long-title()     ---> page's title
 * - $page->title() *        ---> page's title, used to generate fallback for page's long title

Fields marked with an asterisk (*) are required and need to be filled in to
make it work. If any of the other fields are missing it should still work.

Include following line in HTML head:
`<title><?php echo $page->page_title(); ?></title>`
 */

page::$methods['page_title'] = function($page) {

	if($page->isHomePage()) {
		if(site()->tagline()->exits() && site()->tagline()->isNotEmpty()) {
			$page_title = site()->title() . ': ' . site()->tagline()->smartypants()->titlecase();
		}
		else {
			$page_title = site()->title();
		}
	}
	else {
		if($page->long_title()->exits() && $page->long_title()->isNotEmpty()) {
			$page_title = site()->title() . ': ' . $page->long_title()->smartypants()->titlecase();
		}
		else {
			$page_title = site()->title() . ': ' . $page->title()->smartypants()->titlecase();
		}
	}
	return $page_title;
};

/**
 * Meta description
 *
 * Field requirements:
 * - $page->description()    ---> page's meta description
 * - $page->intro()          ---> page's main text content, used to generate fallback for meta description
 * - $page->text()           ---> page's main text content, used to generate fallback for meta description
 * - $site->tagline() *      ---> (part of) home page's title, last resort fallback for meta description

Fields marked with an asterisk (*) are required and need to be filled in to
make it work. If any of the other fields are missing it should still work.

Include following line in HTML head:
`<meta name="description" content="<?php echo $page->meta_description(); ?>">`
 */

page::$methods['meta_description'] = function($page) {

	if($page->description()->exits() && $page->description()->isNotEmpty()) {
		$description = $page->description()->smartypants();
	}
	elseif($page->intro()->exits() && $page->intro()->isNotEmpty() ) {
		$description = $page->intro()->smartypants();
	}
	elseif($page->text()->exits() && $page->text()->isNotEmpty() ) {
		$description = $page->text()->smartypants();
	}
	else {
		$description = $site->tagline()->smartypants();
	}
	return $description->excerpt(155);
};

};

page::$methods['prevnext_rel'] = function($page, $filter_key, $filter_value, $pagination, $page_num) {

	if($pagination && $pagination->hasPages()) {
		if($page_num == 1 and $pagination->hasNextPage()) {
			return '<link rel="next" href="' . url(kirby()->request()->path()->first() . (($filter_value) ? '/' . $filter_key . '/' . $filter_value : '') . '/page/2') . '">'  . "\n";
		}
		if($page_num == 2 and $pagination->hasNextPage()) {
			return '<link rel="prev" href="' . url(kirby()->request()->path()->first() . (($filter_value) ? '/' . $filter_key . '/' . $filter_value : '')) . '">
					<link rel="next" href="' . url(kirby()->request()->path()->first() . (($filter_value) ? '/' . $filter_key . '/' . $filter_value : '') . '/page/' . ($page_num + 1)) . '">'  . "\n";
		}
		if($pagination->hasPrevPage() and $pagination->hasNextPage()) {
			return '<link rel="prev" href="' . url(kirby()->request()->path()->first() . (($filter_value) ? '/' . $filter_key . '/' . $filter_value : '') . '/page/' . ($page_num - 1)) . '">
					<link rel="next" href="' . url(kirby()->request()->path()->first() . (($filter_value) ? '/' . $filter_key . '/' . $filter_value : '') . '/page/' . ($page_num + 1)) . '">'  . "\n";
		}
		if($page_num == 2 and !$pagination->hasNextPage()) {
			return '<link rel="prev" href="' . url(kirby()->request()->path()->first() . (($filter_value) ? '/' . $filter_key . '/' . $filter_value : '')) . '">'  . "\n";
		}
		if($pagination->hasPrevPage() and !$pagination->hasNextPage()) {
			return '<link rel="prev" href="' . url(kirby()->request()->path()->first() . (($filter_value) ? '/' . $filter_key . '/' . $filter_value : '') . '/page/' . ($page_num - 1)) . '">'   . "\n";
		}
	}
};

/**
 * Alternate link(s) (for multiple languages)
 *
 * Usage example:
 * `<?php echo $page->rel_alternate(); ?>`
 */

page::$methods['rel_alternate'] = function($page) {

	if(c::get('language.multi', false)) {

		$alternate = '';

		foreach(site()->languages() as $language) {

			if(site()->languages()->count() > 1 && site()->language() != $language && isset($page->inventory()['content'][$language->code()])) {
				$alternate .= '<link rel="alternate" href="' . $page->url($language->code()) . '" hreflang="' . $language->locale() . '">'  . "\n";
			}<commit_msg>Remove extra spaces. Clean up.<commit_after><?php

page::$methods['canonical_rel'] = function($page, $filter_value, $page_num) {
	return '<link rel="canonical" href="' . $page->url() . (($page_num && $page_num != 1) ? '/page/' . $page_num : '') . '">' . "\n";
/**
 * HTML head page title
 *
 * Field requirements:
 * - $site->title() *
 * - $site->tagline() *      ---> (part of) home page's title (and used to generate fallback for meta description)
 * - $page->long-title()     ---> page's title
 * - $page->title() *        ---> page's title, used to generate fallback for page's long title

Fields marked with an asterisk (*) are required and need to be filled in to
make it work. If any of the other fields are missing it should still work.

Include following line in HTML head:
`<title><?php echo $page->page_title(); ?></title>`
 */

page::$methods['page_title'] = function($page) {

	if($page->isHomePage()) {
		if(site()->tagline()->exits() && site()->tagline()->isNotEmpty()) {
			$page_title = site()->title() . ': ' . site()->tagline()->smartypants()->titlecase();
		}
		else {
			$page_title = site()->title();
		}
	}
	else {
		if($page->long_title()->exits() && $page->long_title()->isNotEmpty()) {
			$page_title = site()->title() . ': ' . $page->long_title()->smartypants()->titlecase();
		}
		else {
			$page_title = site()->title() . ': ' . $page->title()->smartypants()->titlecase();
		}
	}
	return $page_title;
};

/**
 * Meta description
 *
 * Field requirements:
 * - $page->description()    ---> page's meta description
 * - $page->intro()          ---> page's main text content, used to generate fallback for meta description
 * - $page->text()           ---> page's main text content, used to generate fallback for meta description
 * - $site->tagline() *      ---> (part of) home page's title, last resort fallback for meta description

Fields marked with an asterisk (*) are required and need to be filled in to
make it work. If any of the other fields are missing it should still work.

Include following line in HTML head:
`<meta name="description" content="<?php echo $page->meta_description(); ?>">`
 */

page::$methods['meta_description'] = function($page) {

	if($page->description()->exits() && $page->description()->isNotEmpty()) {
		$description = $page->description()->smartypants();
	}
	elseif($page->intro()->exits() && $page->intro()->isNotEmpty() ) {
		$description = $page->intro()->smartypants();
	}
	elseif($page->text()->exits() && $page->text()->isNotEmpty() ) {
		$description = $page->text()->smartypants();
	}
	else {
		$description = $site->tagline()->smartypants();
	}
	return $description->excerpt(155);
};

};

page::$methods['prevnext_rel'] = function($page, $filter_key, $filter_value, $pagination, $page_num) {

	if($pagination && $pagination->hasPages()) {
		if($page_num == 1 and $pagination->hasNextPage()) {
			return '<link rel="next" href="' . url(kirby()->request()->path()->first() . (($filter_value) ? '/' . $filter_key . '/' . $filter_value : '') . '/page/2') . '">' . "\n";
		}
		if($page_num == 2 and $pagination->hasNextPage()) {
			return '<link rel="prev" href="' . url(kirby()->request()->path()->first() . (($filter_value) ? '/' . $filter_key . '/' . $filter_value : '')) . '">
					<link rel="next" href="' . url(kirby()->request()->path()->first() . (($filter_value) ? '/' . $filter_key . '/' . $filter_value : '') . '/page/' . ($page_num + 1)) . '">' . "\n";
		}
		if($pagination->hasPrevPage() and $pagination->hasNextPage()) {
			return '<link rel="prev" href="' . url(kirby()->request()->path()->first() . (($filter_value) ? '/' . $filter_key . '/' . $filter_value : '') . '/page/' . ($page_num - 1)) . '">
					<link rel="next" href="' . url(kirby()->request()->path()->first() . (($filter_value) ? '/' . $filter_key . '/' . $filter_value : '') . '/page/' . ($page_num + 1)) . '">' . "\n";
		}
		if($page_num == 2 and !$pagination->hasNextPage()) {
			return '<link rel="prev" href="' . url(kirby()->request()->path()->first() . (($filter_value) ? '/' . $filter_key . '/' . $filter_value : '')) . '">' . "\n";
		}
		if($pagination->hasPrevPage() and !$pagination->hasNextPage()) {
			return '<link rel="prev" href="' . url(kirby()->request()->path()->first() . (($filter_value) ? '/' . $filter_key . '/' . $filter_value : '') . '/page/' . ($page_num - 1)) . '">' . "\n";
		}
	}
};

/**
 * Alternate link(s) (for multiple languages)
 *
 * Usage example:
 * `<?php echo $page->rel_alternate(); ?>`
 */

page::$methods['rel_alternate'] = function($page) {

	if(c::get('language.multi', false)) {

		$alternate = '';

		foreach(site()->languages() as $language) {

			if(site()->languages()->count() > 1 && site()->language() != $language && isset($page->inventory()['content'][$language->code()])) {
				$alternate .= '<link rel="alternate" href="' . $page->url($language->code()) . '" hreflang="' . $language->locale() . '">'  . "\n";
			}
{'fraction_non_alphanumeric': 0.25124707319556144, 'fraction_numerical': 0.002646849231395704, 'mean_word_length': 3.698230511716882, 'pattern_counts': {'":': 0, '<': 35, '<?xml version=': 0, '>': 235, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '5603756', 'n_tokens_mistral': 3417, 'n_tokens_neox': 3243, 'n_words': 694}