|
| 1 | +import { defineConfig, type HeadConfig } from 'vitepress' |
| 2 | +import { version } from '../../package.json' |
| 3 | + |
| 4 | +const SITE_URL = 'https://www.fusejs.io' |
| 5 | +const GA_MEASUREMENT_ID = 'G-78VK1PFWH1' |
| 6 | +const GOOGLE_SITE_VERIFICATION = '4nm40QLVcDJmEJSAbrMfZ7fpBJZIXL1oSngBAYrZopY' |
| 7 | + |
| 8 | +export default defineConfig({ |
| 9 | + lang: 'en-US', |
| 10 | + title: 'Fuse.js', |
| 11 | + description: 'Lightweight fuzzy-search library, in JavaScript', |
| 12 | + |
| 13 | + cleanUrls: false, |
| 14 | + |
| 15 | + sitemap: { |
| 16 | + hostname: SITE_URL |
| 17 | + }, |
| 18 | + |
| 19 | + head: getHead(), |
| 20 | + |
| 21 | + themeConfig: { |
| 22 | + logo: '/assets/img/logo.png', |
| 23 | + |
| 24 | + nav: [ |
| 25 | + { text: 'Docs', link: '/' }, |
| 26 | + { text: 'Demo', link: '/demo' }, |
| 27 | + { text: 'Sponsor', link: '/sponsor' }, |
| 28 | + { text: 'Cloud', link: '/cloud' } |
| 29 | + ], |
| 30 | + |
| 31 | + sidebar: [ |
| 32 | + { text: 'Getting Started', link: '/getting-started' }, |
| 33 | + { text: 'Fuzzy Search', link: '/fuzzy-search' }, |
| 34 | + { text: 'Token Search', link: '/token-search' }, |
| 35 | + { text: 'Extended Search', link: '/extended-search' }, |
| 36 | + { text: 'Logical Search', link: '/logical-search' }, |
| 37 | + { text: 'Web Workers', link: '/web-workers' }, |
| 38 | + { text: 'Performance', link: '/performance' }, |
| 39 | + { |
| 40 | + text: 'Articles', |
| 41 | + items: [ |
| 42 | + { text: 'Using Fuse with React', link: '/articles/using-fuse-with-react' }, |
| 43 | + { text: 'vs Semantic Search', link: '/articles/vs-semantic-search' }, |
| 44 | + { text: 'How Fuzzy Search Works', link: '/articles/how-fuzzy-search-works' } |
| 45 | + ] |
| 46 | + } |
| 47 | + ], |
| 48 | + |
| 49 | + outline: { level: [2, 3], label: 'On this page' }, |
| 50 | + |
| 51 | + socialLinks: [ |
| 52 | + { icon: 'github', link: 'https://github.com/krisk/fuse' }, |
| 53 | + { icon: 'x', link: 'https://x.com/kirorisk' } |
| 54 | + ], |
| 55 | + |
| 56 | + search: { |
| 57 | + provider: 'local' |
| 58 | + }, |
| 59 | + |
| 60 | + docFooter: { |
| 61 | + prev: 'Previous', |
| 62 | + next: 'Next' |
| 63 | + }, |
| 64 | + |
| 65 | + editLink: undefined |
| 66 | + }, |
| 67 | + |
| 68 | + markdown: { |
| 69 | + theme: { light: 'github-dark', dark: 'github-dark' } |
| 70 | + }, |
| 71 | + |
| 72 | + vite: { |
| 73 | + server: { port: 3000 }, |
| 74 | + optimizeDeps: { |
| 75 | + include: ['monaco-editor'] |
| 76 | + } |
| 77 | + } |
| 78 | +}) |
| 79 | + |
| 80 | +function getHead(): HeadConfig[] { |
| 81 | + const appleTouchIcons: HeadConfig[] = [ |
| 82 | + '57x57', |
| 83 | + '60x60', |
| 84 | + '72x72', |
| 85 | + '76x76', |
| 86 | + '114x114', |
| 87 | + '120x120', |
| 88 | + '144x144', |
| 89 | + '152x152', |
| 90 | + '180x180' |
| 91 | + ].map((size) => [ |
| 92 | + 'link', |
| 93 | + { rel: 'apple-touch-icon', size, href: `/icons/apple-icon-${size}.png` } |
| 94 | + ]) |
| 95 | + |
| 96 | + const sizedIcons: HeadConfig[] = [ |
| 97 | + { size: '192x192', href: 'android-icon-192x192.png' }, |
| 98 | + { size: '32x32', href: 'favicon-32x32.png' }, |
| 99 | + { size: '96x96', href: 'favicon-96x96.png' }, |
| 100 | + { size: '16x16', href: 'favicon-16x16.png' } |
| 101 | + ].map(({ size, href }) => [ |
| 102 | + 'link', |
| 103 | + { rel: 'icon', type: 'image/png', size, href: `/icons/${href}` } |
| 104 | + ]) |
| 105 | + |
| 106 | + const meta: HeadConfig[] = [ |
| 107 | + ['meta', { name: 'msapplication-TileColor', content: '#ffffff' }], |
| 108 | + ['meta', { name: 'msapplication-TileImage', content: '/icons/ms-icon-144x144.png' }], |
| 109 | + ['meta', { name: 'theme-color', content: '#ffffff' }], |
| 110 | + ['meta', { name: 'google-site-verification', content: GOOGLE_SITE_VERIFICATION }] |
| 111 | + ] |
| 112 | + |
| 113 | + const og: HeadConfig[] = [ |
| 114 | + ['meta', { property: 'og:type', content: 'website' }], |
| 115 | + ['meta', { property: 'og:site_name', content: 'Fuse.js' }], |
| 116 | + ['meta', { property: 'og:title', content: 'Fuse.js — Lightweight Fuzzy-Search Library' }], |
| 117 | + ['meta', { property: 'og:description', content: 'Powerful, lightweight fuzzy-search library for JavaScript with zero dependencies.' }], |
| 118 | + ['meta', { property: 'og:url', content: SITE_URL }], |
| 119 | + ['meta', { property: 'og:image', content: `${SITE_URL}/assets/img/logo.png` }], |
| 120 | + ['meta', { name: 'twitter:card', content: 'summary' }], |
| 121 | + ['meta', { name: 'twitter:site', content: '@kirorisk' }], |
| 122 | + ['meta', { name: 'twitter:title', content: 'Fuse.js — Lightweight Fuzzy-Search Library' }], |
| 123 | + ['meta', { name: 'twitter:description', content: 'Powerful, lightweight fuzzy-search library for JavaScript with zero dependencies.' }], |
| 124 | + ['meta', { name: 'twitter:image', content: `${SITE_URL}/assets/img/logo.png` }] |
| 125 | + ] |
| 126 | + |
| 127 | + const ga: HeadConfig[] = [ |
| 128 | + ['script', { async: '', src: `https://www.googletagmanager.com/gtag/js?id=${GA_MEASUREMENT_ID}` }], |
| 129 | + [ |
| 130 | + 'script', |
| 131 | + {}, |
| 132 | + `window.dataLayer = window.dataLayer || []; |
| 133 | +function gtag(){dataLayer.push(arguments);} |
| 134 | +gtag('js', new Date()); |
| 135 | +gtag('config', '${GA_MEASUREMENT_ID}');` |
| 136 | + ] |
| 137 | + ] |
| 138 | + |
| 139 | + return [ |
| 140 | + ...appleTouchIcons, |
| 141 | + ...sizedIcons, |
| 142 | + ...meta, |
| 143 | + ...og, |
| 144 | + ['link', { rel: 'manifest', href: '/manifest.webmanifest' }], |
| 145 | + ...ga |
| 146 | + ] |
| 147 | +} |
0 commit comments