Skip to content

Commit

Permalink
chore: orangize
Browse files Browse the repository at this point in the history
  • Loading branch information
antfu committed Jun 3, 2022
1 parent d55147c commit be39cf9
Show file tree
Hide file tree
Showing 19 changed files with 58 additions and 55 deletions.
10 changes: 5 additions & 5 deletions docs/components.d.ts → docs/.vitepress/components.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,13 +5,13 @@ import '@vue/runtime-core'

declare module '@vue/runtime-core' {
export interface GlobalComponents {
Contributors: typeof import('./src/components/Contributors.vue')['default']
FeaturesList: typeof import('./src/components/FeaturesList.vue')['default']
HomePage: typeof import('./src/components/HomePage.vue')['default']
ListItem: typeof import('./src/components/ListItem.vue')['default']
Contributors: typeof import('./components/Contributors.vue')['default']
FeaturesList: typeof import('./components/FeaturesList.vue')['default']
HomePage: typeof import('./components/HomePage.vue')['default']
ListItem: typeof import('./components/ListItem.vue')['default']
RouterLink: typeof import('vue-router')['RouterLink']
RouterView: typeof import('vue-router')['RouterView']
TeamMember: typeof import('./src/components/TeamMember.vue')['default']
TeamMember: typeof import('./components/TeamMember.vue')['default']
}
}

Expand Down
File renamed without changes.
File renamed without changes.
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
<script setup lang="ts">
import { coreTeamMembers } from '../contributors'
import { teamMembers } from '../contributors'
</script>

<template>
Expand All @@ -12,7 +12,7 @@ import { coreTeamMembers } from '../contributors'
</h2>
<div grid="~ cols-1 md:cols-2 lg:cols-3 gap-x-10 gap-y-10 items-center" p-10>
<TeamMember
v-for="c of coreTeamMembers"
v-for="c of teamMembers"
:key="c.github"
v-bind="c"
/>
Expand Down
File renamed without changes.
File renamed without changes.
6 changes: 3 additions & 3 deletions docs/.vitepress/config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,8 @@ import {
twitter,
vitestDescription,
vitestName,
} from '../docs-data'
import { coreTeamMembers } from '../src/contributors'
} from './meta'
import { teamMembers } from './contributors'

