Skip to content

Commit

Permalink
doc: home page improvements
Browse files Browse the repository at this point in the history
  • Loading branch information
harlan-zw committed Jul 6, 2024
1 parent 7991426 commit 899d228
Show file tree
Hide file tree
Showing 6 changed files with 239 additions and 46 deletions.
93 changes: 79 additions & 14 deletions docs/components/Footer.vue
Original file line number Diff line number Diff line change
@@ -1,17 +1,82 @@
<template>
<UFooter :links="links">
<template #left />
<script lang="ts" setup>
<template #right>
<UColorModeButton v-if="footer?.colorMode" />
</script>

<template v-if="footer?.links">
<UButton
v-for="(link, index) of footer?.links"
:key="index"
v-bind="{ color: 'gray', variant: 'ghost', ...link }"
/>
</template>
</template>
</UFooter>
<template>
<div>
<footer class="text-sm text-gray-700 dark:text-gray-200 mt-20">
<div class="border-t border-gray-200 dark:border-gray-800">
<UContainer>
<div class="py-10 grid xl:grid-cols-3 lg:gap-20 gap-10">
<div>
<div class="mb-5">
<NuxtLink to="/" title="Home" class="flex items-end gap-1.5 font-bold text-xl text-gray-900 dark:text-white font-title">
<Logo />
</NuxtLink>
</div>
<nav>
<ul class="space-y-6">
<li>
<NuxtLink to="/docs/getting-started">
What is Nuxt Scripts?
</NuxtLink>
</li>
<li>
<NuxtLink to="/docs/getting-started/installation">
Install Nuxt Scripts
</NuxtLink>
</li>
</ul>
</nav>
</div>
<div>
<h3 class="font-bold mb-5">
Top Guides
</h3>
<nav>
<ul class="grid grid-cols-2 gap-6">
<li v-for="(module, key) in modules" :key="key">
<NuxtLink :to="module.to">
<Icon :name="module.icon" />
{{ module.label }}
</NuxtLink>
</li>
</ul>
</nav>
</div>
<div>
<div class="bg-gray-50 dark:bg-gray-900 flex rounded-xl shadow p-5">
<div>
<div class="mb-2">
Hey <Icon name="noto:waving-hand" /> My name is <a href="https://harlanzw.com" target="_blank" class="underline">Harlan</a> and I'm the lead developer and maintainer of Nuxt Scripts.
</div>
<div>
Like the module? Let me know!
</div>
</div>
<div class="gap-3">
<img alt="Harlan Wilton" loading="lazy" src="https://avatars.githubusercontent.com/u/5326365?v=4" class="mx-auto rounded-full w-10 h-10 mb-3">
<div class="flex justify-center items-center">
<UButton color="white" title="Twitter" variant="link" to="https://twitter.com/harlan_zw" target="_blank">
<Icon name="i-ph-twitter-logo-duotone" class="text-xl" />
</UButton>
<UButton color="white" title="GitHub" aria-label="GitHub" variant="link" to="https://github.com/harlan-zw" target="_blank">
<Icon name="i-ph-github-logo-duotone" class="text-xl" />
</UButton>
</div>
</div>
</div>
</div>
</div>
</UContainer>
</div>
<div class="border-t border-gray-200 dark:border-gray-800">
<UContainer>
<div class="py-10">
Copyright © {{ new Date().getFullYear() }} Nuxt Team - <a href="https://github.com/nuxt/scripts/blob/main/LICENSE">MIT License</a>
</div>
</UContainer>
</div>
</footer>
</div>
</template>
33 changes: 33 additions & 0 deletions docs/components/ShowcaseCard.vue
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
<script lang="ts" setup>
defineProps<{ label: string, description: string }>()
</script>

<template>
<div class="relative h-full">
<div class="h-full">
<div class="group relative border hover:border-blue-400 dark:border-gray-800 transition rounded-xl overflow-hidden h-full">
<div
class="h-48 relative flex items-center justify-center bg-no-repeat bg-cover border-b-2 border-gray-100/30 dark:border-gray-900/10"
style="background-image: url('/grid.png')"
>
<div
class="blur-overlay w-full h-full absolute pointer-events-none"
/>
<div class="z-10 text-blue-200 group-hover:scale-110 w-full h-full flex items-center justify-center group-hover:text-blue-500 transition-all relative">
<slot />
</div>
<slot name="teleport" />
</div>

