diff --git a/components/SeoHead.js b/components/SeoHead.js new file mode 100644 index 0000000..d6ba76c --- /dev/null +++ b/components/SeoHead.js @@ -0,0 +1,61 @@ +import Head from 'next/head'; +import { useRouter } from 'next/router'; + +const SITE_URL = 'https://pcc.mlwmlw.org'; +const DEFAULT_TITLE = '開放政府標案'; +const DEFAULT_DESCRIPTION = '開放政府標案目的是為了讓公民能更容易關心繳納的稅金如何被分配與使用,持續監督政商之利害關係,提供各種統計數據與最新趨勢案件。'; +const DEFAULT_IMAGE = '/static/landing.jpg'; + +const toAbsoluteUrl = (value) => { + if (!value) { + return ''; + } + if (value.startsWith('http://') || value.startsWith('https://')) { + return value; + } + return `${SITE_URL}${value}`; +}; + +export default function SeoHead({ + title = DEFAULT_TITLE, + description = DEFAULT_DESCRIPTION, + image, + url, + type = 'website', + noIndex = false, + children, +}) { + const router = useRouter(); + const canonicalUrl = url || `${SITE_URL}${router.asPath}`; + const ogImage = toAbsoluteUrl(image || DEFAULT_IMAGE); + const twitterCard = ogImage ? 'summary_large_image' : 'summary'; + + return ( +
+檢視單月份各單位的標案預算的分配比例,可點擊檢視該單位詳細分配。
+
+