Skip to content

Commit

Permalink
docs: enhance documentation
Browse files Browse the repository at this point in the history
  • Loading branch information
cab-mikee committed Dec 20, 2024
1 parent bc4796e commit 79445b1
Show file tree
Hide file tree
Showing 31 changed files with 962 additions and 53 deletions.
16 changes: 16 additions & 0 deletions docs/.vitepress/components.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
/* eslint-disable */
// @ts-nocheck
// Generated by unplugin-vue-components
// Read more: https://github.com/vuejs/core/pull/3399
export {}

/* prettier-ignore */
declare module 'vue' {
export interface GlobalComponents {
Home: typeof import('./theme/components/Home.vue')['default']
HomeContributors: typeof import('./theme/components/HomeContributors.vue')['default']
HomeSponsors: typeof import('./theme/components/HomeSponsors.vue')['default']
HomeTeam: typeof import('./theme/components/HomeTeam.vue')['default']
TeamMember: typeof import('./theme/components/TeamMember.vue')['default']
}
}
142 changes: 122 additions & 20 deletions docs/.vitepress/config.ts
Original file line number Diff line number Diff line change
@@ -1,32 +1,134 @@
import type { HeadConfig } from 'vitepress'
import { transformerTwoslash } from '@shikijs/vitepress-twoslash'
import { withPwa } from '@vite-pwa/vitepress'
import { defineConfig } from 'vitepress'

import viteConfig from './vite.config'

