<xf:macro name="metadata"
	arg-siteName=""
	arg-title=""
	arg-description=""
	arg-type=""
	arg-shareUrl=""
	arg-canonicalUrl=""
	arg-imageUrl=""
	arg-twitterCard="summary">

	<xf:if is="$siteName is not empty">
		<xf:macro name="site_name" arg-siteName="{$siteName}" />
	</xf:if>
	<xf:if is="$title is not empty">
		<xf:macro name="title" arg-title="{$title}" />
	</xf:if>
	<xf:if is="$description is not empty">
		<xf:macro name="description" arg-description="{$description}" />
	</xf:if>
	<xf:if is="$type is not empty">
		<xf:macro name="type" arg-type="{$type}" />
	</xf:if>
	<xf:if is="$shareUrl is not empty">
		<xf:macro name="share_url" arg-shareUrl="{$shareUrl}" />
	</xf:if>
	<xf:if is="$canonicalUrl is not empty">
		<xf:macro name="canonical_url" arg-canonicalUrl="{$canonicalUrl}" />
	</xf:if>
	<xf:if is="$imageUrl is not empty">
		<xf:macro name="image_url" arg-imageUrl="{$imageUrl}" arg-twitterCard="{$twitterCard}" />
	</xf:if>
</xf:macro>

<xf:macro name="site_name" arg-siteName="!" arg-output="{{ false }}">
	<xf:set var="$meta"><meta property="og:site_name" content="{$siteName|for_attr}" /></xf:set>
	<xf:macro name="output" arg-option="meta_site_name" arg-meta="{$meta}" arg-output="{$output}" />
</xf:macro>

<xf:macro name="title" arg-title="!" arg-output="{{ false }}">
	<xf:set var="$meta">
		<meta property="og:title" content="{$title|for_attr}" />
		<meta property="twitter:title" content="{{ snippet($title, 70)|for_attr }}" />
	</xf:set>
	<xf:macro name="output" arg-option="meta_title" arg-meta="{$meta}" arg-output="{$output}" />
</xf:macro>

<xf:macro name="description" arg-description="!" arg-output="{{ false }}">
	<xf:set var="$meta">
		<meta name="description" content="{{ snippet($description|strip_tags, 160)|for_attr }}" />
		<meta property="og:description" content="{{ snippet($description|strip_tags, 300)|for_attr }}" />
		<meta property="twitter:description" content="{{ snippet($description|strip_tags, 200)|for_attr }}" />
	</xf:set>
	<xf:macro name="output" arg-option="meta_description" arg-meta="{$meta}" arg-output="{$output}" />
</xf:macro>

<xf:macro name="type" arg-type="!" arg-output="{{ false }}">
	<xf:set var="$meta"><meta property="og:type" content="{$type}" /></xf:set>
	<xf:macro name="output" arg-option="meta_type" arg-meta="{$meta}" arg-output="{$output}" />
</xf:macro>

<xf:macro name="share_url" arg-shareUrl="!" arg-output="{{ false }}">
	<xf:set var="$meta"><meta property="og:url" content="{$shareUrl}" /></xf:set>
	<xf:macro name="output" arg-option="meta_share_url" arg-meta="{$meta}" arg-output="{$output}" />
</xf:macro>

<xf:macro name="canonical_url" arg-canonicalUrl="!" arg-output="{{ false }}">
	<xf:set var="$meta"><link rel="canonical" href="{$canonicalUrl}" /></xf:set>
	<xf:macro name="output" arg-option="meta_canonical_url" arg-meta="{$meta}" arg-output="{$output}" />
</xf:macro>

<xf:macro name="image_url" arg-imageUrl="!" arg-twitterCard="summary" arg-output="{{ false }}">
	<xf:set var="$meta">
		<meta property="og:image" content="{$imageUrl}" />
		<meta property="twitter:image" content="{$imageUrl}" />
		<meta property="twitter:card" content="{$twitterCard}" />
	</xf:set>
	<xf:macro name="output" arg-option="meta_image_url" arg-meta="{$meta}" arg-output="{$output}" />
</xf:macro>

<xf:macro name="output" arg-option="!" arg-meta="!" arg-output="{{ false }}">
	<xf:if is="$output">{$meta|raw}<xf:else /><xf:head option="{$option}">{$meta|raw}</xf:head></xf:if>
</xf:macro>