-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathastro.config.mjs
More file actions
165 lines (145 loc) · 5.54 KB
/
astro.config.mjs
File metadata and controls
165 lines (145 loc) · 5.54 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
import { defineConfig } from 'astro/config';
import node from '@astrojs/node';
import sitemap from '@astrojs/sitemap';
import react from '@astrojs/react';
import remarkHeadingId from 'remark-heading-id';
import { locations } from './src/data/locations.ts';
import { geoContent } from './src/data/geo-content.ts';
const site = 'https://avpdev.com';
// Список slug городов, у которых НЕТ русского контента (name_ru: null)
// Эти RU-страницы делают redirect → не должны быть в sitemap
const enOnlyCitySlugs = locations
.filter(loc => loc.name_ru === null)
.map(loc => loc.slug);
export default defineConfig({
site: site,
// 1. Поддержка кастомных ID в заголовках Markdown
markdown: {
remarkPlugins: [remarkHeadingId],
},
// 2. Настройка серверного рендеринга (Node.js)
output: 'server',
adapter: node({
mode: 'standalone'
}),
integrations: [
// 3. Интеграция Sitemap: i18n hreflang + lastmod + priority по типу страниц
sitemap({
// Фильтрация: убираем корень и RU-города без русского контента (redirect-only)
filter: (page) => {
// Исключить корневой URL (делает 301 redirect в index.astro)
if (page === `${site}/` || page === `${site}`) return false;
// Исключить любые страницы, которых нет в контенте для конкретного языка
const isRuGeo = page.includes('/ru/uslugi/');
const isEnGeo = page.includes('/en/services/');
if (isRuGeo) {
const slug = page.split('/ru/uslugi/')[1].replace(/\//g, '');
if (enOnlyCitySlugs.includes(slug)) return false;
}
// Исключить страницы, которые мы знаем как редиректы из middleware
const redirects = [
'/ru/privacy-policy/', '/en/privacy-policy/',
'/ru/terms-of-service/', '/en/terms-of-service/',
'/ru/brief/', '/index.html'
];
if (redirects.some(r => page.endsWith(r))) return false;
return true;
},
// i18n: автоматический hreflang для RU↔EN (xhtml:link alternate)
i18n: {
defaultLocale: 'ru',
locales: {
ru: 'ru',
en: 'en',
},
},
// Кастомизация каждого URL: lastmod + дифференцированный priority
serialize(item) {
const url = item.url;
// lastmod — текущая дата билда
item.lastmod = new Date().toISOString();
// Дифференцированный priority по типу страницы
if (url.match(/\/(ru|en)\/$/)) {
// Главные страницы
item.priority = 1.0;
item.changefreq = 'daily';
} else if (url.includes('/blog/') && url.match(/\/(ru|en)\/blog\/$/)) {
// Блог-листинг
item.priority = 0.8;
item.changefreq = 'daily';
} else if (url.includes('/blog/')) {
// Отдельные статьи блога
item.priority = 0.7;
item.changefreq = 'weekly';
} else if (url.includes('/project/')) {
// Проекты
item.priority = 0.7;
item.changefreq = 'monthly';
} else if (
url.includes('/services/ai-integration/') ||
url.includes('/services/website-development/') ||
url.includes('/services/bot-and-scraper-development/') ||
url.includes('/services/saas-mvp/') ||
url.includes('/services/telegram-mini-apps/') ||
url.includes('/uslugi/razrabotka-saitov/') ||
url.includes('/uslugi/ai-integracii/') ||
url.includes('/uslugi/razrabotka-botov-i-parserov/') ||
url.includes('/uslugi/saas-mvp/') ||
url.includes('/uslugi/telegram-mini-apps/')
) {
// Основные услуги (не города)
item.priority = 0.9;
item.changefreq = 'weekly';
} else if (url.includes('/services/') || url.includes('/uslugi/')) {
// Гео-страницы (города)
item.priority = 0.5;
item.changefreq = 'monthly';
} else if (url.includes('/brief/')) {
// Бриф
item.priority = 0.6;
item.changefreq = 'monthly';
} else if (url.includes('/locations/')) {
// Карта локаций
item.priority = 0.6;
item.changefreq = 'monthly';
} else if (url.includes('/legal/')) {
// Юридические страницы
item.priority = 0.3;
item.changefreq = 'yearly';
} else {
// Все остальные
item.priority = 0.5;
item.changefreq = 'monthly';
}
return item;
},
}),
// 5. Поддержка React компонентов
react()
],
// 6. Настройки путей и сервера
trailingSlash: 'always',
build: {
format: 'directory',
inlineStylesheets: 'always'
},
server: {
host: '0.0.0.0',
port: 3000
},
vite: {
ssr: {
external: ['bun:sqlite'],
},
},
compressHTML: true,
// 7. Интернационализация (i18n)
i18n: {
defaultLocale: 'ru',
locales: ['ru', 'en'],
routing: {
prefixDefaultLocale: true,
redirectToDefaultLocale: false,
},
},
});