<script lang="ts">
	import * as config from '$lib/config'
	import type { Snippet } from '$lib/types'
	import CodeBlock from '$lib/components/CodeBlock.svelte'

	export let data: { snippets: Snippet[] }
</script>

<svelte:head>
	<title>{config.title} in DuckDB</title>
	<meta name="description" content="A collection of snippets for DuckDB." />
	
</svelte:head>

<section class="max-w-3xl mx-auto px-4 py-12 pb-32">
	<h1 class="text-6xl mt-10 font-bold text-center tracking-tight text-slate-800 mb-8">{config.title}</h1>
	<p class="text-lg text-center text-slate-600">{config.description}</p>
	<p class="text-lg text-center text-slate-600 mb-8">Open a discussion to request a new snippet.</p>
	<div class="flex justify-center mb-16">
		<a href="https://huggingface.co/spaces/cfahlgren1/sql-snippets/discussions/new" 
		   target="_blank" 
		   rel="noopener noreferrer" 
		   class="inline-block transition-all duration-300 hover:scale-105 hover:shadow-lg">
		   <svg width="191" height="36" viewBox="0 0 191 36" fill="none" xmlns="http://www.w3.org/2000/svg">
			<path d="M17.0208 0.5H173.679C182.603 0.5 189.899 8.29964 189.899 18C189.899 27.7004 182.603 35.5 173.679 35.5H17.0208C8.09682 35.5 0.800781 27.7004 0.800781 18C0.800781 8.29964 8.09682 0.5 17.0208 0.5Z" fill="url(#paint0_linear_207_211)" stroke="#EFEFEF"/>
			<path d="M47.1168 24.2071C46.1389 24.2071 45.2759 23.9712 44.5281 23.4995C43.7802 23.0163 43.1934 22.3374 42.7677 21.463C42.3535 20.5771 42.1464 19.5243 42.1464 18.3048C42.1464 17.0852 42.3535 16.0439 42.7677 15.181C43.1934 14.3181 43.7802 13.6565 44.5281 13.1963C45.2759 12.7361 46.1389 12.506 47.1168 12.506C48.1063 12.506 48.975 12.7361 49.7228 13.1963C50.4707 13.6565 51.0517 14.3181 51.4659 15.181C51.8916 16.0439 52.1045 17.0852 52.1045 18.3048C52.1045 19.5243 51.8916 20.5771 51.4659 21.463C51.0517 22.3374 50.4707 23.0163 49.7228 23.4995C48.975 23.9712 48.1063 24.2071 47.1168 24.2071ZM47.1168 22.464C48.0028 22.464 48.7104 22.0901 49.2396 21.3422C49.7689 20.5829 50.0335 19.5704 50.0335 18.3048C50.0335 17.0391 49.7689 16.0497 49.2396 15.3363C48.7104 14.6115 48.0028 14.2491 47.1168 14.2491C46.2309 14.2491 45.5233 14.6115 44.9941 15.3363C44.4648 16.0497 44.2002 17.0391 44.2002 18.3048C44.2002 19.5704 44.4648 20.5829 44.9941 21.3422C45.5233 22.0901 46.2309 22.464 47.1168 22.464ZM54.1898 27.3481V15.5262H55.8293L55.9674 16.4236H56.0364C56.3931 16.1245 56.79 15.8656 57.2272 15.647C57.676 15.4284 58.1304 15.3191 58.5906 15.3191C59.6492 15.3191 60.466 15.7103 61.0413 16.4926C61.6281 17.275 61.9215 18.322 61.9215 19.6336C61.9215 20.6001 61.7489 21.4285 61.4038 22.1188C61.0586 22.7977 60.6099 23.3154 60.0576 23.6721C59.5168 24.0288 58.9301 24.2071 58.2973 24.2071C57.9291 24.2071 57.5609 24.1266 57.1927 23.9655C56.8245 23.7929 56.4679 23.5628 56.1227 23.2752L56.1745 24.6903V27.3481H54.1898ZM57.8831 22.5676C58.4468 22.5676 58.9186 22.3202 59.2982 21.8255C59.6779 21.3307 59.8678 20.6059 59.8678 19.6509C59.8678 18.7995 59.7239 18.1379 59.4363 17.6662C59.1487 17.1945 58.6827 16.9586 58.0384 16.9586C57.4401 16.9586 56.8188 17.275 56.1745 17.9078V21.86C56.4851 22.1131 56.7843 22.2972 57.0719 22.4122C57.3596 22.5158 57.6299 22.5676 57.8831 22.5676ZM67.5555 24.2071C66.7732 24.2071 66.0656 24.0345 65.4328 23.6894C64.8 23.3327 64.2995 22.8264 63.9313 22.1706C63.5631 21.5033 63.379 20.7037 63.379 19.7717C63.379 18.8513 63.5631 18.0574 63.9313 17.3901C64.311 16.7227 64.8 16.2107 65.3982 15.8541C65.9965 15.4974 66.6236 15.3191 67.2794 15.3191C68.0503 15.3191 68.6946 15.4917 69.2123 15.8368C69.7301 16.1705 70.1213 16.6422 70.3859 17.252C70.6505 17.8503 70.7828 18.5464 70.7828 19.3403C70.7828 19.7545 70.7541 20.0766 70.6965 20.3067H65.312C65.404 21.0546 65.6744 21.6356 66.1231 22.0498C66.5718 22.464 67.1356 22.6711 67.8144 22.6711C68.1826 22.6711 68.522 22.6193 68.8326 22.5158C69.1548 22.4007 69.4712 22.2454 69.7819 22.0498L70.4549 23.2924C70.0522 23.557 69.6035 23.7756 69.1088 23.9482C68.614 24.1208 68.0963 24.2071 67.5555 24.2071ZM65.2947 18.9606H69.057C69.057 18.3048 68.9132 17.7928 68.6255 17.4246C68.3379 17.0449 67.9065 16.8551 67.3312 16.8551C66.8364 16.8551 66.3935 17.0391 66.0023 17.4073C65.6226 17.764 65.3867 18.2817 65.2947 18.9606ZM72.6784 24V15.5262H74.318L74.456 16.6652H74.5251C74.9047 16.297 75.3189 15.9806 75.7677 15.716C76.2164 15.4514 76.7284 15.3191 77.3036 15.3191C78.2126 15.3191 78.8742 15.6125 79.2884 16.1992C79.7026 16.786 79.9097 17.6144 79.9097 18.6844V24H77.9249V18.9433C77.9249 18.2415 77.8214 17.7467 77.6143 17.4591C77.4072 17.1715 77.0678 17.0276 76.5961 17.0276C76.2279 17.0276 75.9 17.1197 75.6123 17.3038C75.3362 17.4764 75.0198 17.7352 74.6631 18.0804V24H72.6784ZM87.8444 24.2071C87.1081 24.2071 86.504 23.977 86.0323 23.5168C85.5721 23.0565 85.342 22.4583 85.342 21.7219C85.342 20.813 85.7389 20.1111 86.5328 19.6164C87.3267 19.1101 88.5923 18.765 90.3296 18.5809C90.3181 18.1322 90.1973 17.7467 89.9672 17.4246C89.7486 17.0909 89.3517 16.9241 88.7764 16.9241C88.3622 16.9241 87.9537 17.0046 87.551 17.1657C87.1599 17.3268 86.7744 17.5224 86.3947 17.7525L85.6699 16.4236C86.1416 16.1245 86.6709 15.8656 87.2576 15.647C87.8559 15.4284 88.4887 15.3191 89.1561 15.3191C90.2146 15.3191 91.0027 15.6355 91.5205 16.2683C92.0497 16.8896 92.3143 17.7928 92.3143 18.9778V24H90.6748L90.5367 23.0681H90.4677C90.088 23.3902 89.6796 23.6606 89.2424 23.8792C88.8166 24.0978 88.3507 24.2071 87.8444 24.2071ZM88.483 22.6539C88.8282 22.6539 89.1388 22.5733 89.4149 22.4122C89.7026 22.2397 90.0075 22.0095 90.3296 21.7219V19.8235C89.1791 19.9731 88.3794 20.1974 87.9307 20.4966C87.482 20.7842 87.2576 21.1409 87.2576 21.5666C87.2576 21.9463 87.3727 22.2224 87.6028 22.395C87.8329 22.5676 88.1263 22.6539 88.483 22.6539ZM101.113 24.2071C100.054 24.2071 99.2088 23.8159 98.576 23.0335C97.9432 22.2512 97.6268 21.1639 97.6268 19.7717C97.6268 18.8513 97.7936 18.0574 98.1273 17.3901C98.4725 16.7227 98.9212 16.2107 99.4734 15.8541C100.026 15.4974 100.607 15.3191 101.217 15.3191C101.7 15.3191 102.108 15.4054 102.442 15.5779C102.787 15.739 103.121 15.9634 103.443 16.251L103.374 14.8876V11.8156H105.359V24H103.719L103.581 23.0853H103.512C103.201 23.396 102.839 23.6606 102.425 23.8792C102.01 24.0978 101.573 24.2071 101.113 24.2071ZM101.596 22.5676C102.229 22.5676 102.822 22.2512 103.374 21.6184V17.6662C103.086 17.4016 102.799 17.2175 102.511 17.1139C102.223 17.0104 101.936 16.9586 101.648 16.9586C101.107 16.9586 100.641 17.206 100.25 17.7007C99.8704 18.1839 99.6805 18.8685 99.6805 19.7545C99.6805 20.6634 99.8474 21.3595 100.181 21.8427C100.515 22.3259 100.986 22.5676 101.596 22.5676ZM107.886 24V15.5262H109.871V24H107.886ZM108.887 14.042C108.53 14.042 108.243 13.9384 108.024 13.7313C107.806 13.5242 107.696 13.2481 107.696 12.9029C107.696 12.5692 107.806 12.2989 108.024 12.0918C108.243 11.8847 108.53 11.7811 108.887 11.7811C109.244 11.7811 109.531 11.8847 109.75 12.0918C109.969 12.2989 110.078 12.5692 110.078 12.9029C110.078 13.2481 109.969 13.5242 109.75 13.7313C109.531 13.9384 109.244 14.042 108.887 14.042ZM114.767 24.2071C114.192 24.2071 113.617 24.0978 113.041 23.8792C112.466 23.6491 111.971 23.3672 111.557 23.0335L112.489 21.7564C112.869 22.0441 113.249 22.2742 113.628 22.4468C114.008 22.6193 114.411 22.7056 114.836 22.7056C115.297 22.7056 115.636 22.6078 115.855 22.4122C116.073 22.2166 116.182 21.975 116.182 21.6874C116.182 21.4458 116.09 21.2502 115.906 21.1006C115.734 20.9395 115.509 20.8015 115.233 20.6864C114.957 20.5598 114.669 20.439 114.37 20.324C114.002 20.1859 113.634 20.0191 113.266 19.8235C112.909 19.6164 112.616 19.3575 112.386 19.0469C112.156 18.7247 112.04 18.3278 112.04 17.856C112.04 17.1082 112.317 16.4984 112.869 16.0267C113.421 15.5549 114.169 15.3191 115.112 15.3191C115.711 15.3191 116.246 15.4226 116.717 15.6297C117.189 15.8368 117.598 16.0727 117.943 16.3373L117.028 17.5454C116.729 17.3268 116.424 17.1542 116.113 17.0276C115.814 16.8896 115.498 16.8205 115.164 16.8205C114.739 16.8205 114.422 16.9126 114.215 17.0967C114.008 17.2693 113.904 17.4879 113.904 17.7525C113.904 18.0862 114.077 18.3393 114.422 18.5119C114.767 18.6844 115.17 18.8513 115.63 19.0123C116.021 19.1504 116.401 19.323 116.769 19.5301C117.137 19.7257 117.442 19.9846 117.684 20.3067C117.937 20.6289 118.064 21.0546 118.064 21.5838C118.064 22.3087 117.782 22.93 117.218 23.4477C116.654 23.954 115.837 24.2071 114.767 24.2071ZM123.373 24.2071C122.602 24.2071 121.906 24.0345 121.285 23.6894C120.675 23.3327 120.186 22.8264 119.818 22.1706C119.461 21.5033 119.283 20.7037 119.283 19.7717C119.283 18.8283 119.479 18.0286 119.87 17.3728C120.261 16.7055 120.779 16.1992 121.423 15.8541C122.079 15.4974 122.781 15.3191 123.529 15.3191C124.069 15.3191 124.541 15.4111 124.944 15.5952C125.347 15.7793 125.703 16.0036 126.014 16.2683L125.047 17.5626C124.829 17.3671 124.604 17.2175 124.374 17.1139C124.144 16.9989 123.897 16.9413 123.632 16.9413C122.953 16.9413 122.395 17.2002 121.958 17.718C121.532 18.2357 121.32 18.9203 121.32 19.7717C121.32 20.6116 121.527 21.2904 121.941 21.8082C122.367 22.3259 122.913 22.5848 123.58 22.5848C123.914 22.5848 124.225 22.5158 124.512 22.3777C124.812 22.2281 125.082 22.0556 125.324 21.86L126.135 23.1716C125.744 23.5168 125.306 23.7756 124.823 23.9482C124.34 24.1208 123.857 24.2071 123.373 24.2071ZM130.327 24.2071C129.418 24.2071 128.756 23.9137 128.342 23.3269C127.928 22.7401 127.721 21.9117 127.721 20.8417V15.5262H129.706V20.5829C129.706 21.2847 129.809 21.7794 130.016 22.0671C130.223 22.3547 130.557 22.4985 131.017 22.4985C131.385 22.4985 131.708 22.4065 131.984 22.2224C132.271 22.0383 132.576 21.7392 132.898 21.325V15.5262H134.883V24H133.261L133.106 22.7574H133.054C132.686 23.1946 132.283 23.5455 131.846 23.8102C131.409 24.0748 130.902 24.2071 130.327 24.2071ZM139.761 24.2071C139.186 24.2071 138.611 24.0978 138.036 23.8792C137.46 23.6491 136.966 23.3672 136.551 23.0335L137.483 21.7564C137.863 22.0441 138.243 22.2742 138.622 22.4468C139.002 22.6193 139.405 22.7056 139.831 22.7056C140.291 22.7056 140.63 22.6078 140.849 22.4122C141.067 22.2166 141.177 21.975 141.177 21.6874C141.177 21.4458 141.085 21.2502 140.901 21.1006C140.728 20.9395 140.504 20.8015 140.227 20.6864C139.951 20.5598 139.664 20.439 139.365 20.324C138.996 20.1859 138.628 20.0191 138.26 19.8235C137.903 19.6164 137.61 19.3575 137.38 19.0469C137.15 18.7247 137.035 18.3278 137.035 17.856C137.035 17.1082 137.311 16.4984 137.863 16.0267C138.415 15.5549 139.163 15.3191 140.107 15.3191C140.705 15.3191 141.24 15.4226 141.712 15.6297C142.183 15.8368 142.592 16.0727 142.937 16.3373L142.022 17.5454C141.723 17.3268 141.418 17.1542 141.108 17.0276C140.808 16.8896 140.492 16.8205 140.158 16.8205C139.733 16.8205 139.416 16.9126 139.209 17.0967C139.002 17.2693 138.899 17.4879 138.899 17.7525C138.899 18.0862 139.071 18.3393 139.416 18.5119C139.761 18.6844 140.164 18.8513 140.624 19.0123C141.016 19.1504 141.395 19.323 141.763 19.5301C142.132 19.7257 142.437 19.9846 142.678 20.3067C142.931 20.6289 143.058 21.0546 143.058 21.5838C143.058 22.3087 142.776 22.93 142.212 23.4477C141.648 23.954 140.831 24.2071 139.761 24.2071ZM147.194 24.2071C146.619 24.2071 146.043 24.0978 145.468 23.8792C144.893 23.6491 144.398 23.3672 143.984 23.0335L144.916 21.7564C145.296 22.0441 145.675 22.2742 146.055 22.4468C146.435 22.6193 146.837 22.7056 147.263 22.7056C147.723 22.7056 148.063 22.6078 148.281 22.4122C148.5 22.2166 148.609 21.975 148.609 21.6874C148.609 21.4458 148.517 21.2502 148.333 21.1006C148.16 20.9395 147.936 20.8015 147.66 20.6864C147.384 20.5598 147.096 20.439 146.797 20.324C146.429 20.1859 146.061 20.0191 145.693 19.8235C145.336 19.6164 145.042 19.3575 144.812 19.0469C144.582 18.7247 144.467 18.3278 144.467 17.856C144.467 17.1082 144.743 16.4984 145.296 16.0267C145.848 15.5549 146.596 15.3191 147.539 15.3191C148.137 15.3191 148.672 15.4226 149.144 15.6297C149.616 15.8368 150.024 16.0727 150.37 16.3373L149.455 17.5454C149.156 17.3268 148.851 17.1542 148.54 17.0276C148.241 16.8896 147.925 16.8205 147.591 16.8205C147.165 16.8205 146.849 16.9126 146.642 17.0967C146.435 17.2693 146.331 17.4879 146.331 17.7525C146.331 18.0862 146.504 18.3393 146.849 18.5119C147.194 18.6844 147.597 18.8513 148.057 19.0123C148.448 19.1504 148.828 19.323 149.196 19.5301C149.564 19.7257 149.869 19.9846 150.111 20.3067C150.364 20.6289 150.49 21.0546 150.49 21.5838C150.49 22.3087 150.208 22.93 149.645 23.4477C149.081 23.954 148.264 24.2071 147.194 24.2071ZM152.262 24V15.5262H154.247V24H152.262ZM153.263 14.042C152.906 14.042 152.619 13.9384 152.4 13.7313C152.182 13.5242 152.072 13.2481 152.072 12.9029C152.072 12.5692 152.182 12.2989 152.4 12.0918C152.619 11.8847 152.906 11.7811 153.263 11.7811C153.62 11.7811 153.907 11.8847 154.126 12.0918C154.345 12.2989 154.454 12.5692 154.454 12.9029C154.454 13.2481 154.345 13.5242 154.126 13.7313C153.907 13.9384 153.62 14.042 153.263 14.042ZM160.248 24.2071C159.546 24.2071 158.89 24.0345 158.28 23.6894C157.671 23.3327 157.176 22.8264 156.796 22.1706C156.417 21.5033 156.227 20.7037 156.227 19.7717C156.227 18.8283 156.417 18.0286 156.796 17.3728C157.176 16.7055 157.671 16.1992 158.28 15.8541C158.89 15.4974 159.546 15.3191 160.248 15.3191C160.961 15.3191 161.623 15.4974 162.233 15.8541C162.842 16.1992 163.337 16.7055 163.717 17.3728C164.097 18.0286 164.286 18.8283 164.286 19.7717C164.286 20.7037 164.097 21.5033 163.717 22.1706C163.337 22.8264 162.842 23.3327 162.233 23.6894C161.623 24.0345 160.961 24.2071 160.248 24.2071ZM160.248 22.5848C160.869 22.5848 161.358 22.3259 161.715 21.8082C162.072 21.2904 162.25 20.6116 162.25 19.7717C162.25 18.9203 162.072 18.2357 161.715 17.718C161.358 17.2002 160.869 16.9413 160.248 16.9413C159.627 16.9413 159.138 17.2002 158.781 17.718C158.436 18.2357 158.263 18.9203 158.263 19.7717C158.263 20.6116 158.436 21.2904 158.781 21.8082C159.138 22.3259 159.627 22.5848 160.248 22.5848ZM166.251 24V15.5262H167.89L168.028 16.6652H168.097C168.477 16.297 168.891 15.9806 169.34 15.716C169.789 15.4514 170.301 15.3191 170.876 15.3191C171.785 15.3191 172.447 15.6125 172.861 16.1992C173.275 16.786 173.482 17.6144 173.482 18.6844V24H171.497V18.9433C171.497 18.2415 171.394 17.7467 171.187 17.4591C170.98 17.1715 170.64 17.0276 170.168 17.0276C169.8 17.0276 169.472 17.1197 169.185 17.3038C168.909 17.4764 168.592 17.7352 168.236 18.0804V24H166.251Z" fill="#2C3236"/>
			<path fill-rule="evenodd" clip-rule="evenodd" d="M32.9098 14.02C32.9098 12.7205 31.8563 11.6671 30.5568 11.6671H23.498C22.1985 11.6671 21.145 12.7205 21.145 14.02V18.0842C21.145 19.3837 22.1985 20.4372 23.498 20.4372H28.8444L29.8941 22.2553C30.1411 22.6832 30.7586 22.6832 31.0056 22.2553L32.7655 19.2072C32.8154 19.1207 32.8426 19.0298 32.8502 18.9398H32.9098V18.0842V17.0147V14.02ZM23.7119 14.6617C23.7119 14.3073 23.9992 14.02 24.3536 14.02H29.4873C29.8417 14.02 30.129 14.3073 30.129 14.6617C30.129 15.0162 29.8417 15.3035 29.4873 15.3035H24.3536C23.9992 15.3035 23.7119 15.0162 23.7119 14.6617ZM24.3536 16.5869C23.9992 16.5869 23.7119 16.8742 23.7119 17.2286C23.7119 17.583 23.9992 17.8703 24.3536 17.8703H29.4873C29.8417 17.8703 30.129 17.583 30.129 17.2286C30.129 16.8742 29.8417 16.5869 29.4873 16.5869H24.3536Z" fill="#2563EB"/>
			<path fill-rule="evenodd" clip-rule="evenodd" d="M28.1034 21.7206L28.4028 22.2392C27.9755 22.832 27.2791 23.218 26.4926 23.218H21.1462L20.0965 25.0362C19.8495 25.4639 19.232 25.4639 18.985 25.0362L17.2251 21.988C17.1752 21.9015 17.148 21.8106 17.1404 21.7206H17.0808V20.865V19.7955V16.8008C17.0808 15.5013 18.1343 14.4479 19.4338 14.4479H19.8616V18.0842C19.8616 20.0925 21.4896 21.7206 23.4979 21.7206H28.1034Z" fill="#8DA4E4"/>
			<defs>
			<linearGradient id="paint0_linear_207_211" x1="0.300781" y1="18" x2="72.9749" y2="18" gradientUnits="userSpaceOnUse">
			<stop stop-color="#F5F9FA"/>
			<stop offset="1" stop-color="white"/>
			</linearGradient>
			</defs>
			</svg>
	</div>

	<ul class="space-y-12">
		{#each data.snippets as snippet}
			<li class="bg-white rounded-lg shadow-md hover:shadow-lg transition-shadow duration-300">
				<div class="p-4">
					<a href={`${snippet.slug}`} class="block mb-4 hover:underline transition-colors duration-300">
						<h2 class="text-2xl font-bold transition-colors duration-300">{snippet.title}</h2>
					</a>
					<p class="text-sm text-slate-700 font-mono mb-6">{snippet.description}</p>
					{#if snippet.code}
						<CodeBlock code={snippet.code} language="sql" />
					{/if}
				</div>
			</li>
		{/each}
	</ul>
</section>