Skip to content

Commit 9dec0c9

Browse files
committed
chore: enhance docs
1 parent 8e1332a commit 9dec0c9

30 files changed

+956
-57
lines changed

docs/.vitepress/components.d.ts

+16
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
/* eslint-disable */
2+
// @ts-nocheck
3+
// Generated by unplugin-vue-components
4+
// Read more: https://github.com/vuejs/core/pull/3399
5+
export {}
6+
7+
/* prettier-ignore */
8+
declare module 'vue' {
9+
export interface GlobalComponents {
10+
Home: typeof import('./theme/components/Home.vue')['default']
11+
HomeContributors: typeof import('./theme/components/HomeContributors.vue')['default']
12+
HomeSponsors: typeof import('./theme/components/HomeSponsors.vue')['default']
13+
HomeTeam: typeof import('./theme/components/HomeTeam.vue')['default']
14+
TeamMember: typeof import('./theme/components/TeamMember.vue')['default']
15+
}
16+
}

docs/.vitepress/config.ts

+147-37
Original file line numberDiff line numberDiff line change
@@ -1,51 +1,161 @@
1-
import VueDevTools from 'vite-plugin-vue-devtools'
1+
import type { HeadConfig } from 'vitepress'
2+
import { transformerTwoslash } from '@shikijs/vitepress-twoslash'
3+
import { withPwa } from '@vite-pwa/vitepress'
24
import { defineConfig } from 'vitepress'
3-
import Local from '../../src/index'
5+
import viteConfig from './vite.config'
46