export default defineConfig({
lang: 'en-US',
Expand All @@ -22,7 +22,7 @@ export default defineConfig({
['meta', { name: 'theme-color', content: '#ffffff' }],
['link', { rel: 'icon', href: '/logo.svg', type: 'image/svg+xml' }],
['link', { rel: 'alternate icon', href: '/favicon.ico', type: 'image/png', sizes: '16x16' }],
['meta', { name: 'author', content: `${coreTeamMembers.map(c => c.name).join(', ')} and ${vitestName} contributors` }],
['meta', { name: 'author', content: `${teamMembers.map(c => c.name).join(', ')} and ${vitestName} contributors` }],
['meta', { name: 'keywords', content: 'vitest, vite, test, coverage, snapshot, react, vue, preact, svelte, solid, lit, ruby, cypress, puppeteer, jsdom, happy-dom, test-runner, jest, typescript, esm, tinypool, tinyspy, c8, node' }],
['meta', { property: 'og:title', content: vitestName }],
['meta', { property: 'og:description', content: vitestDescription }],
Expand Down
File renamed without changes.
8 changes: 3 additions & 5 deletions docs/src/contributors.ts → docs/.vitepress/contributors.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import contributors from '../contributors.json'
import contributorNames from './contributor-names.json'

export interface Contributor {
name: string
Expand All @@ -18,13 +18,13 @@ const contributorsAvatars: Record<string, string> = {}

const getAvatarUrl = (name: string) => import.meta.hot ? `https://github.com/${name}.png` : `/user-avatars/${name}.png`

const contributorList = (contributors as string[]).reduce((acc, name) => {
export const contributors = (contributorNames as string[]).reduce((acc, name) => {
contributorsAvatars[name] = getAvatarUrl(name)
acc.push({ name, avatar: contributorsAvatars[name] })
return acc
}, [] as Contributor[])

const coreTeamMembers: CoreTeam[] = [
export const teamMembers: CoreTeam[] = [
{
avatar: contributorsAvatars.antfu,
name: 'Anthony Fu',
Expand Down Expand Up @@ -82,5 +82,3 @@ const coreTeamMembers: CoreTeam[] = [
description: 'A fullstack developer<br>Creating tools for collaboration',
},
]

export { coreTeamMembers, contributorList as contributors }
File renamed without changes.
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { promises as fs } from 'fs'
import fg from 'fast-glob'
import { font, preconnectHomeLinks, preconnectLinks } from '../docs-data'
import { font, preconnectHomeLinks, preconnectLinks } from '../meta'

const preconnect = `
${preconnectLinks.map(l => `<link rel="dns-prefetch" href="${l}">`).join('\n')}
Expand Down
35 changes: 35 additions & 0 deletions docs/.vitepress/scripts/fetch-avatars.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
import { join, resolve } from 'pathe'
import fs from 'fs-extra'
import { $fetch } from 'ohmyfetch'
import { teamMembers } from '../contributors'

const docsDir = resolve(__dirname, '../..')
const pathContributors = resolve(docsDir, '.vitepress/contributor-names.json')
const dirAvatars = resolve(docsDir, 'public/user-avatars/')
const dirSponsors = resolve(docsDir, 'public/sponsors/')

let contributors: string[] = []
const team = teamMembers.map(i => i.github)

async function download(url: string, fileName: string) {
// eslint-disable-next-line no-console
console.log('downloading', fileName)
const image = await $fetch(url, { responseType: 'arrayBuffer' })
await fs.writeFile(fileName, Buffer.from(image))
}

async function fetchAvatars() {
await fs.ensureDir(dirAvatars)
contributors = JSON.parse(await fs.readFile(pathContributors, { encoding: 'utf-8' }))

await Promise.all(contributors.map(name => download(`https://github.com/${name}.png?size${team.includes(name) ? 100 : 40}`, join(dirAvatars, 'name.png'))))
}

async function fetchSponsors() {
await fs.ensureDir(dirSponsors)
await download('https://cdn.jsdelivr.net/gh/antfu/static/sponsors.svg', join(dirSponsors, 'antfu.svg'))
await download('https://cdn.jsdelivr.net/gh/patak-dev/static/sponsors.svg', join(dirSponsors, 'patak-dev.svg'))
}

fetchAvatars()
fetchSponsors()
File renamed without changes.
File renamed without changes.
6 changes: 3 additions & 3 deletions docs/.vitepress/theme/index.ts
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
import { h } from 'vue'
import Theme from 'vitepress/theme'
import { inBrowser } from 'vitepress'
import '../../main.css'
import '../../style/vars.css'
import '../style/main.css'
import '../style/vars.css'
import 'uno.css'
import HomePage from '../../src/components/HomePage.vue'
import HomePage from '../components/HomePage.vue'

if (inBrowser)
import('./pwa')
Expand Down
2 changes: 1 addition & 1 deletion docs/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
"build": "nr prefetch && vitepress build",
"serve": "vitepress serve",
"preview-https": "pnpm run build && serve .vitepress/dist",
"prefetch": "esno scripts/fetch-avatars.ts"
"prefetch": "esno .vitepress/scripts/fetch-avatars.ts"
},
"dependencies": {
"@vueuse/core": "^8.5.0",
Expand Down
31 changes: 0 additions & 31 deletions docs/scripts/fetch-avatars.ts

This file was deleted.

7 changes: 4 additions & 3 deletions docs/vite.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,8 @@ import {
vitestDescription,
vitestName,
vitestShortName,
} from './docs-data'
import { optimizePages } from './scripts/assets'
} from './.vitepress/meta'
import { optimizePages } from './.vitepress/scripts/assets'

const PWA = VitePWA({
outDir: '.vitepress/dist',
Expand Down Expand Up @@ -86,7 +86,8 @@ export default defineConfig({
plugins: [
Components({
include: [/\.vue/, /\.md/],
dts: true,
dirs: '.vitepress/components',
dts: '.vitepress/components.d.ts',
}),
Unocss({
shortcuts: [
Expand Down
2 changes: 1 addition & 1 deletion scripts/update-contributors.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ async function fetchContributors(page = 1) {

async function generate() {
const collaborators = await fetchContributors()
await fs.writeFile('./docs/contributors.json', JSON.stringify(collaborators, null, 2), 'utf8')
await fs.writeFile('./docs/.vitepress/contributor-names.json', JSON.stringify(collaborators, null, 2), 'utf8')
}

generate()

0 comments on commit be39cf9

Please sign in to comment.