<div class="p-4">
<h3 class="font-semibold">
{{ label }}
</h3>
<p class="text-sm mt-1 text-gray-400 leading-[22px]">
{{ description }}
</p>
</div>
</div>
</div>
</div>
</template>
11 changes: 11 additions & 0 deletions docs/content/_cookie-api.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
```vue
<script lang="ts" setup>
const cookieConsent = useScriptTriggerConsent()
const { $script, gtag } = useScript('/my-script.js', {
trigger: cookieConsent
})
</script>
<template>
<CookieConsent @accept="cookieConsent.accept()" />
</template>
```
12 changes: 12 additions & 0 deletions docs/content/_magic-api.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
```vue
<script lang="ts" setup>
const { $script, gtag } = useScriptGoogleAnalytics(
{ id: 'G-1234567' },
{ trigger: 'manual' }
)
// send events
gtag('config', 'UA-123456789-1')
// ..
$script.load() // load the script
</script>
```
136 changes: 104 additions & 32 deletions docs/pages/index.vue
Original file line number Diff line number Diff line change
Expand Up @@ -150,6 +150,24 @@ const benchmarks = {
si: 3900,
},
},
intercom: {
logo: registry.find(s => s.import?.name === 'useScriptIntercom').logo,
label: 'Intercom',
nuxt: {
link: 'https://scripts-phi.vercel.app/third-parties/intercom/nuxt-scripts',
fcp: 1400,
tbt: 220,
lcp: 1400,
si: 1900,
},
iframe: {
link: 'https://scripts-phi.vercel.app/third-parties/intercom/default',
fcp: 1400,
tbt: 850,
lcp: 1400,
si: 2800,
},
},
}
const webVital = ref('tbt')
Expand All @@ -166,6 +184,8 @@ function timesFaster(nuxt: number, iframe: number) {
// should display as 2.5 for 2500%
return (iframe / nuxt).toFixed(1)
}
const { data } = await useAsyncData('code-example', () => queryContent('/_magic-api').findOne())
const { data: data2 } = await useAsyncData('code-example2', () => queryContent('/_cookie-api').findOne())
const contributors = useRuntimeConfig().public.contributors
</script>
Expand Down Expand Up @@ -208,23 +228,39 @@ const contributors = useRuntimeConfig().public.contributors
</div>
</ULandingHero>

<ULandingSection :ui="{ wrapper: 'py-6 sm:py-12' }">
<ULandingSection :ui="{ wrapper: 'pt-0 py-6 sm:py-14' }">
<ul class="grid grid-cols-1 gap-x-6 gap-y-10 sm:grid-cols-2 lg:grid-cols-4 lg:gap-x-8 lg:gap-y-16">
<li v-for="feature in features" :key="feature.name" class="flex flex-col gap-y-2">
<UIcon :name="feature.icon" class="h-8 w-8 shrink-0 text-primary" />
<div class="flex flex-col gap-y-1">
<h5 class="font-medium text-gray-900 dark:text-white">
{{ feature.name }}
</h5>
<p class="text-gray-500 dark:text-gray-400">
{{ feature.description }}
</p>
</div>
</li>
<ShowcaseCard v-for="feature in features" :key="feature.name" :label="feature.name" :description="feature.description">
<UIcon :name="feature.icon" class="h-20 w-20 shrink-0 text-primary" />
</ShowcaseCard>
</ul>
</ULandingSection>

<UContainer class="py-6 sm:py-20 gap-8 lg:gap-20 mb-12 flex flex-col xl:flex-row ">
<ULandingSection :ui="{ wrapper: 'pt-0 py-6 sm:py-14' }">
<div class="xl:flex items-center justify-between gap-12">
<div class="max-w-lg">
<UIcon name="i-ph-magic-wand-duotone" class="h-[100px] w-[100px] text-primary" />
<h2 class="text-xl xl:text-4xl font-bold mb-4">
A powerful API with <span class="italic">just enough</span> magic
</h2>
<p class="text-gray-500 dark:text-gray-400 mb-3">
Nuxt Scripts provides an abstraction layer on top of third-party scripts, providing SSR support and type-safety and
while still giving you full low-level control over how a script is loaded.
</p>
</div>
<UCard>
<div class="padded-code xl:col-span-7 hidden sm:block">
<div class="flex justify-center xl:justify-end">
<div class="flex relative items-center bg-gradient-to-br to-green-200/50 from-blue-100/50 dark:from-green-500/10 dark:to-blue-500/20 rounded">
<ContentRenderer :value="data" class="xl:col-span-6 max-w-full" />
</div>
</div>
</div>
</UCard>
</div>
</ULandingSection>

<UContainer class="py-6 sm:py-20 gap-8 lg:gap-20 flex flex-col xl:flex-row ">
<div class="max-w-lg">
<UIcon name="i-ph-speedometer-duotone" class="h-[100px] w-[100px] text-primary" />
<h2 class="text-xl xl:text-4xl font-bold flex items-center gap-4 mb-4">
Expand All @@ -245,7 +281,7 @@ const contributors = useRuntimeConfig().public.contributors
<div class="flex flex-col lg:grid grid-cols-2 mb-8 gap-8">
<div v-for="(benchmark, key) in benchmarks" :key="key">
<h3 class="md:text-xl font-bold flex items-center gap-3 mb-5">
<div class="logo h-auto w-7" v-html="benchmark.logo" />
<div class="logo h-auto w-7 max-h-7" v-html="benchmark.logo" />
{{ benchmark.label }}
</h3>
<div class="mb-3">
Expand Down Expand Up @@ -293,33 +329,66 @@ const contributors = useRuntimeConfig().public.contributors
</p>
</div>
</UContainer>
<ULandingSection :ui="{ wrapper: 'py-6 sm:py-12' }">
<div class="xl:flex items-center gap-12 mx-auto">