57
// https://vitepress.dev/reference/site-config
6-
export default defineConfig({
7-
title: 'vite-plugin-local',
8-
description: 'A better developer environment.',
9-
cleanUrls: true,
10-
11-
themeConfig: {
12-
// https://vitepress.dev/reference/default-theme-config
13-
nav: [
14-
{ text: 'Docs', link: '/intro' },
15-
{ text: 'Changelog', link: 'https://github.com/stacksjs/vite-plugin-local/releases' },
16-
],
178

18-
sidebar: [
9+
const analytics = {
10+
driver: 'fathom',
11+
12+
drivers: {
13+
googleAnalytics: {
14+
trackingId: 'UA-XXXXXXXXX-X',
15+
},
16+
17+
fathom: {
18+
siteId: 'WOLZMJDL',
19+
},
20+
},
21+
}
22+
23+
const fathomAnalyticsHead: HeadConfig[] = [
24+
[
25+
'script',
26+
{
27+
'src': 'https://cdn.usefathom.com/script.js',
28+
'data-site': analytics.drivers?.fathom?.siteId || '',
29+
'defer': '',
30+
},
31+
],
32+
]
33+
34+
const googleAnalyticsHead: HeadConfig[] = [
35+
[
36+
'script',
37+
{
38+
async: '',
39+
src: `https://www.googletagmanager.com/gtag/js?id=${analytics.drivers?.googleAnalytics?.trackingId}`,
40+
},
41+
],
42+
[
43+
'script',
44+
{},
45+
`window.dataLayer = window.dataLayer || [];
46+
function gtag(){dataLayer.push(arguments);}
47+
gtag('js', new Date());
48+
gtag('config', 'TAG_ID');`,
49+
],
50+
]
51+
52+
const nav = [
53+
{ text: 'Changelog', link: 'https://github.com/stacksjs/vite-plugin-local/releases' },
54+
// { text: 'Blog', link: 'https://updates.ow3.org' },
55+
{
56+
text: 'Resources',
57+
items: [
58+
{ text: 'Team', link: '/team' },
59+
{ text: 'Sponsors', link: '/sponsors' },
60+
{ text: 'Partners', link: '/partners' },
61+
{ text: 'Postcardware', link: '/postcardware' },
1962
{
20-
text: 'Get Started',
2163
items: [
22-
{ text: 'Introduction', link: '/intro' },
23-
{ text: 'Install', link: '/install' },
64+
{
65+
text: 'Awesome Stacks',
66+
link: 'https://github.com/stacksjs/awesome-stacks',
67+
},
68+
{
69+
text: 'Contributing',
70+
link: 'https://github.com/stacksjs/vite-plugin-local/blob/main/.github/CONTRIBUTING.md',
71+
},
2472
],
2573
},
2674
],
75+
},
76+
]
2777

28-
socialLinks: [
29-
{ icon: 'github', link: 'https://github.com/stacksjs/vite-plugin-local' },
30-
{ icon: 'bluesky', link: 'https://bsky.app/profile/chrisbreuer.dev' },
31-
{ icon: 'twitter', link: 'https://twitter.com/stacksjs' },
78+
const sidebar = [
79+
{
80+
text: 'Get Started',
81+
items: [
82+
{ text: 'Introduction', link: '/intro' },
83+
{ text: 'Installation', link: '/install' },
3284
],
3385
},
86+
]
87+
88+
const analyticsHead
89+
= analytics.driver === 'fathom'
90+
? fathomAnalyticsHead
91+
: analytics.driver === 'google-analytics'
92+
? googleAnalyticsHead
93+
: []
3494

35-
vite: {
36-
plugins: [
37-
// @ts-expect-error seems to be a bug in Vitepress not being ready for Vite 6 (?)
38-
Local({
39-
domain: 'stacks.localhost', // default: stacks.localhost
40-
https: true, // Use default SSL config, pass TlsConfig options to customize
41-
cleanup: {
42-
hosts: true, // Clean up relating /etc/hosts entry
43-
certs: false, // Clean up relating SSL certificates
44-
},
45-
verbose: false, // Enable detailed logging
46-
}),
47-
48-
VueDevTools(),
95+
export default withPwa(
96+
defineConfig({
97+
lang: 'en-US',
98+
title: 'vite-plugin-local',
99+
description: 'A better developer environment.',
100+
cleanUrls: true,
101+
metaChunk: true,
102+
103+
head: [
104+
['link', { rel: 'icon', type: 'image/svg+xml', href: './images/logo-mini.svg' }],
105+
['link', { rel: 'icon', type: 'image/png', href: './images/logo.png' }],
106+
['meta', { name: 'theme-color', content: '#1e40af' }],
107+
['meta', { property: 'og:type', content: 'website' }],
108+
['meta', { property: 'og:locale', content: 'en' }],
109+
['meta', { property: 'og:title', content: 'vite plugin local| A better developer environment.' }],
110+
['meta', { property: 'og:site_name', content: 'vite plugin local' }],
111+
['meta', { property: 'og:image', content: './images/og-image.png' }],
112+
['meta', { property: 'og:url', content: 'https://stacksjs.org/' }],
113+
// ['script', { 'src': 'https://cdn.usefathom.com/script.js', 'data-site': '', 'data-spa': 'auto', 'defer': '' }],
114+
...analyticsHead,
49115
],
50-
},
51-
})
116+
117+
themeConfig: {
118+
logo: './images/logo-transparent.svg',
119+
120+
nav,
121+
sidebar,
122+
123+
editLink: {
124+
pattern: 'https://github.com/stacksjs/stacks/edit/main/docs/docs/:path',
125+
text: 'Edit this page on GitHub',
126+
},
127+
128+
footer: {
129+
message: 'Released under the MIT License.',
130+
copyright: 'Copyright © 2024-present Stacks.js, Inc.',
131+
},
132+
133+
socialLinks: [
134+
{ icon: 'twitter', link: 'https://twitter.com/stacksjs' },
135+
{ icon: 'bluesky', link: 'https://bsky.app/profile/chrisbreuer.dev' },
136+
{ icon: 'github', link: 'https://github.com/stacksjs/stacks' },
137+
{ icon: 'discord', link: 'https://discord.gg/stacksjs' },
138+
],
139+
140+
// algolia: services.algolia,
141+
142+
// carbonAds: {
143+
// code: '',
144+
// placement: '',
145+
// },
146+
},
147+
148+
markdown: {
149+
theme: {
150+
light: 'vitesse-light',
151+
dark: 'vitesse-dark',
152+
},
153+
154+
codeTransformers: [
155+
transformerTwoslash(),
156+
],
157+
},
158+
159+
vite: viteConfig,
160+
}),
161+
)

docs/.vitepress/sw.ts

+123
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,123 @@
1+
/// <reference types="vite/client" />
2+
3+
/// <reference lib="webworker" />
4+
5+
import { CacheableResponsePlugin } from 'workbox-cacheable-response'
6+
import { ExpirationPlugin } from 'workbox-expiration'
7+
import { cleanupOutdatedCaches, createHandlerBoundToURL, precacheAndRoute } from 'workbox-precaching'
8+
import { NavigationRoute, registerRoute } from 'workbox-routing'
9+
import { NetworkFirst, NetworkOnly, StaleWhileRevalidate } from 'workbox-strategies'
10+
11+
declare let self: ServiceWorkerGlobalScope
12+
13+
const entries = self.__WB_MANIFEST
14+
15+
// self.__WB_MANIFEST is the default injection point
16+
precacheAndRoute(entries)
17+
18+
// clean old assets
19+
cleanupOutdatedCaches()
20+
21+
let allowlist: undefined | RegExp[]
22+
if (import.meta.env.DEV)
23+
allowlist = [/^\/$/]
24+
25+
if (import.meta.env.PROD) {
26+
const swPath = self.location.pathname.lastIndexOf('/')
27+
const base = swPath === 0 ? '/' : self.location.pathname.slice(0, swPath + 1)
28+
function escapeStringRegexp(value: string) {
29+
// Escape characters with special meaning either inside or outside character sets.
30+
// 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.
31+
return value
32+
.replace(/[|\\{}()[\]^$+*?.]/g, '\\$&')
33+
.replace(/-/g, '\\x2d')
34+
}
35+
allowlist = entries.filter((page) => {
36+
return typeof page === 'string'
37+
? page.endsWith('.html')
38+
: page.url.endsWith('.html')
39+
}).map((page) => {
40+
const url = typeof page === 'string' ? page : page.url
41+
const regex = url === 'index.html'
42+
? escapeStringRegexp(base)
43+
: escapeStringRegexp(`${base}${url.replace(/\.html$/, '')}`)
44+
return new RegExp(`^${regex}(\\.html)?$`)
45+
})
46+
registerRoute(
47+
({ request, sameOrigin }) => {
48+
return sameOrigin && request.mode === 'navigate'
49+
},
50+
new NetworkOnly({
51+
plugins: [{
52+
/* this callback will be called when the fetch call fails */
53+
handlerDidError: async () => Response.redirect('404', 302),
54+
/* this callback will prevent caching the response */
55+
cacheWillUpdate: async () => null,
56+
}],
57+
}),
58+
'GET',
59+
)
60+
// googleapis
61+
registerRoute(
62+
/^https:\/\/fonts\.googleapis\.com\/.*/i,
63+
new NetworkFirst({
64+
cacheName: 'google-fonts-cache',
65+
plugins: [
66+
new CacheableResponsePlugin({ statuses: [0, 200] }),
67+
// we only need a few entries
68+
new ExpirationPlugin({
69+
maxEntries: 10,
70+
maxAgeSeconds: 60 * 60 * 24 * 365, // <== 365 days
71+
}),
72+
],
73+
}),
74+
)
75+
// gstatic
76+
registerRoute(
77+
/^https:\/\/fonts\.gstatic\.com\/.*/i,
78+
new StaleWhileRevalidate({
79+
cacheName: 'google-fonts-cache',
80+
plugins: [
81+
new CacheableResponsePlugin({ statuses: [0, 200] }),
82+
// we only need a few entries
83+
new ExpirationPlugin({
84+
maxEntries: 10,
85+
maxAgeSeconds: 60 * 60 * 24 * 365, // <== 365 days
86+
}),
87+
],
88+
}),
89+
)
90+
// antfu sponsors
91+
registerRoute(
92+
/^https:\/\/cdn\.jsdelivr\.net\/.*/i,
93+
new NetworkFirst({
94+
cacheName: 'jsdelivr-images-cache',
95+
plugins: [
96+
new CacheableResponsePlugin({ statuses: [0, 200] }),
97+
// we only need a few entries
98+
new ExpirationPlugin({
99+
maxEntries: 10,
100+
maxAgeSeconds: 60 * 60 * 24 * 7, // <== 7 days
101+
}),
102+
],
103+
}),
104+
)
105+
}
106+
107+
// to allow work offline
108+
registerRoute(new NavigationRoute(
109+
createHandlerBoundToURL('index.html'),
110+
{ allowlist },
111+
))
112+
113+
// Skip-Waiting Service Worker-based solution
114+
self.addEventListener('activate', async () => {
115+
// after we've taken over, iterate over all the current clients (windows)
116+
const clients = await self.clients.matchAll({ type: 'window' })
117+
clients.forEach((client) => {
118+
// ...and refresh each one of them
119+
client.navigate(client.url)
120+
})
121+
})
122+
123+
self.skipWaiting()
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
<template>
2+
<div class="flex flex-col items-center mt-4 home">
3+
<HomeTeam />
4+
5+
<HomeSponsors />
6+
7+
<HomeContributors />
8+
</div>
9+
</template>
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
<script setup lang="ts">
2+
import { contributors } from './contributors'
3+
</script>
4+
5+
<template>
6+
<div class="vp-doc">
7+
<h2 pb-2 pt-5 font-normal op50>
8+
Contributors
9+
</h2>
10+
</div>
11+
12+
<div max-w-200 p-10 text-center text-lg leading-7>
13+
<div flex="~ wrap gap-1" justify-center>
14+
<a v-for="{ name, avatar } of contributors" :key="name" :href="`https://github.com/${name}`" m-0 rel="noopener noreferrer" :aria-label="`${name} on GitHub`">
15+
<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`">
16+
</a>
17+
</div>
18+
<br>
19+
</div>
20+
</template>
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
<template>
2+
<div class="vp-doc">
3+
<h2 pb-2 pt-5 font-normal op50>
4+
Stacks Sponsors
5+
</h2>
6+
</div>
7+
8+
<p id="sponsor" class="mt-5 text-center">
9+
<a href="https://github.com/sponsors/chrisbbreuer">
10+
<img src="https://cdn.jsdelivr.net/gh/stacksjs/sponsors/sponsorkit/sponsors.svg" class="m-auto">
11+
</a>
12+
</p>
13+
14+
<p class="mt-5 text-center">
15+
<a href="https://github.com/sponsors/chrisbbreuer" class="text-xs italic">
16+
Click here to become a sponsor.
17+
</a>
18+
</p>
19+
</template>

0 commit comments

Comments
 (0)