Что такое формат файла ASTRO?
Файл .astro - это компонент, используемый Astro, веб-фреймворком с открытым исходным кодом для сайтов, ориентированных на контент, таких как блоги, документация и маркетинговые страницы. Фред К. Шотт создал Astro в 2021 году, и в августе 2022 года проект достиг стабильной версии 1.0. В настоящее время проект поддерживается под лицензией MIT после того, как Cloudflare приобрела Astro Technology Company в январе 2026 года.
Каждый файл состоит из двух частей, разделенных кодовым ограждением ---. Над ограждением находится скрипт компонента, или frontmatter, написанный на JavaScript или TypeScript. Он выполняется во время сборки для импорта других компонентов, получения данных и объявления переменных. Под ограждением находится шаблон - блок, похожий на HTML, который принимает выражения {}, плейсхолдеры <slot />, а также инкапсулированные теги <style> и <script>. Синтаксис является расширением .html и читается почти как JSX, хотя в нем используются стандартные атрибуты в стиле kebab-case.
Astro рендерит компоненты в HTML заранее и по умолчанию не отправляет JavaScript на сторону клиента. Интерактивные элементы добавляются выборочно через архитектуру островов (islands architecture) с помощью директив client:* в компонентах фреймворка.
Безопасность и защита
РИСК: LOWAn .astro file is human-readable source text and cannot run on its own by double-clicking. It only executes when compiled by the Astro toolchain during a build. As with any project source, its frontmatter can contain JavaScript, so review files from untrusted repositories before running npm install or a build, since build scripts and dependencies (not the .astro file itself) are the real risk.
Детали формата
в двух словах- ASTRO-VISION LifeSign / horoscope data - Some astrology software has used .astro for chart or profile data files. Unrelated to the web framework.
- Generic astronomy/astrology data exports - Occasionally seen as an ad hoc extension for star-chart or ephemeris data in niche tools.
Программы, открывающие файлы ASTRO
.astro files. .astro components. npm run dev or astro build to compile .astro files into HTML and preview the site. .astro files with full language support. astro dev and astro build in Terminal to run and compile the project. .astro files. npm run dev or npx astro build from the terminal to serve or compile .astro files. Технические подробности
глубокая спецификация| Encoding | UTF-8 plain text |
| Byte order | Not applicable (text) |
| Container | None; single source file |
| Typical size | A few hundred bytes to tens of kilobytes |
| Structure | Two sections separated by a --- code fence: an optional component script (frontmatter) written in JavaScript/TypeScript that runs at build time or on the server, followed by a component template made of HTML-like markup with {} expressions, directives, <slot />, <style> and <script> tags. |
| Integrity | None built in |
| Platforms | Windows, macOS, Linux |
| Notes | Astro components render to HTML ahead of time and ship no client-side JavaScript runtime by default. Interactive framework components can be hydrated selectively using client:* directives (the islands architecture). The Astro compiler parses .astro files and outputs HTML plus any scoped CSS and hydration code. |
| Syntax Basis | Superset of HTML, close to JSX but using standard kebab-case HTML attributes |
| Runtime | Server/build-time rendering; no default client runtime |
| Language Support | JavaScript and TypeScript in the frontmatter, including top-level await |
| Выпущен | 2021 |
| Последняя версия | Astro 6 (March 2026) |
| Спецификация | docs.astro.build |
Конвертации ASTRO
Вопросы и ответы сообщества
спрошено пользователямиВопросов пока нет - станьте первым, кто спросит о файлах ASTRO.
Часто задаваемые вопросы
Как открыть файл .astro?
Можно ли просмотреть файл .astro в браузере?
npm run dev или собираете его через astro build, и Astro превращает компонент в HTML, который затем отображает браузер.Какая программа создает файлы .astro?
.astro.Является ли файл .astro тем же самым, что и HTML?
Почему в верхней части моего файла .astro есть JavaScript?
--- является скриптом компонента или frontmatter. Она выполняется во время сборки для импорта компонентов, получения данных и установки переменных, используемых в шаблоне ниже.