<ULandingSection :ui="{ wrapper: 'pt-0 py-6 sm:py-14' }">
<div class="xl:flex items-center justify-between gap-12">
<div class="max-w-lg">
<h2 class="text-xl xl:text-4xl font-bold flex items-center gap-4 mb-4">
<UIcon name="i-ph-handshake-duotone" class="h-12 w-12 shrink-0 text-primary" />
<span>A collaboration in making the web faster</span>
<UIcon name="i-ph-cookie-duotone" class="h-[100px] w-[100px] text-primary" />
<h2 class="text-xl xl:text-4xl font-bold mb-4">
Cookie consent that's good enough to eat
</h2>
<p class="text-gray-500 dark:text-gray-400 mb-1">
Nuxt Scripts was designed and built by the Nuxt core team in collaboration with the <a href="https://developer.chrome.com/aurora" target="_blank" class="underline">Chrome Aurora</a> team at Google.
<p class="text-gray-500 dark:text-gray-400 mb-3">
Nuxt Scripts aims to improve end-user privacy by providing a <NuxtLink to="/docs/guide/consent" class="underline">
simple API for managing cookie consent
</NuxtLink>.
</p>
<p class="text-gray-500 dark:text-gray-400 mb-1">
It's being actively maintained by the Nuxt core team and amazing community contributors.
<p class="text-gray-500 dark:text-gray-400 mb-3">
All scripts can be loaded conditionally based on user consent, set it up however you need.
</p>
</div>
<UCard>
<div class="padded-code xl:col-span-7 hidden sm:block">
<div class="flex justify-center xl:justify-end">
<div class="flex relative items-center bg-gradient-to-br to-green-200/50 from-blue-100/50 dark:from-green-500/10 dark:to-blue-500/20 rounded">
<ContentRenderer :value="data2" class="xl:col-span-6 max-w-full" />
</div>
</div>
</div>
</UCard>
</div>
</ULandingSection>

<ULandingSection :ui="{ wrapper: 'py-6 sm:py-12' }">
<div class="xl:flex items-center gap-12">
<div>
<div class="xl:flex justify-center items-center gap-3 mb-8">
<div class="font-light text-6xl mb-2">
<Icon name="carbon:user-favorite-alt" />
{{ contributors.length }}
<div class="max-w-lg">
<UIcon name="i-ph-handshake-duotone" class="h-[100px] w-[100px] text-primary" />
<h2 class="text-xl xl:text-4xl font-bold flex items-center gap-4 mb-4">
<span>A faster web collaboration</span>
</h2>
<p class="text-gray-500 dark:text-gray-400 mb-4">
Nuxt Scripts was designed and built by the Nuxt core team in collaboration with the <a href="https://developer.chrome.com/aurora" target="_blank" class="underline">Chrome Aurora</a> team at Google.
</p>
<p class="text-gray-500 dark:text-gray-400 mb-1">
Nuxt Scripts is being actively maintained by the Nuxt core team and amazing community contributors, we welcome all contributions.
</p>
</div>
</div>
<div class="flex-grow">
<div class="max-w-lg flex flex-col items-center">
<div class="xl:flex justify-center items-center gap-3 mb-8">
<div class="font-light text-6xl mb-2">
<Icon name="carbon:user-favorite-alt" />
{{ contributors.length }}
</div>
<div class="text-sm opacity-80">
Contributors
</div>
</div>
<div class="text-sm opacity-80">
Contributors
<div class="mb-7 gap-2 mx-auto text-center grid grid-cols-4 sm:grid-cols-7">
<UAvatar v-for="(c, index) in contributors" :key="index" :alt="`GitHub User ${c}`" size="xl" height="45" width="45" loading="lazy" :src="`https://avatars.githubusercontent.com/u/${c}?s=80&v=4`" />
</div>
</div>
<div class="mb-7 gap-2 mx-auto text-center grid grid-cols-4 sm:grid-cols-7">
<UAvatar v-for="(c, index) in contributors" :key="index" :alt="`GitHub User ${c}`" size="xl" height="45" width="45" loading="lazy" :src="`https://avatars.githubusercontent.com/u/${c}?s=80&v=4`" />
</div>
</div>
</div>
</ULandingSection>
Expand Down Expand Up @@ -432,4 +501,7 @@ const contributors = useRuntimeConfig().public.contributors
filter: drop-shadow(0px 1px 4px rgba(56,239,125, 0.5));
}
}
.padded-code pre {
padding: 0.75em 1em;
}
</style>
Binary file added docs/public/grid.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.

0 comments on commit 899d228

Please sign in to comment.