file_path
stringlengths
3
280
file_language
stringclasses
66 values
content
stringlengths
1
1.04M
repo_name
stringlengths
5
92
repo_stars
int64
0
154k
repo_description
stringlengths
0
402
repo_primary_language
stringclasses
108 values
developer_username
stringlengths
1
25
developer_name
stringlengths
0
30
developer_company
stringlengths
0
82
layer/components/Lego/Tweet/Action/Copy.vue
Vue
<script setup lang="ts"> import key from '../.keys' import { copiedKey } from './.keys' const tweet = inject(key) const tweetUrl = computed(() => (tweet?.value ? getTweetUrl(tweet.value) : '')) const { copy, copied } = useClipboard({ source: tweetUrl }) provide(copiedKey, copied) </script> <template> <button v-if="tweet" @click="copy()"> <slot :copied="copied"> <LegoTweetActionCopyIcon /> <span> {{ copied ? "Copied!" : "Copy link" }} </span> </slot> </button> </template>
zernonia/nuxt-lego
234
NuxtLego is an open source UI component layer for building your Nuxt content quick & beautiful.
Vue
zernonia
zernonia
Troop Travel
layer/components/Lego/Tweet/Action/CopyIcon.vue
Vue
<script setup lang="ts"> import { copiedKey } from './.keys' const copied = inject(copiedKey, ref(false)) </script> <script lang="ts"> export default { inheritAttrs: false, } </script> <template> <div> <svg v-if="copied" v-bind="$attrs" viewBox="0 0 24 24" aria-hidden="true" fill="currentColor" > <g> <path d="M9.64 18.952l-5.55-4.861 1.317-1.504 3.951 3.459 8.459-10.948L19.4 6.32 9.64 18.952z" /> </g> </svg> <svg v-else v-bind="$attrs" fill="currentColor" viewBox="0 0 24 24" aria-hidden="true" > <g> <path d="M18.36 5.64c-1.95-1.96-5.11-1.96-7.07 0L9.88 7.05 8.46 5.64l1.42-1.42c2.73-2.73 7.16-2.73 9.9 0 2.73 2.74 2.73 7.17 0 9.9l-1.42 1.42-1.41-1.42 1.41-1.41c1.96-1.96 1.96-5.12 0-7.07zm-2.12 3.53l-7.07 7.07-1.41-1.41 7.07-7.07 1.41 1.41zm-12.02.71l1.42-1.42 1.41 1.42-1.41 1.41c-1.96 1.96-1.96 5.12 0 7.07 1.95 1.96 5.11 1.96 7.07 0l1.41-1.41 1.42 1.41-1.42 1.42c-2.73 2.73-7.16 2.73-9.9 0-2.73-2.74-2.73-7.17 0-9.9z" /> </g> </svg> </div> </template>
zernonia/nuxt-lego
234
NuxtLego is an open source UI component layer for building your Nuxt content quick & beautiful.
Vue
zernonia
zernonia
Troop Travel
layer/components/Lego/Tweet/Action/Love.vue
Vue
<script setup lang="ts"> import { getLikeUrl } from 'lego/utils/twitter' import key from '../.keys' const tweet = inject(key) const favoriteCount = computed(() => tweet?.value.favorite_count ? formatNumber(tweet?.value.favorite_count) : 0, ) </script> <template> <a v-if="tweet" :href="getLikeUrl(tweet)" target="_blank" rel="noopener noreferrer" > <slot :favorite_count="favoriteCount"> <LegoTweetActionLoveIcon /> <span>{{ favoriteCount }}</span> </slot> </a> </template>
zernonia/nuxt-lego
234
NuxtLego is an open source UI component layer for building your Nuxt content quick & beautiful.
Vue
zernonia
zernonia
Troop Travel
layer/components/Lego/Tweet/Action/LoveIcon.vue
Vue
<script setup lang="ts"></script> <template> <svg viewBox="0 0 24 24" fill="currentColor" aria-hidden="true"> <g> <path d="M20.884 13.19c-1.351 2.48-4.001 5.12-8.379 7.67l-.503.3-.504-.3c-4.379-2.55-7.029-5.19-8.382-7.67-1.36-2.5-1.41-4.86-.514-6.67.887-1.79 2.647-2.91 4.601-3.01 1.651-.09 3.368.56 4.798 2.01 1.429-1.45 3.146-2.1 4.796-2.01 1.954.1 3.714 1.22 4.601 3.01.896 1.81.846 4.17-.514 6.67z" /> </g> </svg> </template>
zernonia/nuxt-lego
234
NuxtLego is an open source UI component layer for building your Nuxt content quick & beautiful.
Vue
zernonia
zernonia
Troop Travel
layer/components/Lego/Tweet/Action/Reply.vue
Vue
<script setup lang="ts"> import { getReplyUrl } from 'lego/utils/twitter' import key from '../.keys' const tweet = inject(key) </script> <template> <a v-if="tweet" :href="getReplyUrl(tweet)" target="_blank" rel="noopener noreferrer" aria-label="Reply to this Tweet on Twitter" > <slot> <LegoTweetActionReplyIcon /> <span>Reply</span> </slot> </a> </template>
zernonia/nuxt-lego
234
NuxtLego is an open source UI component layer for building your Nuxt content quick & beautiful.
Vue
zernonia
zernonia
Troop Travel
layer/components/Lego/Tweet/Action/ReplyIcon.vue
Vue
<script setup lang="ts"></script> <template> <svg viewBox="0 0 24 24" aria-hidden="true" fill="currentColor"> <g> <path d="M1.751 10c0-4.42 3.584-8 8.005-8h4.366c4.49 0 8.129 3.64 8.129 8.13 0 2.96-1.607 5.68-4.196 7.11l-8.054 4.46v-3.69h-.067c-4.49.1-8.183-3.51-8.183-8.01z" /> </g> </svg> </template>
zernonia/nuxt-lego
234
NuxtLego is an open source UI component layer for building your Nuxt content quick & beautiful.
Vue
zernonia
zernonia
Troop Travel
layer/components/Lego/Tweet/CreatedAt.vue
Vue
<script setup lang="ts"> import { getTweetUrl } from 'lego/utils/twitter' import key from './.keys' const tweet = inject(key) const createdAt = computed(() => tweet?.value.created_at ? new Date(tweet.value.created_at) : undefined, ) const formatted = useDateFormat(createdAt, 'h:mm a · MMM D, YYYY') </script> <template> <a v-if="tweet?.created_at" :href="getTweetUrl(tweet)" target="_blank" rel="noopener noreferrer" :aria-label="formatted" > <slot :created_at="createdAt"> <time :dateTime="createdAt?.toISOString()"> {{ formatted }} </time> </slot> </a> </template>
zernonia/nuxt-lego
234
NuxtLego is an open source UI component layer for building your Nuxt content quick & beautiful.
Vue
zernonia
zernonia
Troop Travel
layer/components/Lego/Tweet/Link.vue
Vue
<script setup lang="ts"> defineProps<{ href: string }>() </script> <template> <a :href="href" target="_blank" rel="noopener noreferrer"><slot /></a> </template>
zernonia/nuxt-lego
234
NuxtLego is an open source UI component layer for building your Nuxt content quick & beautiful.
Vue
zernonia
zernonia
Troop Travel
layer/components/Lego/Tweet/Media.vue
Vue
<script setup lang="ts"> import key from './.keys' const tweet = inject(key) const mediaDetails = computed(() => tweet?.value?.mediaDetails ?? []) const gridClass = computed(() => { const length = mediaDetails.value.length if (length >= 4) return 'grid-2x2' else if (length === 3) return 'grid-3' else if (length > 1) return 'grid-2-columns' }) </script> <template> <div v-if="mediaDetails.length" :class="gridClass"> <template v-for="(media, index) in mediaDetails" :key="index"> <LegoTweetMediaPhoto v-if="media.type === 'photo'" :media="media" /> <LegoTweetMediaVideo v-if="media.type === 'video'" :media="media" /> </template> </div> </template> <style> .grid-3 { display: grid; grid-template-columns: repeat(2, 1fr); grid-template-rows: repeat(2, 145px); grid-gap: 1px; } .grid-3 > :first-child { grid-row: span 2; } .grid-2x2 { display: grid; grid-template-columns: repeat(2, 1fr); grid-template-rows: repeat(2, 145px); grid-gap: 1px; } .grid-2-columns { display: grid; grid-template-columns: repeat(2, 1fr); grid-gap: 1px; } </style>
zernonia/nuxt-lego
234
NuxtLego is an open source UI component layer for building your Nuxt content quick & beautiful.
Vue
zernonia
zernonia
Troop Travel
layer/components/Lego/Tweet/Media/Photo.vue
Vue
<script setup lang="ts"> import type { MediaPhoto } from 'lego/types' import { getMediaUrl } from 'lego/utils/twitter' defineProps<{ media: MediaPhoto }>() </script> <template> <img style="object-fit: cover; height: 100%; width: 100%" :src="getMediaUrl(media, 'small')" > </template>
zernonia/nuxt-lego
234
NuxtLego is an open source UI component layer for building your Nuxt content quick & beautiful.
Vue
zernonia
zernonia
Troop Travel
layer/components/Lego/Tweet/Media/Video.vue
Vue
<script setup lang="ts"> import type { MediaVideo } from 'lego/types' import { getMediaUrl } from 'lego/utils/twitter' defineProps<{ media: MediaVideo }>() </script> <template> <video v-if="media" :poster="getMediaUrl(media, 'small')" draggable muted preload="metadata" > <source :src="media.url" :type="media.video_info.variants?.[0].content_type" > </video> </template>
zernonia/nuxt-lego
234
NuxtLego is an open source UI component layer for building your Nuxt content quick & beautiful.
Vue
zernonia
zernonia
Troop Travel
layer/components/Lego/Tweet/Replies.vue
Vue
<script setup lang="ts"> import { formatNumber, getTweetUrl } from 'lego/utils/twitter' import key from './.keys' const tweet = inject(key) </script> <template> <a v-if="tweet" :href="getTweetUrl(tweet)" target="_blank" rel="noopener noreferrer" > <slot :conversation_count="tweet.conversation_count"> <span>{{ tweet.conversation_count > 0 ? `Read ${formatNumber(tweet.conversation_count)} replies` : "Read more on Twitter" }} </span> </slot> </a> </template>
zernonia/nuxt-lego
234
NuxtLego is an open source UI component layer for building your Nuxt content quick & beautiful.
Vue
zernonia
zernonia
Troop Travel
layer/components/Lego/Tweet/SummaryCard.vue
Vue
<script setup lang="ts"> import key from './.keys' const tweet = inject(key) const card = computed(() => tweet?.value?.card) const isLargeSummaryCard = computed( () => card.value?.name === 'summary_large_image', ) const image = computed(() => isLargeSummaryCard.value ? card.value?.binding_values?.summary_photo_image?.image_value : card.value?.binding_values?.thumbnail_image?.image_value, ) const info = computed(() => ({ domain: card.value?.binding_values.domain.string_value, title: card.value?.binding_values.title.string_value, description: card.value?.binding_values.description.string_value, })) </script> <template> <div v-if="card && image && info"> <LegoTweetLink :href="card?.url" :class="{ is_small_card: !isLargeSummaryCard }" > <img :style="{ height: image.height, width: image.width, }" :src="image.url" :alt="card?.name" > <slot :domain="info.domain" :title="info.title" :description="info.description" :is_large_summary_card="isLargeSummaryCard" > <p>{{ info?.domain }}</p> <p>{{ info?.title }}</p> <p>{{ info?.description }}</p> </slot> </LegoTweetLink> </div> </template> <style> .is_small_card { display: flex; align-items: center; } </style>
zernonia/nuxt-lego
234
NuxtLego is an open source UI component layer for building your Nuxt content quick & beautiful.
Vue
zernonia
zernonia
Troop Travel
layer/components/Lego/Tweet/Terms.vue
Vue
<script setup lang="ts"></script> <template> <a target="_blank" rel="noopener noreferrer" href="https://help.twitter.com/en/twitter-for-websites-ads-info-and-privacy" > <svg fill="currentColor" width="20" height="20" viewBox="0 0 24 24" aria-hidden="true" > <g> <path d="M13.5 8.5c0 .83-.67 1.5-1.5 1.5s-1.5-.67-1.5-1.5S11.17 7 12 7s1.5.67 1.5 1.5zM13 17v-5h-2v5h2zm-1 5.25c5.66 0 10.25-4.59 10.25-10.25S17.66 1.75 12 1.75 1.75 6.34 1.75 12 6.34 22.25 12 22.25zM20.25 12c0 4.56-3.69 8.25-8.25 8.25S3.75 16.56 3.75 12 7.44 3.75 12 3.75s8.25 3.69 8.25 8.25z" /> </g> </svg> </a> </template>
zernonia/nuxt-lego
234
NuxtLego is an open source UI component layer for building your Nuxt content quick & beautiful.
Vue
zernonia
zernonia
Troop Travel
layer/components/Lego/Tweet/Text.vue
Vue
<script setup lang="ts"> import { h } from 'vue' import type { HashtagEntity, Indices, MediaEntity, SymbolEntity, Tweet, UrlEntity, UserMentionEntity, } from 'lego/types' import { getHashtagUrl, getSymbolUrl, getUserUrl } from 'lego/utils/twitter' import key from './.keys' import LegoTweetLink from './Link.vue' const props = defineProps<{ linkClass?: string }>() const tweet = inject(key) interface TextEntity { indices: Indices type: 'text' } type Entity = | TextEntity | (HashtagEntity & { type: 'hashtag' }) | (UserMentionEntity & { type: 'mention' }) | (UrlEntity & { type: 'url' }) | (MediaEntity & { type: 'media' }) | (SymbolEntity & { type: 'symbol' }) function addEntities( result: Entity[], entities: (HashtagEntity | UserMentionEntity | MediaEntity | SymbolEntity)[], type: Entity['type'], ) { for (const entity of entities) { for (const [i, item] of result.entries()) { if ( entity.indices[0] < item.indices[0] || entity.indices[1] > item.indices[1] ) continue const items = [{ ...entity, type }] as Entity[] if (item.indices[0] < entity.indices[0]) { items.unshift({ indices: [item.indices[0], entity.indices[0]], type: 'text', }) } if (item.indices[1] > entity.indices[1]) { items.push({ indices: [entity.indices[1], item.indices[1]], type: 'text', }) } result.splice(i, 1, ...items) break // Break out of the loop to avoid iterating over the new items } } } function getEntities(tweet: Tweet) { const result: Entity[] = [ { indices: tweet.display_text_range, type: 'text' }, ] addEntities(result, tweet.entities.hashtags, 'hashtag') addEntities(result, tweet.entities.user_mentions, 'mention') addEntities(result, tweet.entities.urls, 'url') addEntities(result, tweet.entities.symbols, 'symbol') if (tweet.entities.media) addEntities(result, tweet.entities.media, 'media') return result } const entities = computed(() => { if (!tweet?.value) return const parsedEntities = getEntities(tweet.value) // Update display_text_range to work w/ Array.from // Array.from is unicode aware, unlike string.slice() if ( tweet.value.entities.media && tweet.value.entities.media[0].indices[0] < tweet.value.display_text_range[1] ) { tweet.value.display_text_range[1] = tweet.value.entities.media[0].indices[0] } const lastEntity = parsedEntities.at(-1) if (lastEntity && lastEntity.indices[1] > tweet.value.display_text_range[1]) lastEntity.indices[1] = tweet.value.display_text_range[1] return parsedEntities }) function render() { return h('div', { style: 'white-space: break-spaces' }, [ (tweet?.value && entities.value) ? entities.value?.map((item, i) => { const text = Array.from(tweet.value.text) .splice(item.indices[0], item.indices[1] - item.indices[0]) .join('') switch (item.type) { case 'hashtag': return h( LegoTweetLink, { key: i, class: props.linkClass, href: getHashtagUrl(item) }, text, ) case 'mention': return h( LegoTweetLink, { key: i, class: props.linkClass, href: getUserUrl(item.screen_name), }, text, ) case 'url': return h( LegoTweetLink, { key: i, class: props.linkClass, href: item.expanded_url }, item.display_url, ) case 'symbol': return h( LegoTweetLink, { key: i, class: props.linkClass, href: getSymbolUrl(item) }, text, ) case 'media': // Media text is currently never displayed, some tweets however might have indices // that do match `display_text_range` so for those cases we ignore the content. return undefined default: return h('span', text) } }) : h(''), ]) } </script> <template> <render /> </template>
zernonia/nuxt-lego
234
NuxtLego is an open source UI component layer for building your Nuxt content quick & beautiful.
Vue
zernonia
zernonia
Troop Travel
layer/components/Lego/Tweet/User.vue
Vue
<script setup lang="ts"> import key from './.keys' const tweet = inject(key) const user = computed(() => tweet?.value?.user) </script> <template> <div v-if="user"> <slot :user="user"> <LegoTweetUserAvatar /> <p>{{ user.name }}</p> <p>@{{ user.screen_name }}</p> </slot> </div> </template>
zernonia/nuxt-lego
234
NuxtLego is an open source UI component layer for building your Nuxt content quick & beautiful.
Vue
zernonia
zernonia
Troop Travel
layer/components/Lego/Tweet/User/Avatar.vue
Vue
<script setup lang="ts"> import key from '../.keys' const tweet = inject(key) const user = computed(() => tweet?.value?.user) </script> <template> <div v-if="user"> <img :style="{ 'border-radius': user.profile_image_shape === 'Square' ? '5px' : '99999px', }" :src="user.profile_image_url_https" :alt="user.name" > <slot :verified="user.verified || user.is_blue_verified"> <Icon v-if="user.verified || user.is_blue_verified" name="material-symbols:verified-rounded" /> </slot> </div> </template>
zernonia/nuxt-lego
234
NuxtLego is an open source UI component layer for building your Nuxt content quick & beautiful.
Vue
zernonia
zernonia
Troop Travel
layer/components/Lego/Tweet/index.vue
Vue
<script setup lang="ts"> // reference from: https://github.com/vercel-labs/react-tweet/ import { getTweetUrl } from 'lego/utils/twitter' import key from './.keys' const props = defineProps<{ tweetId: string }>() const { data, error, pending } = useFetch(`/api/get-tweet/${props.tweetId}`) provide(key, data) const url = computed(() => (data?.value ? getTweetUrl(data.value) : '')) </script> <template> <div> <slot :valid="!error" :url="url" :pending="pending"> <LegoTweetUser /> <LegoTweetText /> <LegoTweetMedia /> <LegoTweetCreatedAt /> <LegoTweetAction /> <LegoTweetReplies /> </slot> </div> </template>
zernonia/nuxt-lego
234
NuxtLego is an open source UI component layer for building your Nuxt content quick & beautiful.
Vue
zernonia
zernonia
Troop Travel
layer/components/Lego/WebsiteCard/.keys.ts
TypeScript
import type { InjectionKey, Ref } from "vue"; import type { MetaTags } from "../../../types/metatags"; export default Symbol() as InjectionKey<Ref<MetaTags | null>>;
zernonia/nuxt-lego
234
NuxtLego is an open source UI component layer for building your Nuxt content quick & beautiful.
Vue
zernonia
zernonia
Troop Travel
layer/components/Lego/WebsiteCard/Description.vue
Vue
<script setup lang="ts"> import key from './.keys' const bookmark = inject(key) const description = computed(() => bookmark?.value?.description) </script> <template> <div> <slot :description="description"> {{ description }} </slot> </div> </template>
zernonia/nuxt-lego
234
NuxtLego is an open source UI component layer for building your Nuxt content quick & beautiful.
Vue
zernonia
zernonia
Troop Travel
layer/components/Lego/WebsiteCard/Image.vue
Vue
<script setup lang="ts"> import key from './.keys' const bookmark = inject(key) const image = computed(() => bookmark?.value?.image) </script> <template> <img v-if="image" :src="image"> </template>
zernonia/nuxt-lego
234
NuxtLego is an open source UI component layer for building your Nuxt content quick & beautiful.
Vue
zernonia
zernonia
Troop Travel
layer/components/Lego/WebsiteCard/Title.vue
Vue
<script setup lang="ts"> import key from './.keys' const bookmark = inject(key) const title = computed(() => bookmark?.value?.title) </script> <template> <div> <slot :title="title"> {{ title }} </slot> </div> </template>
zernonia/nuxt-lego
234
NuxtLego is an open source UI component layer for building your Nuxt content quick & beautiful.
Vue
zernonia
zernonia
Troop Travel
layer/components/Lego/WebsiteCard/Url.vue
Vue
<script setup lang="ts"> import key from './.keys' const bookmark = inject(key) const url = computed(() => bookmark?.value?.url) </script> <template> <div> <slot :url="url"> {{ url }} </slot> </div> </template>
zernonia/nuxt-lego
234
NuxtLego is an open source UI component layer for building your Nuxt content quick & beautiful.
Vue
zernonia
zernonia
Troop Travel
layer/components/Lego/WebsiteCard/index.vue
Vue
<script setup lang="ts"> import key from './.keys' const props = defineProps<{ url: string }>() const { data, error, pending } = useFetch('/api/get-metatags', { method: 'POST', body: { url: props.url, }, }) provide(key, data) </script> <template> <div> <slot :title="data?.title" :description="data?.description" :image="data?.image" :url="url" :valid="!error" :pending="pending" > <LegoWebsiteCardTitle /> <LegoWebsiteCardDescription /> <LegoWebsiteCardUrl /> <LegoWebsiteCardImage /> </slot> </div> </template>
zernonia/nuxt-lego
234
NuxtLego is an open source UI component layer for building your Nuxt content quick & beautiful.
Vue
zernonia
zernonia
Troop Travel
layer/nuxt.config.ts
TypeScript
import { fileURLToPath } from 'node:url' import { dirname } from 'node:path' const currentDir = dirname(fileURLToPath(import.meta.url)) // https://v3.nuxtjs.org/api/configuration/nuxt.config export default defineNuxtConfig({ modules: ['nuxt-icon', '@vueuse/nuxt'], alias: { lego: currentDir, }, })
zernonia/nuxt-lego
234
NuxtLego is an open source UI component layer for building your Nuxt content quick & beautiful.
Vue
zernonia
zernonia
Troop Travel
layer/server/api/get-github-stars/index.get.ts
TypeScript
import { getQuery } from 'h3' import type { GitHubRepo } from '../../../types' import { cachedGitHubRepo } from '#imports' export default defineEventHandler(async (event) => { const repoWithOwner = getQuery(event).repo if (!repoWithOwner) return sendError(event, new Error('Missing repo name.')) // use ungh to fetch the statrs const repo = await cachedGitHubRepo(repoWithOwner).catch({ stars: 0 }) as GitHubRepo return repo.stars })
zernonia/nuxt-lego
234
NuxtLego is an open source UI component layer for building your Nuxt content quick & beautiful.
Vue
zernonia
zernonia
Troop Travel
layer/server/api/get-metatags/index.post.ts
TypeScript
interface MetaTags { [key: string]: string } export default defineEventHandler(async (event) => { const { url } = await readBody(event) if (!url) return sendError(event, new Error('Missing url')) const html = await $fetch<string>(url, { responseType: 'text' }) const metaTags: MetaTags = {} const metaTagRegExp = /<meta\s+(?:name|property)="([^"]+)"\s+content="([^"]+)"\s*\/?>/g let match // eslint-disable-next-line no-cond-assign while ((match = metaTagRegExp.exec(html))) { const tagName = match[1] const tagContent = match[2] metaTags[tagName] = tagContent } const titleRegExp = /<title>([^<]*)<\/title>/i const titleTag = titleRegExp.exec(html) const title = titleTag?.[1] || metaTags['og:title'] || metaTags['twitter:title'] const description = metaTags.description || metaTags['og:description'] || metaTags['twitter:description'] const image = metaTags['og:image'] || metaTags['twitter:image'] return { title, description, image, url, } })
zernonia/nuxt-lego
234
NuxtLego is an open source UI component layer for building your Nuxt content quick & beautiful.
Vue
zernonia
zernonia
Troop Travel
layer/server/api/get-tweet/[tweetId].get.ts
TypeScript
import type { Tweet } from '../../../types' export default defineEventHandler(async (event) => { const tweetId = event.context.params?.tweetId if (!tweetId) return sendError(event, new Error('Missing tweetId')) const SYNDICATION_URL = 'https://cdn.syndication.twimg.com' const url = new URL(`${SYNDICATION_URL}/tweet-result`) url.searchParams.set('id', tweetId) url.searchParams.set('lang', 'en') url.searchParams.set( 'features', [ 'tfw_timeline_list:', 'tfw_follower_count_sunset:true', 'tfw_tweet_edit_backend:on', 'tfw_refsrc_session:on', 'tfw_show_business_verified_badge:on', 'tfw_duplicate_scribes_to_settings:on', 'tfw_show_blue_verified_badge:on', 'tfw_legacy_timeline_sunset:true', 'tfw_show_gov_verified_badge:on', 'tfw_show_business_affiliate_badge:on', 'tfw_tweet_edit_frontend:on', ].join(';'), ) const result = await $fetch<Tweet>(url.toString(), { responseType: 'json' }) if (result.text) return result else return sendError(event, new Error('something wrong')) })
zernonia/nuxt-lego
234
NuxtLego is an open source UI component layer for building your Nuxt content quick & beautiful.
Vue
zernonia
zernonia
Troop Travel
layer/server/utils/github.ts
TypeScript
import { cachedFunction } from '#imports' export const cachedGitHubRepo = cachedFunction(async (repo: string) => { return (await $fetch(`https://ungh.cc/repos/${repo}`)).repo }, { maxAge: 60 * 60, name: 'github-repo', getKey: (repo: string) => repo, })
zernonia/nuxt-lego
234
NuxtLego is an open source UI component layer for building your Nuxt content quick & beautiful.
Vue
zernonia
zernonia
Troop Travel
layer/types/github.ts
TypeScript
export interface GitHubRepo { id: number name: string repo: string description: string createdAt: string updatedAt: string pushedAt: string stars: number watchers: number forks: number }
zernonia/nuxt-lego
234
NuxtLego is an open source UI component layer for building your Nuxt content quick & beautiful.
Vue
zernonia
zernonia
Troop Travel
layer/types/index.ts
TypeScript
export * from './twitter' export * from './metatags' export * from './github'
zernonia/nuxt-lego
234
NuxtLego is an open source UI component layer for building your Nuxt content quick & beautiful.
Vue
zernonia
zernonia
Troop Travel
layer/types/metatags.ts
TypeScript
export interface MetaTags { title?: string description?: string url?: string image?: string }
zernonia/nuxt-lego
234
NuxtLego is an open source UI component layer for building your Nuxt content quick & beautiful.
Vue
zernonia
zernonia
Troop Travel
layer/types/twitter.ts
TypeScript
interface TweetEditControl { edit_tweet_ids: string[] editable_until_msecs: string is_edit_eligible: boolean edits_remaining: string } export type Indices = [number, number] export interface HashtagEntity { indices: Indices text: string } export interface UserMentionEntity { id_str: string indices: Indices name: string screen_name: string } export interface MediaEntity { display_url: string expanded_url: string indices: Indices url: string } export interface UrlEntity { display_url: string expanded_url: string indices: Indices url: string } export interface SymbolEntity { indices: Indices text: string } export interface TweetEntities { hashtags: HashtagEntity[] urls: UrlEntity[] user_mentions: UserMentionEntity[] symbols: SymbolEntity[] media?: MediaEntity[] } interface RGB { red: number green: number blue: number } interface Rect { x: number y: number w: number h: number } interface Size { h: number w: number resize: string } interface VideoInfo { aspect_ratio: [number, number] variants: { bitrate?: number content_type: 'video/mp4' | 'application/x-mpegURL' url: string }[] } interface MediaBase { display_url: string expanded_url: string ext_media_availability: { status: string } ext_media_color: { palette: { percentage: number rgb: RGB }[] } indices: Indices media_url_https: string original_info: { height: number width: number focus_rects: Rect[] } sizes: { large: Size medium: Size small: Size thumb: Size } url: string } export interface MediaPhoto extends MediaBase { type: 'photo' ext_alt_text?: string } export interface MediaAnimatedGif extends MediaBase { type: 'animated_gif' video_info: VideoInfo } export interface MediaVideo extends MediaBase { type: 'video' video_info: VideoInfo } export type MediaDetails = MediaPhoto | MediaAnimatedGif | MediaVideo interface TweetUser { id_str: string name: string profile_image_url_https: string screen_name: string verified: boolean verified_type: string is_blue_verified: boolean profile_image_shape: 'Circle' | 'Square' } interface TweetVideo { aspectRatio: [number, number] contentType: string durationMs: number mediaAvailability: { status: string } poster: string variants: { type: string src: string }[] videoId: { type: string id: string } viewCount: number } interface TweetPhoto { backgroundColor: RGB cropCandidates: Rect[] expandedUrl: string url: string width: number height: number } interface TweetBase { lang: string created_at: string display_text_range: Indices entities: TweetEntities id_str: string text: string user: TweetUser edit_control: TweetEditControl card: TweetCard isEdited: boolean isStaleEdit: boolean } export interface Tweet extends TweetBase { __typename: 'Tweet' favorite_count: number mediaDetails?: MediaDetails[] photos?: TweetPhoto[] video?: TweetVideo conversation_count: number news_action_type: 'conversation' quoted_tweet?: QuotedTweet in_reply_to_screen_name?: string in_reply_to_status_id_str?: string in_reply_to_user_id_str?: string parent?: TweetParent possibly_sensitive?: boolean } interface TweetParent extends TweetBase { reply_count: number retweet_count: number favorite_count: number } interface QuotedTweet extends TweetBase { reply_count: number retweet_count: number favorite_count: number self_thread: { id_str: string } } interface TweetCardBindingValuesBase { string_value: string type: 'STRING' } interface TweetCardBindingValues { title: TweetCardBindingValuesBase description: TweetCardBindingValuesBase domain: TweetCardBindingValuesBase thumbnail_image: { image_value: { height: number width: number url: string } } summary_photo_image: { image_value: { height: number width: number url: string } } } export interface TweetCard { name: 'summary' | 'summary_large_image' url: string binding_values: TweetCardBindingValues }
zernonia/nuxt-lego
234
NuxtLego is an open source UI component layer for building your Nuxt content quick & beautiful.
Vue
zernonia
zernonia
Troop Travel
layer/utils/twitter.ts
TypeScript
import type { HashtagEntity, MediaDetails, SymbolEntity, Tweet, } from '../types/twitter' export function getUserUrl(usernameOrTweet: string | Tweet) { return `https://twitter.com/${ typeof usernameOrTweet === 'string' ? usernameOrTweet : usernameOrTweet.user.screen_name }` } export function getTweetUrl(tweet: Tweet) { return `https://twitter.com/${tweet.user.screen_name}/status/${tweet.id_str}` } export function getLikeUrl(tweet: Tweet) { return `https://twitter.com/intent/like?tweet_id=${tweet.id_str}` } export function getReplyUrl(tweet: Tweet) { return `https://twitter.com/intent/tweet?in_reply_to=${tweet.id_str}` } export function getFollowUrl(tweet: Tweet) { return `https://twitter.com/intent/follow?screen_name=${tweet.user.screen_name}` } export function getHashtagUrl(hashtag: HashtagEntity) { return `https://twitter.com/hashtag/${hashtag.text}` } export function getSymbolUrl(symbol: SymbolEntity) { return `https://twitter.com/search?q=%24${symbol.text}` } export function getInReplyToUrl(tweet: Tweet) { return `https://twitter.com/${tweet.in_reply_to_screen_name}/status/${tweet.in_reply_to_status_id_str}` } export function getMediaUrl(media: MediaDetails, size: 'small' | 'medium' | 'larget'): string { const url = new URL(media.media_url_https) const extension = url.pathname.split('.').pop() if (!extension) return media.media_url_https url.pathname = url.pathname.replace(`.${extension}`, '') url.searchParams.set('format', extension) url.searchParams.set('name', size) return url.toString() } export function formatNumber(n: number): string { if (n > 999999) return `${(n / 1000000).toFixed(1)}M` if (n > 999) return `${(n / 1000).toFixed(1)}K` return n.toString() }
zernonia/nuxt-lego
234
NuxtLego is an open source UI component layer for building your Nuxt content quick & beautiful.
Vue
zernonia
zernonia
Troop Travel
website/app.vue
Vue
<script setup lang="ts"></script> <template> <div class="text-gray-700 max-w-screen-xl mx-auto"> <SeoKit /> <NuxtLoadingIndicator color="rgb(96,165,250)" /> <NavBar class="sticky top-0 bg-white bg-opacity-50 backdrop-blur-md" /> <div class="px-4 md:px-6 py-4"> <NuxtPage /> </div> <NavFooter /> </div> </template>
zernonia/nuxt-lego
234
NuxtLego is an open source UI component layer for building your Nuxt content quick & beautiful.
Vue
zernonia
zernonia
Troop Travel
website/assets/css/main.css
CSS
.bg-grid { background: url(~/assets/img/grid.png); } .blur-overlay { background: linear-gradient( 180deg, #ffffff00 0%, #ffffff00 65%, #ffffff 100% ); } .fade-edge { --mask: linear-gradient(to right, rgba(0,0,0, 0) 0, rgba(0,0,0, 0) 5%, rgba(0,0,0, 1) 20%, rgba(0,0,0, 1) 80%, rgba(0,0,0, 0) 95%, rgba(0,0,0, 0) 0 ) 100% 50% / 100% 100%; -webkit-mask: var(--mask); mask: var(--mask); } h1, h2, h3 { @apply font-sans; }
zernonia/nuxt-lego
234
NuxtLego is an open source UI component layer for building your Nuxt content quick & beautiful.
Vue
zernonia
zernonia
Troop Travel
website/components/AuthUi/CustomButton.vue
Vue
<script setup lang="ts"> </script> <template> <a target="_blank"> <slot /> </a> </template>
zernonia/nuxt-lego
234
NuxtLego is an open source UI component layer for building your Nuxt content quick & beautiful.
Vue
zernonia
zernonia
Troop Travel
website/components/AuthUi/Demo.vue
Vue
<script setup lang="ts"> function handleSelectProvider(provider: string) { // return the selected provider } function handleSubmit(payload: { [key: string]: any }) { // in this case payload will return { email: string, password: string } } </script> <template> <LegoAuth class="max-w-96 w-full bg-white border rounded-2xl px-8 py-10 shadow-sm" :hide-provider-label="true" :providers="['twitter', 'google', 'facebook']" > <LegoAuthHeader> <template #logo> <img src="/logo.svg" alt="NuxtLego" class="w-10"> </template> <h2 class="mt-4 font-semibold text-xl"> Create your account </h2> <p class="text-gray-400 text-sm mt-1"> to continue to NuxtLego </p> </LegoAuthHeader> <div class="flex space-x-2 w-full mt-8"> <LegoAuthSocialProviders class="w-full px-4 py-3 border bg-white hover:bg-gray-50 transition rounded-lg text-xl flex justify-center" @select="handleSelectProvider" /> </div> <LegoAuthForm class="mt-10 text-sm" @submit="handleSubmit"> <LegoAuthFormInputText name="email" type="email" label="Email Address" class="block border w-full outline-blue-400 px-4 py-2 rounded-lg mt-1 mb-2" /> <LegoAuthFormInputText name="password" type="password" label="Password" class="block border w-full outline-blue-400 px-4 py-2 rounded-lg mt-1 mb-2" /> <LegoAuthFormButton label="Continue" class="bg-blue-400 hover:bg-blue-500 transition mt-2 px-4 py-2.5 rounded-lg w-full text-sm text-white" /> </LegoAuthForm> <div class="mt-10 text-sm text-gray-400"> Have an account? <NuxtLink class="text-blue-400 hover:text-blue-500 underline" to="/"> Sign In </NuxtLink> </div> </LegoAuth> </template>
zernonia/nuxt-lego
234
NuxtLego is an open source UI component layer for building your Nuxt content quick & beautiful.
Vue
zernonia
zernonia
Troop Travel
website/components/AuthUi/Demo2.vue
Vue
<script setup lang="ts"> import CustomButton from './CustomButton.vue' function handleSelectProvider(provider: string) { // return the selected provider } </script> <template> <LegoAuth class="max-w-96 w-full bg-white border rounded-2xl px-8 py-10 shadow-sm" :hide-provider-label="true" :providers="['twitter', 'google', 'facebook']" > <LegoAuthHeader> <div class="font-medium text-xl text-gray-300"> Custom Button <br> for Social Providers </div> </LegoAuthHeader> <div class="flex space-x-2 w-full mt-8"> <LegoAuthSocialProviders :is="CustomButton" class="w-full px-4 py-3 border bg-white hover:bg-gray-50 transition rounded-lg text-xl flex justify-center" @select="handleSelectProvider" /> </div> </LegoAuth> </template>
zernonia/nuxt-lego
234
NuxtLego is an open source UI component layer for building your Nuxt content quick & beautiful.
Vue
zernonia
zernonia
Troop Travel
website/components/AuthUi/Showcase.vue
Vue
<script setup lang="ts"></script> <template> <ShowcaseCard slug="auth-ui"> <template #image> <div class="mt-20 relative"> <div class="absolute -top-16 group-hover:-top-20 right-22 group-hover:right-24 text-4xl text-blue-200 group-hover:text-blue-400 transition-all" > <Icon name="ion:logo-facebook" /> </div> <div class="absolute -top-16 group-hover:-top-20 left-22 group-hover:left-24 text-4xl text-blue-200 group-hover:text-blue-400 transition-all" > <Icon name="ion:logo-google" /> </div> <div class="absolute -top-12 group-hover:-top-14 left-36 group-hover:left-38 text-4xl text-blue-200 group-hover:text-blue-400 transition-all" > <Icon name="ion:logo-github" /> </div> <div class="absolute -top-12 group-hover:-top-14 right-36 group-hover:right-38 text-4xl text-blue-200 group-hover:text-blue-400 transition-all" > <Icon name="ion:logo-twitter" /> </div> <div class="bg-white relative z-10 bg-white w-40 h-12 text-gray-300 group-hover:text-blue-400 transition text-sm border border-gray-200 group-hover:border-blue-400 rounded-xl flex items-center justify-center" > Sign Up </div> </div> </template> </ShowcaseCard> </template>
zernonia/nuxt-lego
234
NuxtLego is an open source UI component layer for building your Nuxt content quick & beautiful.
Vue
zernonia
zernonia
Troop Travel
website/components/Blueprints/Container.vue
Vue
<script setup lang="ts"> </script> <template> <div class="not-prose overflow-hidden bg-gradient-radial from-blue-400 to-blue-500 w-full rounded-2xl min-h-16rem md:min-h-lg border flex items-center justify-center"> <slot /> </div> </template>
zernonia/nuxt-lego
234
NuxtLego is an open source UI component layer for building your Nuxt content quick & beautiful.
Vue
zernonia
zernonia
Troop Travel
website/components/Blueprints/MagnifiedDock/AppIcon.vue
Vue
<script setup lang="ts"> import { useMotionProperties, useMotionTransitions } from '@vueuse/motion' const props = defineProps<{ mouseX: number }>() const { mouseX } = toRefs(props) const target = ref<HTMLElement>() const { motionProperties } = useMotionProperties(target, { width: 40 }) const { push } = useMotionTransitions() // relative distance of target element to mouseX const distance = computed(() => { const bounds = target.value?.getBoundingClientRect() ?? { x: 0, width: 0 } const val = Math.abs(mouseX.value - bounds.x - bounds.width / 2) return val > 150 ? 150 : val }) const widthSync = useProjection(distance, [0, 150], [100, 40]) watch(widthSync, () => { push('width', widthSync.value, motionProperties, { type: 'spring', mass: 0.1, stiffness: 150, damping: 12 }) }) </script> <template> <div ref="target" class="aspect-square w-10 rounded-full bg-white" /> </template>
zernonia/nuxt-lego
234
NuxtLego is an open source UI component layer for building your Nuxt content quick & beautiful.
Vue
zernonia
zernonia
Troop Travel
website/components/Blueprints/MagnifiedDock/index.vue
Vue
<script setup lang="ts"> import AppIcon from './AppIcon.vue' const mouseX = ref(Infinity) </script> <template> <div class=" flex h-16 items-end gap-4 rounded-2xl bg-white bg-opacity-20 backdrop-blur-md px-4 pb-3" @mousemove="mouseX = $event.pageX" @mouseleave="mouseX = Infinity" > <AppIcon v-for="i in 8" :key="i" :mouse-x="mouseX" /> </div> </template>
zernonia/nuxt-lego
234
NuxtLego is an open source UI component layer for building your Nuxt content quick & beautiful.
Vue
zernonia
zernonia
Troop Travel
website/components/CodeExample.vue
Vue
<script setup lang="ts"> const isPreview = ref(true) </script> <template> <div> <button class="px-5 py-2.5 text-sm hover:bg-gray-100 opacity-50 hover:opacity-100 transition rounded-lg mr-2" :class="{ 'bg-gray-100 border !opacity-100': isPreview }" :active="isPreview" @click="isPreview = true" > Preview </button> <button class="px-5 py-2.5 text-sm hover:bg-gray-100 opacity-50 hover:opacity-100 transition rounded-lg" :class="{ 'bg-gray-100 border !opacity-100': !isPreview }" @click="isPreview = false" > Code </button> <div> <Demo v-show="isPreview"> <slot name="preview" /> </Demo> <div v-show="!isPreview" class="mt-4"> <slot name="code" /> </div> </div> </div> </template>
zernonia/nuxt-lego
234
NuxtLego is an open source UI component layer for building your Nuxt content quick & beautiful.
Vue
zernonia
zernonia
Troop Travel
website/components/CountDown/Demo.vue
Vue
<script setup lang="ts"> const date = computed(() => { const today = new Date() const tomorrow = new Date(today) tomorrow.setDate(tomorrow.getDate() + 1) return tomorrow }) </script> <template> <div class="p-8 bg-white flex flex-col items-center rounded-3xl border "> <h4 class="text-2xl font-semibold"> Coming soon! </h4> <LegoCountDown v-slot="{ days, hours, minutes, seconds }" :date="date" enable-days> <div class="mt-6 flex items-center space-x-4"> <div class="w-20 h-20 p-2 bg-gray-100 rounded-xl flex flex-col items-center justify-center"> <h5 class="text-3xl font-semibold"> {{ days }} </h5> <p class="text-sm mt-1 text-gray-400"> Days </p> </div> <div class="w-20 h-20 p-2 bg-gray-100 rounded-xl flex flex-col items-center justify-center"> <h5 class="text-3xl font-semibold"> {{ hours }} </h5> <p class="text-sm mt-1 text-gray-400"> Hours </p> </div> <div class="w-20 h-20 p-2 bg-gray-100 rounded-xl flex flex-col items-center justify-center"> <h5 class="text-3xl font-semibold"> {{ minutes }} </h5> <p class="text-sm mt-1 text-gray-400"> Minutes </p> </div> <div class="w-20 h-20 p-2 bg-gray-100 rounded-xl flex flex-col items-center justify-center"> <h5 class="text-3xl font-semibold"> {{ seconds }} </h5> <p class="text-sm mt-1 text-gray-400"> Seconds </p> </div> </div> </LegoCountDown> </div> </template>
zernonia/nuxt-lego
234
NuxtLego is an open source UI component layer for building your Nuxt content quick & beautiful.
Vue
zernonia
zernonia
Troop Travel
website/components/Demo.vue
Vue
<script setup lang="ts"></script> <template> <div class="not-prose min-h-40 my-4 p-4 md:p-12 w-full rounded-2xl border bg-grid bg-repeat-x flex items-center justify-center" > <slot /> </div> </template>
zernonia/nuxt-lego
234
NuxtLego is an open source UI component layer for building your Nuxt content quick & beautiful.
Vue
zernonia
zernonia
Troop Travel
website/components/GithubStar/Demo.vue
Vue
<template> <LegoGithubStar v-slot="{ stars }" repo="zernonia/nuxt-lego" class="group border bg-white hover:bg-gray-100 transition rounded-lg text-xl flex justify-center"> <div class="flex items-center bg-gray-100 group-hover:bg-gray-200 transition rounded-l px-4 py-3 space-x-1"> <Icon name="uil:star" class="text-xl group-hover:op75 " /> <div>Star</div> </div> <div class="px-4 py-3"> {{ stars }} </div> </LegoGithubStar> </template>
zernonia/nuxt-lego
234
NuxtLego is an open source UI component layer for building your Nuxt content quick & beautiful.
Vue
zernonia
zernonia
Troop Travel
website/components/GithubStar/Showcase.vue
Vue
<template> <ShowcaseCard slug="github-star"> <template #image> <div class="text-blue-300 group-hover:text-[1.25rem] group-hover:text-blue-500 transition-all "> <LegoGithubStar v-slot="{ stars }" repo="zernonia/nuxt-lego" class="flex items-center space-x-1 px-3 py-2 border bg-white hover:bg-gray-50 transition rounded-lg flex justify-center"> <Icon name="mdi:star" class="op75 " /> {{ stars }} </LegoGithubStar> </div> </template> </ShowcaseCard> </template>
zernonia/nuxt-lego
234
NuxtLego is an open source UI component layer for building your Nuxt content quick & beautiful.
Vue
zernonia
zernonia
Troop Travel
website/components/Hero.vue
Vue
<script setup lang="ts"></script> <template> <div class="my-10 md:my-20"> <h1 class="text-4xl md:text-6xl font-semibold"> Ready made <br> UI components <br> with Nuxt layer. </h1> <h2 class="mt-4 text-lg md:text-xl text-gray-400"> Unstyled components for building your<br> Nuxt content quick & beautiful. </h2> <div class="mt-12 flex flex-col sm:flex-row sm:items-center space-y-2 sm:space-y-0 sm:space-x-4"> <NuxtLink to="/docs/overview/getting-started" class="block w-max px-6 py-3 font-semibold bg-blue-400 hover:bg-blue-500 transition text-white rounded-lg border border-blue-400" > Install NuxtLego </NuxtLink> <NuxtLink to="/blueprints" class="block w-max px-6 py-3 bg-white hover:bg-gray-100 transition text-gray-600 font-semibold rounded-lg border" > Blueprints </NuxtLink> </div> </div> </template>
zernonia/nuxt-lego
234
NuxtLego is an open source UI component layer for building your Nuxt content quick & beautiful.
Vue
zernonia
zernonia
Troop Travel
website/components/MarqueeBanner/Demo.vue
Vue
<script setup lang="ts"> const items = ['Vue', 'React', 'Angular'] </script> <template> <LegoMarqueeBanner :speed="0.5" :hovered-speed="0.25" class="w-96 md:w-144 text-xl"> <LegoMarqueeBannerLeft class="my-2"> <div v-for="item in items" :key="item" class="whitespace-nowrap px-5 border hover:border-gray-400 transition mr-4 py-2 rounded-full bg-gray-50"> {{ item }} </div> </LegoMarqueeBannerLeft> <LegoMarqueeBannerRight class="my-2"> <div v-for="item in items" :key="item" class="whitespace-nowrap px-5 border hover:border-gray-400 transition mr-4 py-2 rounded-full bg-gray-50"> {{ item }} </div> </LegoMarqueeBannerRight> </LegoMarqueeBanner> </template> <style scoped> .marquee-container { --mask: linear-gradient(to right, rgba(0,0,0, 0) 0, rgba(0,0,0, 0) 5%, rgba(0,0,0, 1) 20%, rgba(0,0,0, 1) 80%, rgba(0,0,0, 0) 95%, rgba(0,0,0, 0) 0 ) 100% 50% / 100% 100%; -webkit-mask: var(--mask); mask: var(--mask); } </style>
zernonia/nuxt-lego
234
NuxtLego is an open source UI component layer for building your Nuxt content quick & beautiful.
Vue
zernonia
zernonia
Troop Travel
website/components/MarqueeBanner/Showcase.vue
Vue
<script setup lang="ts"> </script> <template> <ShowcaseCard slug="marquee-banner"> <template #image> <div class="overflow-hidden absolute fade-edge w-full"> <div class="flex group-hover:translate-x-10 transition-transform"> <div class="flex-shrink-0 bg-gray-50 mr-2 w-32 h-10 border hover:bg-white hover:border-blue-400 transition rounded-full" /> <div class="flex-shrink-0 bg-gray-50 mr-2 w-32 h-10 border hover:bg-white hover:border-blue-400 transition rounded-full" /> <div class="flex-shrink-0 bg-gray-50 mr-2 w-32 h-10 border hover:bg-white hover:border-blue-400 transition rounded-full" /> </div> <div class="flex mt-4 -translate-x-16 group-hover:-translate-x-32 transition-transform"> <div class="flex-shrink-0 bg-gray-50 mr-2 w-32 h-10 border hover:bg-white hover:border-blue-400 transition rounded-full" /> <div class="flex-shrink-0 bg-gray-50 mr-2 w-32 h-10 border hover:bg-white hover:border-blue-400 transition rounded-full" /> <div class="flex-shrink-0 bg-gray-50 mr-2 w-32 h-10 border hover:bg-white hover:border-blue-400 transition rounded-full" /> <div class="flex-shrink-0 bg-gray-50 mr-2 w-32 h-10 border hover:bg-white hover:border-blue-400 transition rounded-full" /> </div> </div> </template> </ShowcaseCard> </template>
zernonia/nuxt-lego
234
NuxtLego is an open source UI component layer for building your Nuxt content quick & beautiful.
Vue
zernonia
zernonia
Troop Travel
website/components/NavBar.vue
Vue
<script setup lang="ts"> const isShowingMenu = ref(false) watch(isShowingMenu, (n) => { if (n) document.body.classList.add('overflow-y-hidden') else document.body.classList.remove('overflow-y-hidden') }) watch( () => useRoute().path, () => { isShowingMenu.value = false }, ) </script> <template> <header class="px-4 md:px-6 py-4 flex items-center justify-between z-10"> <h1> <NuxtLink to="/" class="text-xl md:text-2xl font-bold flex items-center space-x-2" > <img src="/logo.svg" alt="NuxtLego" class="w-6 md:w-8"> <span>NuxtLego</span> </NuxtLink> </h1> <div class="flex items-center"> <NuxtLink v-if="$route.path.includes('blueprints')" to="/blueprints" class="text-sm"> Blueprints </NuxtLink> <div v-if="$route.path.includes('blueprints')" to="/blueprints" class="h-4 w-1px mx-2 sm:mx-4 bg-gray-200" /> <LegoGithubStar v-slot="{ stars }" repo="zernonia/nuxt-lego" class="mr-5 group border bg-white hover:bg-gray-100 transition rounded-lg text-sm flex justify-center"> <div class="flex items-center bg-gray-100 group-hover:bg-gray-200 transition rounded-l px-2 py-1 space-x-1"> <Icon name="uil:star" class="group-hover:op75 " /> <div>Star</div> </div> <div class="px-2 py-1"> {{ stars }} </div> </LegoGithubStar> <NuxtLink to="https://github.com/zernonia/nuxt-lego" target="_blank"> <Icon class="text-3xl" name="uil:github" /> </NuxtLink> <button class="block md:hidden p-1 ml-1" @click="isShowingMenu = !isShowingMenu" > <Icon name="ph:list-fill" class="text-2xl" /> </button> </div> <Transition enter-active-class="overflow-y-hidden duration-300 ease-out" enter-from-class="overflow-y-hidden transform max-h-0 opacity-0" enter-to-class="overflow-y-hidden max-h-screen opacity-100" leave-active-class="overflow-y-hidden duration-300 ease-in" leave-from-class="overflow-y-hidden max-h-screen opacity-100" leave-to-class="overflow-y-hidden transform max-h-0 opacity-0" > <div v-if="isShowingMenu" class="z-20 fixed top-16 left-0 bg-white bg-opacity-50 backdrop-blur-md w-screen h-screen overflow-y-auto" @click.self="isShowingMenu = false" > <div class="bg-white p-4 border-b rounded-b-xl"> <SideNavBar /> </div> </div> </Transition> </header> </template>
zernonia/nuxt-lego
234
NuxtLego is an open source UI component layer for building your Nuxt content quick & beautiful.
Vue
zernonia
zernonia
Troop Travel
website/components/NavFooter.vue
Vue
<script setup lang="ts"></script> <template> <footer class="px-6 py-8"> <div class="border-t w-full pt-8"> <div> A project by <NuxtLink class="font-semibold" target="_blank" to="https://zernonia.com" > Zernonia </NuxtLink> </div> </div> </footer> </template>
zernonia/nuxt-lego
234
NuxtLego is an open source UI component layer for building your Nuxt content quick & beautiful.
Vue
zernonia
zernonia
Troop Travel
website/components/PageProgress/Demo.vue
Vue
<script setup lang="ts"> const el = ref() </script> <template> <div class="relative"> <LegoPageProgress v-slot="{ progress }" :target="el"> <div class="absolute -left-6 bottom-0 rounded-full h-full w-2.5 bg-gray-100 overflow-hidden" > <div class="w-full bg-blue-300 rounded-full" :style="{ height: `${progress}%` }" /> </div> </LegoPageProgress> <div ref="el"> <p> Lorem ipsum dolor sit amet, consectetur adipisicing elit. Cupiditate architecto voluptatum, laboriosam quisquam quod minus molestias. Rem ut quidem, corrupti nihil molestiae deserunt, iusto velit unde atque mollitia, eum ad maiores exercitationem. Soluta harum sit cupiditate eos, commodi itaque nihil, beatae dolorem ducimus, repudiandae, vero quo corporis sed laborum at maxime dicta dolores perferendis! Possimus repellat velit iste quod recusandae suscipit vitae ex soluta nostrum animi saepe eius itaque, voluptas, sapiente minima quo culpa explicabo necessitatibus distinctio. Veritatis amet tempora, consectetur molestias optio eveniet laudantium, tenetur aspernatur nobis ratione sit hic in impedit quod deserunt recusandae atque, ipsam molestiae sequi! </p> <p> Lorem ipsum dolor sit amet, consectetur adipisicing elit. Cupiditate architecto voluptatum, laboriosam quisquam quod minus molestias. Rem ut quidem, corrupti nihil molestiae deserunt, iusto velit unde atque mollitia, eum ad maiores exercitationem. Soluta harum sit cupiditate eos, commodi itaque nihil, beatae dolorem ducimus, repudiandae, vero quo corporis sed laborum at maxime dicta dolores perferendis! Possimus repellat velit iste quod recusandae suscipit vitae ex soluta nostrum animi saepe eius itaque, voluptas, sapiente minima quo culpa explicabo necessitatibus distinctio. Veritatis amet tempora, consectetur molestias optio eveniet laudantium, tenetur aspernatur nobis ratione sit hic in impedit quod deserunt recusandae atque, ipsam molestiae sequi! </p> <p> Lorem ipsum dolor sit amet, consectetur adipisicing elit. Cupiditate architecto voluptatum, laboriosam quisquam quod minus molestias. Rem ut quidem, corrupti nihil molestiae deserunt, iusto velit unde atque mollitia, eum ad maiores exercitationem. Soluta harum sit cupiditate eos, commodi itaque nihil, beatae dolorem ducimus, repudiandae, vero quo corporis sed laborum at maxime dicta dolores perferendis! Possimus repellat velit iste quod recusandae suscipit vitae ex soluta nostrum animi saepe eius itaque, voluptas, sapiente minima quo culpa explicabo necessitatibus distinctio. Veritatis amet tempora, consectetur molestias optio eveniet laudantium, tenetur aspernatur nobis ratione sit hic in impedit quod deserunt recusandae atque, ipsam molestiae sequi! </p> <p> Lorem ipsum dolor sit amet, consectetur adipisicing elit. Cupiditate architecto voluptatum, laboriosam quisquam quod minus molestias. Rem ut quidem, corrupti nihil molestiae deserunt, iusto velit unde atque mollitia, eum ad maiores exercitationem. Soluta harum sit cupiditate eos, commodi itaque nihil, beatae dolorem ducimus, repudiandae, vero quo corporis sed laborum at maxime dicta dolores perferendis! Possimus repellat velit iste quod recusandae suscipit vitae ex soluta nostrum animi saepe eius itaque, voluptas, sapiente minima quo culpa explicabo necessitatibus distinctio. Veritatis amet tempora, consectetur molestias optio eveniet laudantium, tenetur aspernatur nobis ratione sit hic in impedit quod deserunt recusandae atque, ipsam molestiae sequi! </p> <p> Lorem ipsum dolor sit amet, consectetur adipisicing elit. Cupiditate architecto voluptatum, laboriosam quisquam quod minus molestias. Rem ut quidem, corrupti nihil molestiae deserunt, iusto velit unde atque mollitia, eum ad maiores exercitationem. Soluta harum sit cupiditate eos, commodi itaque nihil, beatae dolorem ducimus, repudiandae, vero quo corporis sed laborum at maxime dicta dolores perferendis! Possimus repellat velit iste quod recusandae suscipit vitae ex soluta nostrum animi saepe eius itaque, voluptas, sapiente minima quo culpa explicabo necessitatibus distinctio. Veritatis amet tempora, consectetur molestias optio eveniet laudantium, tenetur aspernatur nobis ratione sit hic in impedit quod deserunt recusandae atque, ipsam molestiae sequi! </p> <p> Lorem ipsum dolor sit amet, consectetur adipisicing elit. Cupiditate architecto voluptatum, laboriosam quisquam quod minus molestias. Rem ut quidem, corrupti nihil molestiae deserunt, iusto velit unde atque mollitia, eum ad maiores exercitationem. Soluta harum sit cupiditate eos, commodi itaque nihil, beatae dolorem ducimus, repudiandae, vero quo corporis sed laborum at maxime dicta dolores perferendis! Possimus repellat velit iste quod recusandae suscipit vitae ex soluta nostrum animi saepe eius itaque, voluptas, sapiente minima quo culpa explicabo necessitatibus distinctio. Veritatis amet tempora, consectetur molestias optio eveniet laudantium, tenetur aspernatur nobis ratione sit hic in impedit quod deserunt recusandae atque, ipsam molestiae sequi! </p> <p> Lorem ipsum dolor sit amet, consectetur adipisicing elit. Cupiditate architecto voluptatum, laboriosam quisquam quod minus molestias. Rem ut quidem, corrupti nihil molestiae deserunt, iusto velit unde atque mollitia, eum ad maiores exercitationem. Soluta harum sit cupiditate eos, commodi itaque nihil, beatae dolorem ducimus, repudiandae, vero quo corporis sed laborum at maxime dicta dolores perferendis! Possimus repellat velit iste quod recusandae suscipit vitae ex soluta nostrum animi saepe eius itaque, voluptas, sapiente minima quo culpa explicabo necessitatibus distinctio. Veritatis amet tempora, consectetur molestias optio eveniet laudantium, tenetur aspernatur nobis ratione sit hic in impedit quod deserunt recusandae atque, ipsam molestiae sequi! </p> </div> </div> </template>
zernonia/nuxt-lego
234
NuxtLego is an open source UI component layer for building your Nuxt content quick & beautiful.
Vue
zernonia
zernonia
Troop Travel
website/components/PageProgress/Showcase.vue
Vue
<script setup lang="ts"> import { TransitionPresets, useTransition } from '@vueuse/core' const progress = ref(10) const output = useTransition(progress, { duration: 300, transition: TransitionPresets.easeInOutCubic, }) </script> <template> <ShowcaseCard slug="page-progress" @mouseover="progress = 45" @mouseleave="progress = 10"> <template #image> <div class="overflow-hidden h-full"> <div class="absolute top-10 right-8 font-bold text-4xl text-blue-300"> {{ output.toFixed(0) }}% </div> <div class="bg-white mt-10 group-hover:-mt-10 transition-margin w-64 h-60 border rounded-xl" /> </div> </template> </ShowcaseCard> </template>
zernonia/nuxt-lego
234
NuxtLego is an open source UI component layer for building your Nuxt content quick & beautiful.
Vue
zernonia
zernonia
Troop Travel
website/components/Preview/Demo.vue
Vue
<script setup lang="ts"> import { withBase } from 'ufo' import { computed, useRuntimeConfig } from '#imports' // props from ProseImg (https://github.com/nuxt/content/blob/main/src/runtime/components/Prose/ProseImg.vue) const props = defineProps({ src: { type: String, default: '', }, alt: { type: String, default: '', }, width: { type: [String, Number], default: undefined, }, height: { type: [String, Number], default: undefined, }, }) const refinedSrc = computed(() => { if (props.src?.startsWith('/') && !props.src.startsWith('//')) return withBase(props.src, useRuntimeConfig().app.baseURL) return props.src }) </script> <template> <div> <LegoPreview class="transition-transform ease-in-out duration-500 outline-none"> <LegoPreviewDialog class="fixed z-800 left-0 top-0 w-screen h-screen bg-white bg-opacity-50 backdrop-blur-md" /> <img class="rounded-2xl" :src="refinedSrc" :alt="alt" :width="width" :height="height"> </LegoPreview> </div> </template>
zernonia/nuxt-lego
234
NuxtLego is an open source UI component layer for building your Nuxt content quick & beautiful.
Vue
zernonia
zernonia
Troop Travel
website/components/Preview/Showcase.vue
Vue
<script setup lang="ts"> </script> <template> <ShowcaseCard slug="preview"> <template #image> <div> <div class="relative bg-white transition-all w-32 h-20 group-hover:scale-140 flex items-center justify-center text-gray-200 text-3xl border rounded-xl"> <Icon name="uil:image" /> <div class="absolute top-4 -right-4 group-hover:right-0 transition-all font-bold text-4xl text-blue-300"> <Icon name="akar-icons:zoom-in" /> </div> </div> </div> </template> </ShowcaseCard> </template>
zernonia/nuxt-lego
234
NuxtLego is an open source UI component layer for building your Nuxt content quick & beautiful.
Vue
zernonia
zernonia
Troop Travel
website/components/ShowcaseCard.vue
Vue
<script setup lang="ts"> const props = defineProps<{ slug: string }>() const { slug } = toRefs(props) const { data } = await useAsyncData(`showcase-${slug.value}`, () => queryContent(`/docs/components/${slug.value}`).only(['title', 'description', '_path', 'new']).findOne()) </script> <template> <NuxtLink :to="data._path"> <div class="group relative border hover:border-blue-400 transition rounded-xl overflow-hidden h-full"> <div class="h-48 relative flex items-center justify-center bg-grid bg-no-repeat bg-cover" > <div class="blur-overlay w-full h-full absolute pointer-events-none" /> <slot name="image" /> </div> <div class="p-4"> <h5 class="font-semibold"> {{ data.title }} </h5> <p class="text-sm mt-1 text-gray-400"> {{ data.description }} </p> <span v-if="data.new" class="absolute top-4 right-4 text-xs px-2 flex items-center rounded-full bg-blue-50 text-blue-400" > New </span> </div> </div> </NuxtLink> </template>
zernonia/nuxt-lego
234
NuxtLego is an open source UI component layer for building your Nuxt content quick & beautiful.
Vue
zernonia
zernonia
Troop Travel
website/components/ShowcaseList.vue
Vue
<script setup lang="ts"></script> <template> <div class="grid sm:grid-cols-2 lg:grid-cols-3 gap-8"> <SocialShareShowcase /> <StaticTweetShowcase /> <WebsiteCardShowcase /> <AuthUiShowcase /> <PageProgressShowcase /> <MarqueeBannerShowcase /> <PreviewShowcase /> <TocShowcase /> <GithubStarShowcase /> </div> </template>
zernonia/nuxt-lego
234
NuxtLego is an open source UI component layer for building your Nuxt content quick & beautiful.
Vue
zernonia
zernonia
Troop Travel
website/components/SideNavBar.vue
Vue
<script setup lang="ts"> const { data } = await useAsyncData('nav', () => fetchContentNavigation(queryContent('docs'))) const navigation = computed(() => data.value?.[0].children) </script> <template> <div> <div v-for="nav in navigation" :key="nav._id" class="mb-6"> <h4 class="font-semibold text-lg capitalize"> {{ nav.title }} </h4> <div class="mt-2 text-sm flex flex-col space-y-1"> <NuxtLink v-for="child in nav.children" :key="child.title" class="hover:underline inline-flex items-center" :to="child._path" > {{ child.title }} <span v-if="child.new" class="text-[0.65rem] px-1.5 ml-1 h-4 flex items-center rounded-full bg-blue-50 text-blue-400" > New </span> </NuxtLink> </div> </div> </div> </template> <style scoped> .router-link-active { @apply text-blue-400; } </style>
zernonia/nuxt-lego
234
NuxtLego is an open source UI component layer for building your Nuxt content quick & beautiful.
Vue
zernonia
zernonia
Troop Travel
website/components/SocialShare/Demo.vue
Vue
<script setup lang="ts"> defineProps<{ url?: string text?: string }>() </script> <template> <LegoSocialShare :url="url" class="text-3xl flex space-x-3"> <LegoSocialShareLink class="text-blue-300 hover:text-blue-400 transition" /> <LegoSocialShareFacebook class="text-blue-300 hover:text-blue-400 transition" /> <LegoSocialShareTwitter class="text-blue-300 hover:text-blue-400 transition" :text="text" /> <LegoSocialShareLinkedIn class="text-blue-300 hover:text-blue-400 transition" :text="text" /> <LegoSocialShareReddit class="text-blue-300 hover:text-blue-400 transition" :text="text" /> </LegoSocialShare> </template>
zernonia/nuxt-lego
234
NuxtLego is an open source UI component layer for building your Nuxt content quick & beautiful.
Vue
zernonia
zernonia
Troop Travel
website/components/SocialShare/Showcase.vue
Vue
<script setup lang="ts"></script> <template> <ShowcaseCard slug="social-share"> <template #image> <div class="text-blue-300 text-4xl group-hover:text-[2.75rem] transition-all flex space-x-2 "> <Icon name="mdi:twitter" class="hover:text-blue-400 transition" /> <Icon name="mdi:facebook" class="hover:text-blue-400 transition" /> <Icon name="mdi:linkedin" class="hover:text-blue-400 transition" /> <Icon name="mdi:share-variant" class="hover:text-blue-400 transition" /> <Icon name="mdi:reddit" class="hover:text-blue-400 transition" /> </div> </template> </ShowcaseCard> </template>
zernonia/nuxt-lego
234
NuxtLego is an open source UI component layer for building your Nuxt content quick & beautiful.
Vue
zernonia
zernonia
Troop Travel
website/components/StaticTweet/Demo.vue
Vue
<script setup lang="ts"> defineProps<{ id: string }>() </script> <template> <LegoTweet v-slot="{ url }" :tweet-id="id" class="max-w-[550px] bg-white p-4 rounded-xl border" > <div class="flex justify-between"> <LegoTweetUser v-slot="{ user }"> <div class="flex items-center"> <LegoTweetUserAvatar> <span /> </LegoTweetUserAvatar> <div class="ml-3"> <p class="font-semibold leading-5"> {{ user.name }} </p> <p class="text-gray-400"> @{{ user.screen_name }} </p> </div> </div> </LegoTweetUser> <LegoTweetLink :href="url"> <Icon name="uil:twitter" class="text-4xl text-blue-300" /> </LegoTweetLink> </div> <LegoTweetText class="mt-4 text-base md:text-lg" link-class="text-blue-500 hover:underline" /> <LegoTweetMedia class="mt-2 rounded-xl overflow-hidden border max-h-[290px]" /> <LegoTweetSummaryCard v-slot="{ title, description, domain }" class="mt-2 border rounded-xl overflow-hidden bg-white hover:bg-gray-100 transition" > <div class="px-4 py-2 h-full"> <p class="text-sm text-gray-400"> {{ domain }} </p> <p>{{ title }}</p> <p class="text-sm text-gray-400"> {{ description }} </p> </div> </LegoTweetSummaryCard> <div class="mt-2 text-gray-400 flex justify-between"> <LegoTweetCreatedAt /> <LegoTweetTerms /> </div> <div class="my-2 h-[1px] w-full bg-gray-200" /> <LegoTweetAction class="text-gray-500 flex space-x-4"> <LegoTweetActionLove v-slot="{ favorite_count }" class="group flex items-center font-semibold text-sm space-x-1" > <LegoTweetActionLoveIcon class="text-pink-600 group-hover:bg-pink-100 p-1.5 rounded-full w-8 h-8" /> <span class="group-hover:text-pink-600 group-hover:underline"> {{ favorite_count }} </span> </LegoTweetActionLove> <LegoTweetActionReply class="group flex items-center font-semibold text-sm space-x-1" > <LegoTweetActionReplyIcon class="text-blue-400 group-hover:bg-blue-100 p-1.5 rounded-full w-8 h-8" /> <span class="group-hover:text-blue-400 group-hover:underline"> Reply </span> </LegoTweetActionReply> <LegoTweetActionCopy v-slot="{ copied }" class="group flex items-center font-semibold text-sm space-x-1" > <LegoTweetActionCopyIcon class="group-hover:bg-green-100 group-hover:text-green-500 p-1.5 rounded-full w-8 h-8" /> <span class="group-hover:text-green-400 group-hover:underline"> {{ copied ? "Copied!" : "Copy link" }} </span> </LegoTweetActionCopy> </LegoTweetAction> <LegoTweetReplies class="py-2 px-4 mt-2 flex justify-center text-sm font-medium text-blue-500 bg-white hover:bg-blue-50 transition rounded-3xl border" /> </LegoTweet> </template>
zernonia/nuxt-lego
234
NuxtLego is an open source UI component layer for building your Nuxt content quick & beautiful.
Vue
zernonia
zernonia
Troop Travel
website/components/StaticTweet/Showcase.vue
Vue
<script setup lang="ts"></script> <template> <ShowcaseCard slug="static-tweet"> <template #image> <div class="overflow-hidden h-full w-full"> <div class="w-64 p-4 mt-12 mx-auto border bg-white rounded-xl"> <div class="flex justify-between items-center"> <div class="flex"> <div class="w-10 h-10 rounded-full bg-gray-100" /> <div class="ml-2 mt-1"> <div class="h-2 w-16 rounded-full bg-gray-100" /> <div class="mt-1 h-2 w-12 rounded-full bg-gray-100" /> </div> </div> <div> <Icon class="text-4xl group-hover:text-6xl group-hover:-rotate-5 transition-all text-blue-300" name="uil:twitter" /> </div> </div> <div class="h-20 w-full" /> </div> </div> </template> </ShowcaseCard> </template>
zernonia/nuxt-lego
234
NuxtLego is an open source UI component layer for building your Nuxt content quick & beautiful.
Vue
zernonia
zernonia
Troop Travel
website/components/Toc/Demo.vue
Vue
<script setup lang="ts"> const props = defineProps<{ contentPath: string }>() const { data } = await useAsyncData(props.contentPath, () => { return queryContent(props.contentPath).findOne() }) const links = computed(() => data.value?.body.toc.links) </script> <template> <LegoToc class="bg-white border text-sm p-4 rounded-xl"> <template #title> <div class="mx-4 mb-4 text-lg font-semibold"> Navigation </div> </template> <LegoTocLinks v-slot="{ link }" class="ml-4" :links="links"> <div class="block my-2 hover:underline"> {{ link.text }} </div> </LegoTocLinks> </LegoToc> </template>
zernonia/nuxt-lego
234
NuxtLego is an open source UI component layer for building your Nuxt content quick & beautiful.
Vue
zernonia
zernonia
Troop Travel
website/components/Toc/Showcase.vue
Vue
<script setup lang="ts"></script> <template> <ShowcaseCard slug="table-of-contents"> <template #image> <div class="px-4 py-6 flex flex-col space-y-2"> <div class="h-2 w-36 rounded-full transition-all bg-gray-100 group-hover:bg-blue-300" /> <div class="ml-4 group-hover:ml-6 transition-all h-2 w-36 rounded-full bg-gray-100 group-hover:bg-blue-300" /> <div class="ml-4 group-hover:ml-6 transition-all h-2 w-36 rounded-full bg-gray-100 group-hover:bg-blue-300" /> <div class="h-2 w-36 rounded-full transition-all bg-gray-100 group-hover:bg-blue-300" /> <div class="ml-4 group-hover:ml-6 transition-all h-2 w-36 rounded-full bg-gray-100 group-hover:bg-blue-300" /> </div> </template> </ShowcaseCard> </template>
zernonia/nuxt-lego
234
NuxtLego is an open source UI component layer for building your Nuxt content quick & beautiful.
Vue
zernonia
zernonia
Troop Travel
website/components/WebsiteCard/Demo.vue
Vue
<script setup lang="ts"> defineProps<{ url: string }>() </script> <template> <LegoWebsiteCard v-slot="{ url, valid }" class="border rounded-xl overflow-hidden max-w-[550px]" :url="url" > <NuxtLink v-if="valid" :to="url" target="_blank" class="flex bg-white hover:bg-gray-50 transition" > <div class="p-4"> <LegoWebsiteCardTitle class="font-medium" /> <LegoWebsiteCardDescription class="text-xs text-gray-500 mt-2" /> <LegoWebsiteCardUrl class="mt-2 text-xs md:text-sm text-gray-500" /> </div> <LegoWebsiteCardImage class="w-28 md:w-52 border-l object-cover" /> </NuxtLink> <div v-else class="p-6 text-sm text-gray-500 text-center"> <span>Something wrong</span> <Icon class="mb-1 ml-2" name="uil:info-circle" /> </div> </LegoWebsiteCard> </template>
zernonia/nuxt-lego
234
NuxtLego is an open source UI component layer for building your Nuxt content quick & beautiful.
Vue
zernonia
zernonia
Troop Travel
website/components/WebsiteCard/Showcase.vue
Vue
<script setup lang="ts"></script> <template> <ShowcaseCard slug="website-card"> <template #image> <div class="mt-4 h-22 flex items-center border border-gray-200 group-hover:border-gray-300 transition rounded-xl overflow-hidden" > <div class="w-20 h-full bg-gray-100 group-hover:bg-gray-100 transition" /> <div class="px-3 bg-white h-full flex flex-col justify-center"> <p class="text-xs font-semibold text-gray-300 group-hover:text-gray-400 transition"> Title </p> <p class="text-xs my-1 text-gray-300 group-hover:text-gray-400 transition"> Website's metadata description </p> <div class="mt-1 h-2 w-16 rounded-full bg-gray-100 group-hover:bg-gray-200 transition" /> </div> </div> </template> </ShowcaseCard> </template>
zernonia/nuxt-lego
234
NuxtLego is an open source UI component layer for building your Nuxt content quick & beautiful.
Vue
zernonia
zernonia
Troop Travel
website/components/content/ProseCode.vue
Vue
<script setup lang="ts"> const props = defineProps<{ code: string language?: string filename?: string higlights?: number[] meta?: string }>() const { code } = toRefs(props) const { copy, copied } = useClipboard({ source: code }) </script> <template> <div class="group relative border rounded-xl bg-gray-100"> <div v-if="filename" class="mr-4 mt-4 md:mr-0 md:mt-0 flex justify-end"> <samp class="not-prose w-max md:absolute top-4 right-4 opacity-70 md:group-hover:opacity-0 transition text-xs px-2 py-1 bg-gray-200 rounded" > {{ filename }} </samp> </div> <button class="absolute bottom-4 right-4 text-lg w-10 h-10 flex items-center justify-center rounded-lg border opacity-0 group-hover:opacity-70 text-gray-500 transition bg-white" @click="copy()" > <Icon v-if="!copied" name="uil:clipboard" /> <Icon v-else name="uil:check" /> </button> <slot /> </div> </template>
zernonia/nuxt-lego
234
NuxtLego is an open source UI component layer for building your Nuxt content quick & beautiful.
Vue
zernonia
zernonia
Troop Travel
website/components/content/ProseTable.vue
Vue
<template> <table class="text-sm"> <slot /> </table> </template>
zernonia/nuxt-lego
234
NuxtLego is an open source UI component layer for building your Nuxt content quick & beautiful.
Vue
zernonia
zernonia
Troop Travel
website/components/content/ProseTd.vue
Vue
<template> <td class="px-2 md:px-6 border-0 border-solid border-b border-gray-200"> <slot /> </td> </template>
zernonia/nuxt-lego
234
NuxtLego is an open source UI component layer for building your Nuxt content quick & beautiful.
Vue
zernonia
zernonia
Troop Travel
website/components/content/ProseTh.vue
Vue
<template> <td class="px-2 md:px-6 border-0 border-solid border-b border-gray-200"> <slot /> </td> </template>
zernonia/nuxt-lego
234
NuxtLego is an open source UI component layer for building your Nuxt content quick & beautiful.
Vue
zernonia
zernonia
Troop Travel
website/components/islands/CustomOgImage.vue
Vue
<script setup lang="ts"> defineProps<{ title: string; description: string }>() </script> <template> <div :style="{ fontFamily: 'Plus Jakarta Sans' }" class="relative w-full h-full flex flex-col bg-white text-blue-400 items-center justify-center" > <div class="mt-26 max-w-[600px] flex flex-col text-center items-center justify-center" > <h1 class="text-7xl font-bold"> {{ title }} </h1> <p class="text-3xl"> {{ description }} </p> </div> <div class="mt-28 flex flex-row items-center"> <img src="/logo.png" height="50px"> <p class="text-gray-800 font-bold ml-4 text-3xl"> NuxtLego </p> </div> <img class="absolute top-0 left-0 w-96" height="200px" src="/grid.png"> <img class="absolute top-0 right-0 w-96" src="/grid.png"> <img class="absolute bottom-0 left-0 w-96" style="transform: rotate(180deg)" src="/grid.png" > <img class="absolute bottom-0 right-0 w-96" style="transform: rotate(180deg)" src="/grid.png" > </div> </template>
zernonia/nuxt-lego
234
NuxtLego is an open source UI component layer for building your Nuxt content quick & beautiful.
Vue
zernonia
zernonia
Troop Travel
website/composables/useCustomHead.ts
TypeScript
export function useCustomHead(data: { title: string description: string image: string } = { title: '', description: '', image: '/og.png', }) { const { public: { siteUrl }, } = useRuntimeConfig() const image = computed(() => `${siteUrl}${data.image ?? ''}`) return useSeoMeta({ title: () => data.title, description: () => data.description, ogTitle: () => data.title, ogDescription: () => data.description, ogImage: () => image.value, twitterTitle: () => data.title, twitterDescription: () => data.description, twitterImage: () => image.value, }) }
zernonia/nuxt-lego
234
NuxtLego is an open source UI component layer for building your Nuxt content quick & beautiful.
Vue
zernonia
zernonia
Troop Travel
website/error.vue
Vue
<script setup lang="ts"> defineProps<{ error: { message: string } }>() const handleError = () => clearError({ redirect: '/' }) </script> <template> <div class="w-full"> <div class="my-32 flex flex-col items-center justify-center "> <Icon name="mdi-map-marker-question-outline" class="text-4xl text-gray-300 mr-2" /> <h1 class="inline-flex text-5xl font-bold my-8"> {{ error.message }} </h1> <button class=" px-6 py-3 font-semibold rounded-lg border" @click="handleError"> Back to Home </button> </div> </div> </template>
zernonia/nuxt-lego
234
NuxtLego is an open source UI component layer for building your Nuxt content quick & beautiful.
Vue
zernonia
zernonia
Troop Travel
website/nuxt.config.ts
TypeScript
export default defineNuxtConfig({ extends: ['../layer', 'nuxt-seo-kit'], app: { head: { link: [{ rel: 'icon', type: 'image/svg', href: '/logo.svg' }], meta: [{ name: 'google-site-verification', content: '0fHjXCYubdueQI63delbgFoqfSf_90OQdhwJBW5NxpQ' }], }, }, modules: [ '@unocss/nuxt', '@nuxt/content', '@nuxt/devtools', '@nuxthq/studio', '@vueuse/nuxt', '@vueuse/motion/nuxt', "@nuxt/image" ], css: ['@unocss/reset/tailwind.css', '~/assets/css/main.css'], components: [ { path: '~/components', global: true }, { path: '~/components/islands', island: true }, ], content: { highlight: { theme: 'github-light', preload: ['vue', 'ts'], }, navigation: { fields: ['new', 'image'], }, }, nitro: { rootDir: '.', prerender: { crawlLinks: true, routes: ['/', '/docs'], }, }, unocss: { configFile: '~/uno.config.ts', }, image: { provider: 'ipx', }, runtimeConfig: { public: { siteUrl: process.env.NUXT_PUBLIC_SITE_URL || `https://${process.env.NUXT_ENV_VERCEL_URL}` || 'https://nuxt-lego.vercel.app', titleSeparator: '|', siteName: 'NuxtLego', siteDescription: 'Ready made UI components with Nuxt layer.', language: 'en', umamiHost: '', umamiId: '', umamiDomains: '', studioTokens: '', }, }, ogImage: { fonts: ['Plus+Jakarta+Sans:400', 'Plus+Jakarta+Sans:700'], }, })
zernonia/nuxt-lego
234
NuxtLego is an open source UI component layer for building your Nuxt content quick & beautiful.
Vue
zernonia
zernonia
Troop Travel
website/pages/blueprints/[...slug].vue
Vue
<script setup lang="ts"> const slug = computed(() => useRoute().path) const { data } = await useAsyncData(slug.value, () => queryContent(slug.value).findOne(), ) if (!data.value) throw createError({ statusCode: 404, statusMessage: 'Page Not Found!!' }) const image = computed(() => { return `${useRoute().path}/__og_image__/og.png` }) useCustomHead({ title: data.value?.title ?? '', description: data.value?.description ?? '', image: image.value, }) defineOgImageStatic({ component: 'CustomOgImage', title: data.value?.title, description: data.value?.description ?? '', }) </script> <template> <div class="flex flex-col w-full text-base md:text-lg"> <BlueprintsContainer class="mb-6"> <component :is="data.reference" /> </BlueprintsContainer> <main class="prose w-full lg:max-w-54rem mx-auto"> <h1> {{ data.title }} </h1> <ContentRendererMarkdown :value="data" /> <NuxtLink to="/blueprints" class="mt-12 inline-flex items-center underline underline-offset-4 underline-gray-100 hover:underline-blue-400 transition-all duration-1000"> <Icon name="uil:angle-right" class="text-xl" /> <span>cd ..</span> </NuxtLink> </main> </div> </template>
zernonia/nuxt-lego
234
NuxtLego is an open source UI component layer for building your Nuxt content quick & beautiful.
Vue
zernonia
zernonia
Troop Travel
website/pages/blueprints/index.vue
Vue
<script setup lang="ts"> const { data } = await useAsyncData('nav-blueprints', () => fetchContentNavigation(queryContent('blueprints'))) const navigation = computed(() => data.value?.[0].children) </script> <template> <div class="md:mt-8"> <h1 class="text-3xl md:text-4xl font-bold"> Blueprints </h1> <h2 class="mt-4 text-lg md:text-xl text-gray-400"> Code snippets for modern user interface techniques. </h2> <ul class="mt-12 grid sm:grid-cols-2 lg:grid-cols-3 gap-8"> <li v-for="item in navigation" :key="item._id" class="group"> <NuxtLink :to="item._path"> <div class="h-48 flex items-center justify-center border rounded-2xl bg-gradient-radial from-blue-400 to-blue-500 border-blue-400 "> <NuxtImg class="w-full h-auto bg-contain" :src="`${item.image}`" /> </div> <h5 class="mt-2 text-gray-400 text-center group-hover:underline"> {{ item.title }} </h5> </NuxtLink> </li> </ul> </div> </template>
zernonia/nuxt-lego
234
NuxtLego is an open source UI component layer for building your Nuxt content quick & beautiful.
Vue
zernonia
zernonia
Troop Travel
website/pages/docs.vue
Vue
<script setup lang="ts"></script> <template> <div class="flex"> <SideNavBar class="hidden md:block sticky top-21 py-4 h-max w-44 shrink-0" /> <NuxtPage /> </div> </template>
zernonia/nuxt-lego
234
NuxtLego is an open source UI component layer for building your Nuxt content quick & beautiful.
Vue
zernonia
zernonia
Troop Travel
website/pages/docs/[...slug].vue
Vue
<script setup lang="ts"> const slug = computed(() => useRoute().path) const { data } = await useAsyncData(slug.value, () => queryContent(slug.value).findOne(), ) if (!data.value) throw createError({ statusCode: 404, statusMessage: 'Page Not Found!!' }) const { data: prevNext } = await useAsyncData(`${slug.value}-prev-next`, () => { return queryContent() .only(['_path', 'title', '_dir']) .findSurround(slug.value) }) const prev = prevNext.value?.[0] const next = prevNext.value?.[1] const links = computed(() => data.value?.body.toc.links) const image = computed(() => { return `${useRoute().path}/__og_image__/og.png` }) useCustomHead({ title: data.value?.title ?? '', description: data.value?.description ?? '', image: image.value, }) defineOgImageStatic({ component: 'CustomOgImage', title: data.value?.title, description: data.value?.description ?? '', }) </script> <template> <div class="flex w-full"> <main v-if="data" class="prose text-sm md:text-base mx-auto w-full"> <h1>{{ data.title }}</h1> <p v-if="data.description" class="text-lg"> {{ data.description }} </p> <ContentRenderer :value="data" /> <div class="py-12 border-b"> <NuxtLink target="_blank" class="hover:underline" :to="`https://github.com/zernonia/nuxt-lego/tree/main/website/content/${data._file}`" > <Icon name="uil:edit" /> <span class="text-sm ml-2">Edit something here!</span> </NuxtLink> </div> <div class="pt-8 not-prose flex flex-col sm:flex-row justify-between"> <div> <NuxtLink v-if="prev" :to="prev._path" class="flex items-center px-3 py-2.5 rounded-xl border sm:w-max bg-white hover:bg-gray-100 transition" > <Icon name="uil:angle-left-b" class="text-xl" /> <div class="flex flex-col items-end px-2"> <span class="capitalize text-gray-400 text-xs">{{ prev._dir }}</span> <h5>{{ prev.title }}</h5> </div> </NuxtLink> </div> <div class="mt-4 sm:mt-0"> <NuxtLink v-if="next" :to="next._path" class="flex items-center justify-end px-3 py-2.5 rounded-xl border sm:w-max bg-white hover:bg-gray-100 transition" > <div class="flex flex-col items-start px-2"> <span class="capitalize text-gray-400 text-xs">{{ next._dir }}</span> <h5>{{ next.title }}</h5> </div> <Icon name="uil:angle-right-b" class="text-xl" /> </NuxtLink> </div> </div> </main> <LegoToc class="hidden lg:block text-sm p-4 w-44 h-max sticky top-21 shrink-0"> <template #title> <div class="ml-4 mb-4 text-xl font-semibold"> Quick Nav </div> </template> <LegoTocLinks v-slot="{ link }" class="ml-4" :links="links"> <div class="block my-2 hover:underline"> {{ link.text }} </div> </LegoTocLinks> </LegoToc> </div> </template>
zernonia/nuxt-lego
234
NuxtLego is an open source UI component layer for building your Nuxt content quick & beautiful.
Vue
zernonia
zernonia
Troop Travel
website/pages/index.vue
Vue
<script setup lang="ts"> useCustomHead({ title: 'Primitives', description: 'Ready made UI components with Nuxt layer.', image: '/og.png', }) </script> <template> <div> <Hero /> <ShowcaseList /> </div> </template>
zernonia/nuxt-lego
234
NuxtLego is an open source UI component layer for building your Nuxt content quick & beautiful.
Vue
zernonia
zernonia
Troop Travel
website/plugins/analytics.client.ts
TypeScript
export default defineNuxtPlugin(() => { const cfg = useRuntimeConfig() if (!cfg.public.umamiHost) return const url = new URL('/script.js', cfg.public.umamiHost) const node = document.createElement('script') node.async = true node.src = url.href node.setAttribute('data-website-id', cfg.public.umamiId) node.setAttribute('data-domains', cfg.public.umamiDomains) document.body.appendChild(node) })
zernonia/nuxt-lego
234
NuxtLego is an open source UI component layer for building your Nuxt content quick & beautiful.
Vue
zernonia
zernonia
Troop Travel
website/server/plugins/content.ts
TypeScript
// Autodoc from inkline.io // reference: https://github.com/inkline/inkline.io/blob/main/server/plugins/content.ts import { readFileSync } from 'node:fs' import { resolve } from 'pathe' import glob from 'fast-glob' const rootPath = resolve('.') const codeCache = new Map<string, string>() const codeFilePaths = [...glob.sync(resolve('website', '**', 'components', '**'))] codeFilePaths.forEach((filePath) => { const keyName = filePath.split(rootPath)[1].slice(1) codeCache.set(keyName, readFileSync(filePath, 'utf-8')) }) const autodocsRegEx = /codegen\s*\{(.+})/g const paramsRegEx = /(\w+)="([^"]+)"/g export default defineNitroPlugin((nitroApp) => { nitroApp.hooks.hook('content:file:beforeParse', (file) => { if (file._id.endsWith('.md')) { let match let body = file.body do { match = autodocsRegEx.exec(body) if (match) { const rawParams = match[1] const params = [...rawParams.matchAll(paramsRegEx)].reduce< Record<string, string> >((acc, [, propertyName, propertyValue]) => { acc[propertyName] = propertyValue return acc }, {}) const code = codeCache.get(params.src) const codeBlock = `~~~${params.lang}[${params.fileName}]\n${code}\n~~~` if (code) body = body.replace(match[0], codeBlock) else console.error(`Could not find code for ${params.src}`) } } while (match) file.body = body } }) })
zernonia/nuxt-lego
234
NuxtLego is an open source UI component layer for building your Nuxt content quick & beautiful.
Vue
zernonia
zernonia
Troop Travel
website/uno.config.ts
TypeScript
import { defineConfig, presetAttributify, presetIcons, presetTypography, presetUno, presetWebFonts, transformerDirectives, } from 'unocss' export default defineConfig({ shortcuts: [ // ... ], theme: { colors: { // ... }, }, presets: [ presetUno(), presetAttributify(), presetIcons(), presetTypography({ cssExtend: { 'pre,code': { margin: 0, }, 'h1': { 'font-weight': '700', }, 'h2': { 'font-size': '1.5rem', }, 'a': { 'text-decoration': 'unset', 'font-weight': 'unset', 'color': 'rgba(96,165,250,var(--un-text-opacity))', }, }, }), presetWebFonts({ provider: 'google', fonts: { sans: { name: 'Plus Jakarta Sans', weights: ['400', '500', '600', '700'], }, }, }), ], transformers: [transformerDirectives()], })
zernonia/nuxt-lego
234
NuxtLego is an open source UI component layer for building your Nuxt content quick & beautiful.
Vue
zernonia
zernonia
Troop Travel
global.d.ts
TypeScript
declare global { var supabaseRef: string; } export {};
zernonia/supabase-vscode-extension
14
Unofficial Supabase Extension
TypeScript
zernonia
zernonia
Troop Travel
src/commands/go-to-dashboard.ts
TypeScript
import * as vscode from "vscode"; const defineQuickPath = (command: string, path: string) => { return vscode.commands.registerCommand(`supabase-vscode.${command}`, () => { if (!supabaseRef) { return vscode.window.showErrorMessage("[Error] Supabase: Couldn't find Supabase's Ref from your .env file"); } vscode.env.openExternal(vscode.Uri.parse(`https://app.supabase.com/project/${supabaseRef}${path}`)); }); }; const navList = [ { command: "goToEditor", path: "/editor" }, { command: "goToAuth", path: "/auth/policies" }, { command: "goToStorage", path: "/storage/buckets" }, { command: "goToSQL", path: "/sql" }, { command: "goToEdgeFunction", path: "/functions" }, { command: "goToSettings", path: "/settings/general" }, ]; export default navList.map((i) => defineQuickPath(i.command, i.path));
zernonia/supabase-vscode-extension
14
Unofficial Supabase Extension
TypeScript
zernonia
zernonia
Troop Travel
src/commands/go-to-website.ts
TypeScript
import * as vscode from "vscode"; const defineQuickPath = (command: string, path: string) => { return vscode.commands.registerCommand(`supabase-vscode.${command}`, () => { vscode.env.openExternal(vscode.Uri.parse(`https://supabase.com${path}`)); }); }; const navList = [ { command: "goToWebsite", path: "/" }, { command: "goToGuides", path: "/docs" }, { command: "goToReference", path: "/docs/reference" }, ]; export default navList.map((i) => defineQuickPath(i.command, i.path));
zernonia/supabase-vscode-extension
14
Unofficial Supabase Extension
TypeScript
zernonia
zernonia
Troop Travel
src/index.ts
TypeScript
import * as vscode from "vscode"; import { join } from "path"; import goToDashboard from "./commands/go-to-dashboard"; import goToWebsite from "./commands/go-to-website"; export function activate(context: vscode.ExtensionContext) { let rootDir = vscode.workspace.workspaceFolders?.[0]?.uri.fsPath; if (rootDir) { vscode.workspace.openTextDocument(join(rootDir, ".env")).then((document) => { const text = document.getText(); const envList = text.split("\n"); const supabaseUrl = envList.find((i) => i.includes("supabase.co")); global.supabaseRef = supabaseUrl?.split("https://")[1].split(".supabase")[0] ?? ""; // console.log(text.split("\n")); // console.log({ supabaseUrl, supabaseRef }); }); } context.subscriptions.concat(goToWebsite); context.subscriptions.concat(goToDashboard); } export function deactivate() {}
zernonia/supabase-vscode-extension
14
Unofficial Supabase Extension
TypeScript
zernonia
zernonia
Troop Travel
src/test/runTest.ts
TypeScript
import * as path from 'path'; import { runTests } from '@vscode/test-electron'; async function main() { try { // The folder containing the Extension Manifest package.json // Passed to `--extensionDevelopmentPath` const extensionDevelopmentPath = path.resolve(__dirname, '../../'); // The path to test runner // Passed to --extensionTestsPath const extensionTestsPath = path.resolve(__dirname, './suite/index'); // Download VS Code, unzip it and run the integration test await runTests({ extensionDevelopmentPath, extensionTestsPath }); } catch (err) { console.error('Failed to run tests'); process.exit(1); } } main();
zernonia/supabase-vscode-extension
14
Unofficial Supabase Extension
TypeScript
zernonia
zernonia
Troop Travel
src/test/suite/extension.test.ts
TypeScript
import * as assert from 'assert'; // You can import and use all API from the 'vscode' module // as well as import your extension to test it import * as vscode from 'vscode'; // import * as myExtension from '../../extension'; suite('Extension Test Suite', () => { vscode.window.showInformationMessage('Start all tests.'); test('Sample test', () => { assert.strictEqual(-1, [1, 2, 3].indexOf(5)); assert.strictEqual(-1, [1, 2, 3].indexOf(0)); }); });
zernonia/supabase-vscode-extension
14
Unofficial Supabase Extension
TypeScript
zernonia
zernonia
Troop Travel
src/test/suite/index.ts
TypeScript
import * as path from 'path'; import * as Mocha from 'mocha'; import * as glob from 'glob'; export function run(): Promise<void> { // Create the mocha test const mocha = new Mocha({ ui: 'tdd', color: true }); const testsRoot = path.resolve(__dirname, '..'); return new Promise((c, e) => { glob('**/**.test.js', { cwd: testsRoot }, (err, files) => { if (err) { return e(err); } // Add files to the test suite files.forEach(f => mocha.addFile(path.resolve(testsRoot, f))); try { // Run the mocha test mocha.run(failures => { if (failures > 0) { e(new Error(`${failures} tests failed.`)); } else { c(); } }); } catch (err) { console.error(err); e(err); } }); }); }
zernonia/supabase-vscode-extension
14
Unofficial Supabase Extension
TypeScript
zernonia
zernonia
Troop Travel
api/_lib/chromium.ts
TypeScript
import core from "puppeteer-core" import { getOptions } from "./options" let _page: core.Page | null export async function initPage() { if (_page) { return _page } const options = await getOptions() const browser = await core.launch(options) _page = await browser.newPage() return _page }
zernonia/supadb
47
Connect and play with Supabase REST API / Graphql easily
Vue
zernonia
zernonia
Troop Travel
api/_lib/options.ts
TypeScript
import chrome from "chrome-aws-lambda" const exePath = process.platform === "win32" ? "C:\\Program Files\\Google\\Chrome\\Application\\chrome.exe" : process.platform === "linux" ? "/usr/bin/google-chrome" : "/Applications/Google Chrome.app/Contents/MacOS/Google Chrome" interface Options { args: string[] executablePath: string headless: boolean } export async function getOptions() { let options: Options if (!process.env.AWS_REGION) { options = { args: [], executablePath: exePath, headless: true, } } else { options = { args: chrome.args, executablePath: await chrome.executablePath, headless: chrome.headless, } } return options }
zernonia/supadb
47
Connect and play with Supabase REST API / Graphql easily
Vue
zernonia
zernonia
Troop Travel
api/_lib/supabase.ts
TypeScript
import { createClient } from "@supabase/supabase-js" export const supabase = createClient(process.env.VITE_SUPABASE_URL ?? "", process.env.VITE_SUPABASE_SERVICE ?? "")
zernonia/supadb
47
Connect and play with Supabase REST API / Graphql easily
Vue
zernonia
zernonia
Troop Travel
api/_lib/verify.ts
TypeScript
import type { VercelRequest, VercelResponse } from "@vercel/node" export default (req: VercelRequest, res: VercelResponse) => { const { authorization } = req.headers if (process.env.NODE_ENV !== "development" && authorization !== `Bearer ${process.env.API_SECRET_KEY}`) { res.status(401).end("Unauthorized") return } }
zernonia/supadb
47
Connect and play with Supabase REST API / Graphql easily
Vue
zernonia
zernonia
Troop Travel
api/imdb.ts
TypeScript
import { supabase } from "./_lib/supabase" import { initPage } from "./_lib/chromium" import type { VercelRequest, VercelResponse } from "@vercel/node" import verify from "./_lib/verify" export default async (req: VercelRequest, res: VercelResponse) => { verify(req, res) var hrstart = process.hrtime() const { query } = req if (!query.genre || !query.start) { res.status(400).end("No genre or start position found") return } try { const page = await initPage() await page.goto(`https://www.imdb.com/search/title/?genres=${query.genre}&start=${query.start}`) await page.waitForSelector(".lister-list") await page.waitForSelector(".loadlate") let data = await page.$$eval(".lister-item", (item) => { // Extract the item from the data return item.map((el) => { let link = "https://www.imdb.com" + el.querySelector(".lister-item-image a")?.getAttribute("href") let id = link.match(/title\/(.*?)\//i)?.[1] let image = ( el.querySelector(".lister-item-image img")?.getAttribute("loadlate") ?? el.querySelector(".lister-item-image img")?.getAttribute("src") )?.replace(/._(.*?)_.jpg/g, ".jpg") let title = (el.querySelector(".lister-item-header a") as HTMLElement)?.innerText ?? null let year = (el.querySelector(".lister-item-header .lister-item-year") as HTMLElement)?.innerText.replace( /[()\ \s-]+/g, "" ) ?? null let certificate = (el.querySelector(".certificate") as HTMLElement)?.innerText ?? null let duration = el.querySelector(".runtime") ? +(el.querySelector(".runtime") as HTMLElement)?.innerText.replace(" min", "") : null let genre = (el.querySelector(".genre") as HTMLElement)?.innerText.split(", ") ?? null let rating = +(el.querySelector(".ratings-imdb-rating") as HTMLElement)?.innerText ?? null let metascore = +(el.querySelector(".metascore") as HTMLElement)?.innerText ?? null let description = (el.querySelector(".lister-item-content p:nth-child(4)") as HTMLElement)?.innerText ?? null let vote = el.querySelector(".sort-num_votes-visible span:nth-child(2)") ? +(el.querySelector(".sort-num_votes-visible span:nth-child(2)") as HTMLElement)?.innerText.replace(/,/g, "") : null return { id, image, link, title, year, certificate, duration, genre, rating, metascore, description, vote, } }) }) const result = await supabase.from("imdb").upsert(data) if (result.error) throw new Error(result.error.message) var hrend = process.hrtime(hrstart) console.info("Execution time (hr): %ds %dms", hrend[0], hrend[1] / 1000000) res.status(200).end("success") } catch (err) { console.log({ err }) res.status(500).end(err) } } // ** Genre ** // Comedy // Sci-Fi // Horror // Romance // Action // Thriller // Drama // Mystery // Crime // Animation // Adventure // Fantasy // Comedy-Romance // Action-Comedy // Superhero
zernonia/supadb
47
Connect and play with Supabase REST API / Graphql easily
Vue
zernonia
zernonia
Troop Travel
api/steam.ts
TypeScript
import { supabase } from "./_lib/supabase" import { initPage } from "./_lib/chromium" import type { VercelRequest, VercelResponse } from "@vercel/node" import verify from "./_lib/verify" import { Page } from "puppeteer-core" const scrapData = async (page: Page, query: any) => { return await page.$$eval( "#NewReleasesRows > a", (item, query: any) => { // Extract the item from the data return item.map((el) => { let link = el.getAttribute("href") let id = Number(link?.match(/app\/(.*?)\//i)?.[1]) let image = el.querySelector(".tab_item_cap_img")?.getAttribute("src")?.replace("capsule_184x69", "header") ?? null let title = (el.querySelector(".tab_item_name") as HTMLElement)?.innerText ?? null let price = +(el.querySelector(".discount_final_price") as HTMLElement)?.innerText?.replace(/[^\d.-]/g, "") ?? null let tags = (el.querySelector(".tab_item_top_tags") as HTMLElement)?.innerText.split(", ") ?? null let platforms = [ el.querySelector(".platform_img.win") ? "Windows" : null, el.querySelector(".platform_img.mac") ? "Mac" : null, el.querySelector(".platform_img.linux") ? "Linux" : null, ].filter((i) => i) let genre = query.genre as string return { id, link, image, title, price, tags, platforms, genre } }) }, query ) } export default async (req: VercelRequest, res: VercelResponse) => { verify(req, res) var hrstart = process.hrtime() const { query } = req if (!query.genre || !query.page) { res.status(400).end("No genre or page found") return } try { const page = await initPage() await page.goto(`https://store.steampowered.com/tags/en/${query.genre}/#p=${+query.page * 3}&tab=NewReleases`) await page.waitForSelector("#NewReleasesTable") await page.waitForNetworkIdle() let data1 = await scrapData(page, query) await Promise.all([page.click("#NewReleases_btn_next"), page.waitForNavigation()]) let data2 = await scrapData(page, query) await Promise.all([page.click("#NewReleases_btn_next"), page.waitForNavigation()]) let data3 = await scrapData(page, query) const data = [...new Map([...data1, ...data2, ...data3].map((v) => [v.id, v])).values()] const result = await supabase.from("steam").upsert(data) if (result.error) throw new Error(result.error.message) var hrend = process.hrtime(hrstart) console.info("Execution time (hr): %ds %dms", hrend[0], hrend[1] / 1000000) res.status(200).end("success") } catch (err) { console.log({ err }) res.status(500).end(err) } } // ** Genre ** // Free to Play // Early Access // Action // Adventure // Casual // Indie // Massively Multiplayer // Racing // RPG // Simulation // Sports // Strategy
zernonia/supadb
47
Connect and play with Supabase REST API / Graphql easily
Vue
zernonia
zernonia
Troop Travel
api/user/generate.ts
TypeScript
import type { VercelRequest, VercelResponse } from "@vercel/node" import jwt from "jsonwebtoken" import { supabase } from "../_lib/supabase" export default async (req: VercelRequest, res: VercelResponse) => { const { body } = req if (req.method !== "POST") { res.status(404).end("Not allowed") return } if (!body?.id) { res.status(400).end("No id is found") return } try { const result = await supabase.from("secrets").select("*").eq("user_id", body.id).single() if (result.error) throw new Error(result.error.message) // const token = jwt.decode(process.env.VITE_SUPABASE_ANON as string) as any // if (token) { // token.secret = result.data.secret // } const newToken = jwt.sign({ secret: result.data.secret }, process.env.VITE_SUPABASE_JWT_SECRET as string) res.json({ key: newToken, }) } catch (err) { console.log({ err }) res.status(500).end(err) } }
zernonia/supadb
47
Connect and play with Supabase REST API / Graphql easily
Vue
zernonia
zernonia
Troop Travel
components.d.ts
TypeScript
// generated by unplugin-vue-components // We suggest you to commit this file into source control // Read more: https://github.com/vuejs/vue-next/pull/3399 declare module 'vue' { export interface GlobalComponents { BasePage: typeof import('./src/components/BasePage.vue')['default'] CodeGraphql: typeof import('./src/components/CodeGraphql.vue')['default'] CodeInit: typeof import('./src/components/CodeInit.vue')['default'] 'CodeInit copy': typeof import('./src/components/CodeInit copy.vue')['default'] 'IHeroiconsOutline:clipboardCopy': typeof import('~icons/heroicons-outline/clipboard-copy')['default'] 'IHeroiconsOutline:home': typeof import('~icons/heroicons-outline/home')['default'] 'IHeroiconsOutline:userCircle': typeof import('~icons/heroicons-outline/user-circle')['default'] 'ISimpleIcons:github': typeof import('~icons/simple-icons/github')['default'] 'ISimpleIcons:imdb': typeof import('~icons/simple-icons/imdb')['default'] 'ISimpleIcons:steam': typeof import('~icons/simple-icons/steam')['default'] LazyImage: typeof import('./src/components/LazyImage.vue')['default'] ProductPage: typeof import('./src/components/ProductPage.vue')['default'] Tabs: typeof import('./src/components/Tabs.vue')['default'] } } export { }
zernonia/supadb
47
Connect and play with Supabase REST API / Graphql easily
Vue
zernonia
zernonia
Troop Travel
index.html
HTML
<!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8" /> <link rel="icon" href="/favicon.png" /> <link rel="preconnect" href="https://fonts.googleapis.com" /> <link rel="preconnect" href="https://fonts.gstatic.com" crossorigin /> <link href="https://fonts.googleapis.com/css2?family=Inter:wght@400;500;600;700&family=Roboto+Mono&display=swap" rel="stylesheet" /> <meta name="viewport" content="width=device-width, initial-scale=1.0" /> <title>SupaDB | Pre-Built Supabase Database for you</title> <meta name="google" content="notranslate" /> <meta name="twitter:card" content="summary_large_image" /> <meta name="twitter:site" content="@zernonia" /> <meta name="twitter:title" content="SupaDB | Pre-Built Supabase Database for you" /> <meta name="twitter:description" content="Connect and play with Free & Open Source Supabase REST API / Graphql easily." /> <meta name="twitter:image" content="https://supadb.dev/og.png" /> <meta property="og:type" content="website" /> <meta property="og:title" content="SupaDB | Pre-Built Supabase Database for you" /> <meta property="og:url" content="https://supadb.dev/" /> <meta property="og:image" content="https://supadb.dev/og.png" /> <meta property="og:description" content="Connect and play with Free & Open Source Supabase REST API / Graphql easily." /> <script async defer data-website-id="70a8ba7d-82b3-40aa-ac34-c41c8be3fbae" data-domains="supadb.dev,www.supadb.dev" src="https://umami-zernonia.vercel.app/umami.js" ></script> </head> <body> <div id="app"></div> <script type="module" src="/src/main.ts"></script> </body> </html>
zernonia/supadb
47
Connect and play with Supabase REST API / Graphql easily
Vue
zernonia
zernonia
Troop Travel