// https://vitepress.dev/reference/site-config
export default defineConfig({
title: 'bunfig',
description: 'A smart config leader for Bun projects.',
cleanUrls: true,

themeConfig: {
// https://vitepress.dev/reference/default-theme-config
nav: [
{ text: 'Docs', link: '/intro' },
{ text: 'Changelog', link: 'https://github.com/stacksjs/bunfig/releases' },
],

sidebar: [
const analyticsHead: HeadConfig[] = [
[
'script',
{
'src': 'https://cdn.usefathom.com/script.js',
'data-site': 'JWZWSUOY',
'defer': '',
},
],
]

const nav = [
{
text: 'Changelog',
link: 'https://github.com/stacksjs/bunfig/blob/main/CHANGELOG.md',
},
// { text: 'Blog', link: 'https://updates.ow3.org' },
{
text: 'Resources',
items: [
{ text: 'Team', link: '/team' },
{ text: 'Sponsors', link: '/sponsors' },
{ text: 'Partners', link: '/partners' },
{ text: 'Postcardware', link: '/postcardware' },
{
text: 'Get Started',
items: [
{ text: 'Introduction', link: '/intro' },
{ text: 'Install', link: '/install' },
{
text: 'Awesome Stacks',
link: 'https://github.com/stacksjs/awesome-stacks',
},
{
text: 'Contributing',
link: 'https://github.com/stacksjs/stacks/blob/main/.github/CONTRIBUTING.md',
},
],
},
],
},
]

socialLinks: [
{ icon: 'github', link: 'https://github.com/stacksjs/bunfig' },
{ icon: 'bluesky', link: 'https://bsky.app/profile/chrisbreuer.dev' },
{ icon: 'twitter', link: 'https://twitter.com/stacksjs' },
const sidebar = [
{
text: 'Get Started',
items: [
{ text: 'Introduction', link: '/intro' },
{ text: 'Install', link: '/install' },
{ text: 'Usage', link: '/usage' },
],
},
})
]

export default withPwa(
defineConfig({
lang: 'en-US',
title: 'bunfig',
description: 'A smart config leader for Bun projects.',
lastUpdated: true,
cleanUrls: true,
metaChunk: true,

head: [
['link', { rel: 'icon', type: 'image/svg+xml', href: './images/logo-mini.svg' }],
['link', { rel: 'icon', type: 'image/png', href: './images/logo.png' }],
['meta', { name: 'theme-color', content: '#0A0ABC' }],
['meta', { property: 'og:type', content: 'website' }],
['meta', { property: 'og:locale', content: 'en' }],
['meta', { property: 'og:title', content: 'bunfig | A smart config leader for Bun projects.' }],
['meta', { property: 'og:site_name', content: 'bunfig' }],
['meta', { property: 'og:image', content: './images/og-image.jpg' }],
['meta', { property: 'og:url', content: 'https://bunfig.netlify.app/' }],
// ['script', { 'src': 'https://cdn.usefathom.com/script.js', 'data-site': '', 'data-spa': 'auto', 'defer': '' }],
...analyticsHead,
],

themeConfig: {
logo: './images/logo-transparent.svg',

nav,
sidebar,

editLink: {
pattern: 'https://github.com/stacksjs/stacks/edit/main/docs/docs/:path',
text: 'Edit this page on GitHub',
},

footer: {
message: 'Released under the MIT License.',
copyright: 'Copyright © 2024-present Stacks.js, Inc.',
},

socialLinks: [
{ icon: 'twitter', link: 'https://twitter.com/stacksjs' },
{ icon: 'bluesky', link: 'https://bsky.app/profile/chrisbreuer.dev' },
{ icon: 'github', link: 'https://github.com/stacksjs/bunfig' },
{ icon: 'discord', link: 'https://discord.gg/stacksjs' },
],

// algolia: services.algolia,

// carbonAds: {
// code: '',
// placement: '',
// },
},

pwa: {
manifest: {
theme_color: '#0A0ABC',
},
},

markdown: {
theme: {
light: 'vitesse-light',
dark: 'vitesse-dark',
},

codeTransformers: [
transformerTwoslash(),
],
},

vite: viteConfig,
}),
)
123 changes: 123 additions & 0 deletions docs/.vitepress/sw.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,123 @@
/// <reference types="vite/client" />

/// <reference lib="webworker" />

import { CacheableResponsePlugin } from 'workbox-cacheable-response'
import { ExpirationPlugin } from 'workbox-expiration'
import { cleanupOutdatedCaches, createHandlerBoundToURL, precacheAndRoute } from 'workbox-precaching'
import { NavigationRoute, registerRoute } from 'workbox-routing'
import { NetworkFirst, NetworkOnly, StaleWhileRevalidate } from 'workbox-strategies'

declare let self: ServiceWorkerGlobalScope

const entries = self.__WB_MANIFEST

// self.__WB_MANIFEST is the default injection point
precacheAndRoute(entries)

// clean old assets
cleanupOutdatedCaches()

let allowlist: undefined | RegExp[]
if (import.meta.env.DEV)
allowlist = [/^\/$/]

if (import.meta.env.PROD) {
const swPath = self.location.pathname.lastIndexOf('/')
const base = swPath === 0 ? '/' : self.location.pathname.slice(0, swPath + 1)
function escapeStringRegexp(value: string) {
// Escape characters with special meaning either inside or outside character sets.
// Use a simple backslash escape when it’s always valid, and a `\xnn` escape when the simpler form would be disallowed by Unicode patterns’ stricter grammar.
return value
.replace(/[|\\{}()[\]^$+*?.]/g, '\\$&')
.replace(/-/g, '\\x2d')
}
allowlist = entries.filter((page) => {
return typeof page === 'string'
? page.endsWith('.html')
: page.url.endsWith('.html')
}).map((page) => {
const url = typeof page === 'string' ? page : page.url
const regex = url === 'index.html'
? escapeStringRegexp(base)
: escapeStringRegexp(`${base}${url.replace(/\.html$/, '')}`)
return new RegExp(`^${regex}(\\.html)?$`)
})
registerRoute(
({ request, sameOrigin }) => {
return sameOrigin && request.mode === 'navigate'
},
new NetworkOnly({
plugins: [{
/* this callback will be called when the fetch call fails */
handlerDidError: async () => Response.redirect('404', 302),
/* this callback will prevent caching the response */
cacheWillUpdate: async () => null,
}],
}),
'GET',
)
// googleapis
registerRoute(
/^https:\/\/fonts\.googleapis\.com\/.*/i,
new NetworkFirst({
cacheName: 'google-fonts-cache',
plugins: [
new CacheableResponsePlugin({ statuses: [0, 200] }),
// we only need a few entries
new ExpirationPlugin({
maxEntries: 10,
maxAgeSeconds: 60 * 60 * 24 * 365, // <== 365 days
}),
],
}),
)
// gstatic
registerRoute(
/^https:\/\/fonts\.gstatic\.com\/.*/i,
new StaleWhileRevalidate({
cacheName: 'google-fonts-cache',
plugins: [
new CacheableResponsePlugin({ statuses: [0, 200] }),
// we only need a few entries
new ExpirationPlugin({
maxEntries: 10,
maxAgeSeconds: 60 * 60 * 24 * 365, // <== 365 days
}),
],
}),
)
// antfu sponsors
registerRoute(
/^https:\/\/cdn\.jsdelivr\.net\/.*/i,
new NetworkFirst({
cacheName: 'jsdelivr-images-cache',
plugins: [
new CacheableResponsePlugin({ statuses: [0, 200] }),
// we only need a few entries
new ExpirationPlugin({
maxEntries: 10,
maxAgeSeconds: 60 * 60 * 24 * 7, // <== 7 days
}),
],
}),
)
}

// to allow work offline
registerRoute(new NavigationRoute(
createHandlerBoundToURL('index.html'),
{ allowlist },
))

// Skip-Waiting Service Worker-based solution
self.addEventListener('activate', async () => {
// after we've taken over, iterate over all the current clients (windows)
const clients = await self.clients.matchAll({ type: 'window' })
clients.forEach((client) => {
// ...and refresh each one of them
client.navigate(client.url)
})
})

self.skipWaiting()
9 changes: 9 additions & 0 deletions docs/.vitepress/theme/components/Home.vue
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
<template>
<div class="flex flex-col items-center mt-4 home">
<HomeTeam />

<HomeSponsors />

<HomeContributors />
</div>
</template>
20 changes: 20 additions & 0 deletions docs/.vitepress/theme/components/HomeContributors.vue
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
<script setup lang="ts">
import { contributors } from './contributors'
</script>

<template>
<div class="vp-doc">
<h2 pb-2 pt-5 font-normal op50>
Contributors
</h2>
</div>

<div max-w-200 p-10 text-center text-lg leading-7>
<div flex="~ wrap gap-1" justify-center>
<a v-for="{ name, avatar } of contributors" :key="name" :href="`https://github.com/${name}`" m-0 rel="noopener noreferrer" :aria-label="`${name} on GitHub`">
<img loading="lazy" :src="avatar" width="40" height="40" h-10 min-h-10 min-w-10 w-10 rounded-full :alt="`${name}'s avatar`">
</a>
</div>
<br>
</div>
</template>
19 changes: 19 additions & 0 deletions docs/.vitepress/theme/components/HomeSponsors.vue
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
<template>
<div class="vp-doc">
<h2 pb-2 pt-5 font-normal op50>
Stacks Sponsors
</h2>
</div>

<p id="sponsor" class="mt-5 text-center">
<a href="https://github.com/sponsors/chrisbbreuer">
<img src="https://cdn.jsdelivr.net/gh/stacksjs/sponsors/sponsorkit/sponsors.svg" class="m-auto">
</a>
</p>

<p class="mt-5 text-center">
<a href="https://github.com/sponsors/chrisbbreuer" class="text-xs italic">
Click here to become a sponsor.
</a>
</p>
</template>
20 changes: 20 additions & 0 deletions docs/.vitepress/theme/components/HomeTeam.vue
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
<script setup lang="ts">
import { coreTeamMembers } from './contributors'
</script>

<template>
<div class="vp-doc">
<h2 pb-2 pt-5 font-normal op50>
Meet The Team
</h2>
</div>

<div grid="~ cols-2 lg:cols-4 gap-x-3 gap-y-20 items-stretch" p-10>
<TeamMember
v-for="c of coreTeamMembers"
:key="c.github"
:data="c"
class="flex flex-col items-center text-center p-4 h-full"
/>
</div>
</template>
Loading

0 comments on commit 79445b1

Please sign in to comment.