mirror of
https://github.com/tabler/tabler.git
synced 2026-08-28 12:56:24 +04:00
140 lines
5.1 KiB
JavaScript
140 lines
5.1 KiB
JavaScript
// @ts-check
|
|
import { defineConfig, envField } from 'astro/config'
|
|
import vercel from '@astrojs/vercel'
|
|
import mdx from '@astrojs/mdx'
|
|
import { satteri } from '@astrojs/markdown-satteri'
|
|
import { fileURLToPath } from 'node:url'
|
|
import { copyAssets } from '../.build/copy-assets'
|
|
|
|
/** @param {string} p */
|
|
const path = (p) => fileURLToPath(new URL(p, import.meta.url))
|
|
|
|
// https://astro.build/config
|
|
export default defineConfig({
|
|
site: 'https://docs.tabler.io',
|
|
env: {
|
|
// DocSearch/Algolia config for the docs search (see DocsNavbar.astro).
|
|
// Values come from the environment only (.env locally, project settings on
|
|
// Vercel) — see .env.example. When unset, the search input is hidden.
|
|
schema: {
|
|
DOCSEARCH_APP_ID: envField.string({ context: 'client', access: 'public', optional: true }),
|
|
DOCSEARCH_INDEX_NAME: envField.string({ context: 'client', access: 'public', optional: true }),
|
|
DOCSEARCH_API_KEY: envField.string({ context: 'client', access: 'public', optional: true }),
|
|
},
|
|
},
|
|
// Static output + the Vercel adapter: turns `redirects` below into real HTTP
|
|
// redirects at Vercel's routing layer (no adapter = meta-refresh HTML pages).
|
|
adapter: vercel({
|
|
webAnalytics: {
|
|
enabled: true,
|
|
},
|
|
}),
|
|
// Renamed/moved pages. Add an entry here whenever a docs URL changes.
|
|
// The plural component slugs are the pre-Astro URLs still present in the
|
|
// Google index, Algolia search results and external backlinks.
|
|
redirects: {
|
|
'/ui/base/markdown': { status: 301, destination: '/ui/base/prose' },
|
|
...Object.fromEntries(
|
|
[
|
|
['alerts', 'alert'],
|
|
['avatars', 'avatar'],
|
|
['badges', 'badge'],
|
|
['buttons', 'button'],
|
|
['cards', 'card'],
|
|
['charts', 'chart'],
|
|
['dropdowns', 'dropdown'],
|
|
['icons', 'icon'],
|
|
['modals', 'modal'],
|
|
['ribbons', 'ribbon'],
|
|
['spinners', 'spinner'],
|
|
['statuses', 'status'],
|
|
['steps', 'step'],
|
|
['tables', 'table'],
|
|
['tabs', 'tab'],
|
|
['timelines', 'timeline'],
|
|
['toasts', 'toast'],
|
|
['tooltips', 'tooltip'],
|
|
['vector-maps', 'vector-map'],
|
|
].map(([from, to]) => [`/ui/components/${from}`, { status: 301, destination: `/ui/components/${to}` }]),
|
|
),
|
|
},
|
|
// pages live at the package root (./pages) — content-first layout; all
|
|
// components/lib/data are shared (see the @shared alias). The docs content
|
|
// itself lives in ./content and is rendered by pages/[...slug].astro.
|
|
srcDir: '.',
|
|
server: {
|
|
port: 3010,
|
|
// bind on all interfaces so the dev server is reachable from Docker
|
|
// port mappings and other devices on the local network
|
|
host: true,
|
|
},
|
|
vite: {
|
|
define: {
|
|
TABLER_STATIC_BASE: JSON.stringify('/static'),
|
|
},
|
|
resolve: {
|
|
alias: {
|
|
'@data': fileURLToPath(new URL('../shared/data', import.meta.url)),
|
|
// Astro components/lib shared with preview (single source of truth)
|
|
'@shared': fileURLToPath(new URL('../shared', import.meta.url)),
|
|
'@ui': fileURLToPath(new URL('../shared/ui', import.meta.url)),
|
|
// docs-only components (Example, DocsMenu, …)
|
|
'@components': fileURLToPath(new URL('./components', import.meta.url)),
|
|
// docs-only layouts (DocsLayout)
|
|
'@layouts': fileURLToPath(new URL('./layouts', import.meta.url)),
|
|
// docs-only helpers (docs collection queries)
|
|
'@lib': fileURLToPath(new URL('./lib', import.meta.url)),
|
|
},
|
|
},
|
|
},
|
|
integrations: [
|
|
copyAssets({
|
|
repo: path('..'),
|
|
publicDir: path('./public'),
|
|
copies: [
|
|
{
|
|
from: path('./assets'),
|
|
to: path('./public'),
|
|
label: '@tabler/docs',
|
|
requiredFile: path('./assets/css/docs.css'),
|
|
},
|
|
{
|
|
from: path('../core/dist'),
|
|
to: path('./public/dist'),
|
|
label: '@tabler/core',
|
|
requiredFile: path('../core/dist/css/tabler.css'),
|
|
},
|
|
{
|
|
// Sourced from preview's isolated tmp-assets/ (not dist/) — dist/ is Astro's
|
|
// own build output there, and reading demo assets from it caused unbounded
|
|
// growth across repeated builds. See preview/.build/vite.config.mts.
|
|
from: path('../preview/tmp-assets'),
|
|
to: path('./public/preview'),
|
|
label: '@tabler/preview',
|
|
requiredFile: path('../preview/tmp-assets/css/demo.css'),
|
|
},
|
|
{
|
|
from: path('../shared/static'),
|
|
to: path('./public/static'),
|
|
label: 'shared assets',
|
|
requiredFile: path('../shared/static/logo.svg'),
|
|
},
|
|
],
|
|
syncDirs: [
|
|
{ from: path('../core/dist'), to: path('./public/dist') },
|
|
{ from: path('../preview/tmp-assets'), to: path('./public/preview') },
|
|
{ from: path('./assets'), to: path('./public') },
|
|
{ from: path('../shared/static'), to: path('./public/static') },
|
|
],
|
|
}),
|
|
mdx(),
|
|
],
|
|
markdown: {
|
|
// No typographic quote rewriting.
|
|
processor: satteri({ features: { smartPunctuation: false } }),
|
|
shikiConfig: {
|
|
theme: 'github-dark',
|
|
},
|
|
},
|
|
})
|