mirror of
https://github.com/tabler/tabler.git
synced 2026-10-12 05:06:55 +04:00
Fix robots.txt, minified assets and dead links in the preview build (#3079)
This commit is contained in:
1 parent
39e73cea60
commit
084d2021d3
13 files changed
+80
-30
No files matched your search
@@ -1,5 +1,7 @@
|
||||
---
|
||||
// Legacy alias kept for old bookmarks and the downloadable package: the page
|
||||
// moved to prose.html.
|
||||
import RedirectLayout from '@shared/layouts/RedirectLayout.astro'
|
||||
---
|
||||
|
||||
<RedirectLayout />
|
||||
<RedirectLayout url="/prose.html" />
|
||||
@@ -3,15 +3,17 @@ import { site } from '@shared/lib/site'
|
||||
|
||||
export const prerender = true
|
||||
|
||||
// development, and crawling is allowed only in the preview environment.
|
||||
// Vercel sets VERCEL_ENV to "production" on preview.tabler.io and to "preview"
|
||||
// on branch deploys; it is unset locally. Only production may be crawled,
|
||||
// and the sitemap URL is absolute outside development.
|
||||
export const GET: APIRoute = () => {
|
||||
const environment = process.env.NODE_ENV || 'production'
|
||||
const isProduction = process.env.VERCEL_ENV === 'production'
|
||||
const sitemapBase = environment !== 'development' ? site.previewUrl : ''
|
||||
const body = `Sitemap: ${sitemapBase}/sitemap.xml
|
||||
|
||||
|
||||
User-agent: *
|
||||
Disallow:${environment === 'preview' ? '' : ' /'}
|
||||
Disallow:${isProduction ? '' : ' /'}
|
||||
`
|
||||
|
||||
return new Response(body, {
|
||||
|
||||
@@ -3,7 +3,9 @@ import { site } from '@shared/lib/site'
|
||||
|
||||
export const prerender = true
|
||||
|
||||
// Index pages collapse to directory URLs (build.format 'file').
|
||||
// build.format 'file' emits x/index.astro as x.html (the hosting serves no
|
||||
// x/ directory), so nested index pages collapse to that file; the root index
|
||||
// stays "/".
|
||||
const pages = import.meta.glob('./**/*.astro')
|
||||
|
||||
const urls = Object.keys(pages)
|
||||
@@ -16,7 +18,7 @@ const urls = Object.keys(pages)
|
||||
})
|
||||
.map((path) => {
|
||||
if (path === 'index.html') return '/'
|
||||
if (path.endsWith('/index.html')) return `/${path.slice(0, -'index.html'.length)}`
|
||||
if (path.endsWith('/index.html')) return `/${path.slice(0, -'/index.html'.length)}.html`
|
||||
return `/${path}`
|
||||
})
|
||||
|
||||
|
||||
@@ -18,7 +18,7 @@ import Icon from '@ui/Icon.astro'
|
||||
<Card>
|
||||
<CardHeader title="Product Tour Example">
|
||||
<CardActions>
|
||||
<Button id="start-tour" text="Start Tour" icon="play" color="primary" element="button" />
|
||||
<Button id="start-tour" text="Start Tour" icon="player-play" color="primary" element="button" />
|
||||
</CardActions>
|
||||
</CardHeader>
|
||||
<CardBody>
|
||||
|
||||
Reference in new issue
Block a user