feat: pagine vetrina in SSR e sitemap runtime
This commit is contained in:
@@ -1,6 +1,5 @@
|
|||||||
import { defineConfig } from 'astro/config';
|
import { defineConfig } from 'astro/config';
|
||||||
import node from '@astrojs/node';
|
import node from '@astrojs/node';
|
||||||
import sitemap from '@astrojs/sitemap';
|
|
||||||
|
|
||||||
export default defineConfig({
|
export default defineConfig({
|
||||||
site: 'https://insanitylab.tielogic.xyz',
|
site: 'https://insanitylab.tielogic.xyz',
|
||||||
@@ -11,5 +10,4 @@ export default defineConfig({
|
|||||||
allowedDomains: [{ hostname: 'insanitylab.tielogic.xyz', protocol: 'https' }],
|
allowedDomains: [{ hostname: 'insanitylab.tielogic.xyz', protocol: 'https' }],
|
||||||
},
|
},
|
||||||
adapter: node({ mode: 'standalone' }),
|
adapter: node({ mode: 'standalone' }),
|
||||||
integrations: [sitemap({ filter: (page) => !page.includes('/admin') })],
|
|
||||||
});
|
});
|
||||||
|
|||||||
+1
-1
@@ -1,4 +1,4 @@
|
|||||||
User-agent: *
|
User-agent: *
|
||||||
Disallow: /admin
|
Disallow: /admin
|
||||||
Disallow: /api
|
Disallow: /api
|
||||||
Sitemap: https://insanitylab.tielogic.xyz/sitemap-index.xml
|
Sitemap: https://insanitylab.tielogic.xyz/sitemap.xml
|
||||||
|
|||||||
@@ -24,7 +24,7 @@ const { title, description = 'InsanityLab — Performance. Balance. Longevity. A
|
|||||||
<meta property="og:type" content="website" />
|
<meta property="og:type" content="website" />
|
||||||
<meta property="og:image" content={new URL('/img/og.jpg', Astro.site)} />
|
<meta property="og:image" content={new URL('/img/og.jpg', Astro.site)} />
|
||||||
<link rel="icon" href="/favicon.svg" type="image/svg+xml" />
|
<link rel="icon" href="/favicon.svg" type="image/svg+xml" />
|
||||||
<link rel="sitemap" href="/sitemap-index.xml" />
|
<link rel="sitemap" href="/sitemap.xml" />
|
||||||
<script is:inline>document.documentElement.classList.add('js');</script>
|
<script is:inline>document.documentElement.classList.add('js');</script>
|
||||||
</head>
|
</head>
|
||||||
<body>
|
<body>
|
||||||
|
|||||||
+1
-1
@@ -2,7 +2,7 @@
|
|||||||
import Base from '../layouts/Base.astro';
|
import Base from '../layouts/Base.astro';
|
||||||
import T from '../components/content/T.astro';
|
import T from '../components/content/T.astro';
|
||||||
import { t } from '../lib/content';
|
import { t } from '../lib/content';
|
||||||
export const prerender = true;
|
export const prerender = false;
|
||||||
---
|
---
|
||||||
<Base title={t('notfound.meta.title')}>
|
<Base title={t('notfound.meta.title')}>
|
||||||
<section class="section" style="text-align:center; padding-block:140px;">
|
<section class="section" style="text-align:center; padding-block:140px;">
|
||||||
|
|||||||
@@ -10,7 +10,7 @@ const images = import.meta.glob<{ default: ImageMetadata }>('../assets/img/*.{jp
|
|||||||
const imgOf = (name: string) => Object.entries(images).find(([p]) => p.includes(name))?.[1]?.default;
|
const imgOf = (name: string) => Object.entries(images).find(([p]) => p.includes(name))?.[1]?.default;
|
||||||
const founders = team.filter((m) => m.founder);
|
const founders = team.filter((m) => m.founder);
|
||||||
const staff = team.filter((m) => !m.founder);
|
const staff = team.filter((m) => !m.founder);
|
||||||
export const prerender = true;
|
export const prerender = false;
|
||||||
---
|
---
|
||||||
<Base title={t('about.meta.title')} description={t('about.meta.description')}>
|
<Base title={t('about.meta.title')} description={t('about.meta.description')}>
|
||||||
<PageHero title={t('about.hero.title')} />
|
<PageHero title={t('about.hero.title')} />
|
||||||
|
|||||||
@@ -5,7 +5,7 @@ import ContactForm from '../components/ContactForm.astro';
|
|||||||
import contactHero from '../assets/img/contact-hero.jpg';
|
import contactHero from '../assets/img/contact-hero.jpg';
|
||||||
import T from '../components/content/T.astro';
|
import T from '../components/content/T.astro';
|
||||||
import { t, getImageOverride } from '../lib/content';
|
import { t, getImageOverride } from '../lib/content';
|
||||||
export const prerender = true;
|
export const prerender = false;
|
||||||
const mapsQuery = encodeURIComponent(`${t('global.contact.address')}, ${t('global.contact.city-line')}`);
|
const mapsQuery = encodeURIComponent(`${t('global.contact.address')}, ${t('global.contact.city-line')}`);
|
||||||
---
|
---
|
||||||
<Base title={t('contact.meta.title')} description={t('contact.meta.description')}>
|
<Base title={t('contact.meta.title')} description={t('contact.meta.description')}>
|
||||||
|
|||||||
@@ -12,7 +12,7 @@ import MethodSteps from '../components/home/MethodSteps.astro';
|
|||||||
import PartnersStrip from '../components/home/PartnersStrip.astro';
|
import PartnersStrip from '../components/home/PartnersStrip.astro';
|
||||||
import T from '../components/content/T.astro';
|
import T from '../components/content/T.astro';
|
||||||
import { t } from '../lib/content';
|
import { t } from '../lib/content';
|
||||||
export const prerender = true;
|
export const prerender = false;
|
||||||
---
|
---
|
||||||
<Base title={t('home.meta.title')}>
|
<Base title={t('home.meta.title')}>
|
||||||
<HeroSlider />
|
<HeroSlider />
|
||||||
|
|||||||
@@ -2,18 +2,16 @@
|
|||||||
import Base from '../../layouts/Base.astro';
|
import Base from '../../layouts/Base.astro';
|
||||||
import PageHero from '../../components/PageHero.astro';
|
import PageHero from '../../components/PageHero.astro';
|
||||||
import type { ImageMetadata } from 'astro';
|
import type { ImageMetadata } from 'astro';
|
||||||
import { programs } from '../../data/programs';
|
import { programs, getProgram } from '../../data/programs';
|
||||||
import { performanceClassPricing } from '../../data/pricing';
|
import { performanceClassPricing } from '../../data/pricing';
|
||||||
import { programIcons } from '../../data/program-icons';
|
import { programIcons } from '../../data/program-icons';
|
||||||
import T from '../../components/content/T.astro';
|
import T from '../../components/content/T.astro';
|
||||||
import TImg from '../../components/content/TImg.astro';
|
import TImg from '../../components/content/TImg.astro';
|
||||||
import { t } from '../../lib/content';
|
import { t } from '../../lib/content';
|
||||||
export const prerender = true;
|
export const prerender = false;
|
||||||
|
|
||||||
export function getStaticPaths() {
|
const program = getProgram(Astro.params.slug!);
|
||||||
return programs.map((p) => ({ params: { slug: p.slug }, props: { program: p } }));
|
if (!program) return new Response(null, { status: 404 });
|
||||||
}
|
|
||||||
const { program } = Astro.props;
|
|
||||||
const slug = program.slug;
|
const slug = program.slug;
|
||||||
const others = programs.filter((p) => p.slug !== program.slug);
|
const others = programs.filter((p) => p.slug !== program.slug);
|
||||||
const images = import.meta.glob<{ default: ImageMetadata }>('../../assets/img/program-*.jpg', { eager: true });
|
const images = import.meta.glob<{ default: ImageMetadata }>('../../assets/img/program-*.jpg', { eager: true });
|
||||||
|
|||||||
@@ -8,7 +8,7 @@ import TImg from '../../components/content/TImg.astro';
|
|||||||
import { t } from '../../lib/content';
|
import { t } from '../../lib/content';
|
||||||
const images = import.meta.glob<{ default: ImageMetadata }>('../../assets/img/program-*.jpg', { eager: true });
|
const images = import.meta.glob<{ default: ImageMetadata }>('../../assets/img/program-*.jpg', { eager: true });
|
||||||
const imgOf = (slug: string) => Object.entries(images).find(([p]) => p.includes(`program-${slug}.`))?.[1]?.default;
|
const imgOf = (slug: string) => Object.entries(images).find(([p]) => p.includes(`program-${slug}.`))?.[1]?.default;
|
||||||
export const prerender = true;
|
export const prerender = false;
|
||||||
---
|
---
|
||||||
<Base title={t('programs.meta.title')} description={t('programs.meta.description')}>
|
<Base title={t('programs.meta.title')} description={t('programs.meta.description')}>
|
||||||
<PageHero title={t('programs.hero.title')} />
|
<PageHero title={t('programs.hero.title')} />
|
||||||
|
|||||||
@@ -0,0 +1,18 @@
|
|||||||
|
import type { APIRoute } from 'astro';
|
||||||
|
import { getDb } from '../lib/db';
|
||||||
|
import { programs } from '../data/programs';
|
||||||
|
export const prerender = false;
|
||||||
|
|
||||||
|
const STATIC = ['/', '/about', '/contact', '/training', '/programs', '/blog'];
|
||||||
|
|
||||||
|
export const GET: APIRoute = ({ site }) => {
|
||||||
|
const base = (site ?? new URL('https://insanitylab.tielogic.xyz')).toString().replace(/\/$/, '');
|
||||||
|
const posts = getDb().prepare('SELECT slug FROM posts WHERE draft = 0').all() as { slug: string }[];
|
||||||
|
const urls = [
|
||||||
|
...STATIC,
|
||||||
|
...programs.map((p) => `/programs/${p.slug}`),
|
||||||
|
...posts.map((p) => `/blog/${p.slug}`),
|
||||||
|
];
|
||||||
|
const xml = `<?xml version="1.0" encoding="UTF-8"?>\n<urlset xmlns="http://www.sitemaps.org/schemas/sitemap/0.9">\n${urls.map((u) => ` <url><loc>${base}${u}</loc></url>`).join('\n')}\n</urlset>`;
|
||||||
|
return new Response(xml, { headers: { 'Content-Type': 'application/xml' } });
|
||||||
|
};
|
||||||
@@ -11,7 +11,7 @@ import TImg from '../components/content/TImg.astro';
|
|||||||
import { t } from '../lib/content';
|
import { t } from '../lib/content';
|
||||||
const images = import.meta.glob<{ default: ImageMetadata }>('../assets/img/training-*.{jpg,png}', { eager: true });
|
const images = import.meta.glob<{ default: ImageMetadata }>('../assets/img/training-*.{jpg,png}', { eager: true });
|
||||||
const imgOf = (name: string) => Object.entries(images).find(([p]) => p.includes(name))?.[1]?.default;
|
const imgOf = (name: string) => Object.entries(images).find(([p]) => p.includes(name))?.[1]?.default;
|
||||||
export const prerender = true;
|
export const prerender = false;
|
||||||
---
|
---
|
||||||
<Base title={t('training.meta.title')} description={t('training.meta.description')}>
|
<Base title={t('training.meta.title')} description={t('training.meta.description')}>
|
||||||
<PageHero title={t('training.hero.title')} />
|
<PageHero title={t('training.hero.title')} />
|
||||||
|
|||||||
Reference in New Issue
Block a user