Co to jest format pliku ASTRO?
Plik .astro to komponent używany przez Astro, framework webowy typu open-source przeznaczony dla witryn skoncentrowanych na treści, takich jak blogi, dokumentacja i strony marketingowe. Fred K. Schott stworzył Astro w 2021 roku, a wersja stabilna 1.0 została wydana w sierpniu 2022 roku. Projekt jest obecnie utrzymywany na licencji MIT po tym, jak Cloudflare przejęło Astro Technology Company w styczniu 2026 roku.
Każdy plik składa się z dwóch części rozdzielonych blokiem kodu ---. Powyżej znajduje się skrypt komponentu (frontmatter), napisany w JavaScript lub TypeScript. Jest on uruchamiany w czasie budowania (build time), aby importować inne komponenty, pobierać dane i deklarować zmienne. Poniżej znajduje się szablon, blok przypominający HTML, który akceptuje wyrażenia {}, symbole zastępcze <slot /> oraz ograniczone do komponentu tagi <style> i <script>. Składnia jest nadzbiorem .html i przypomina JSX, choć używa standardowych atrybutów typu kebab-case.
Astro renderuje komponenty do HTML z wyprzedzeniem i domyślnie nie wysyła żadnego JavaScriptu na stronę klienta. Interaktywne elementy są dodawane selektywnie poprzez architekturę wysp (islands architecture) przy użyciu dyrektyw client:* na komponentach frameworka.
Bezpieczeństwo
RYZYKO: 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.
Szczegóły formatu
w pigułce- 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.
Programy otwierające pliki 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. Szczegóły techniczne
specyfikacja| 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 |
| Wydano | 2021 |
| Najnowsza wersja | Astro 6 (March 2026) |
| Specyfikacja | docs.astro.build |
Konwersje ASTRO
Pytania i odpowiedzi społeczności
pytania użytkownikówBrak pytań - bądź pierwszą osobą, która zapyta o pliki ASTRO.
Najczęściej zadawane pytania
Jak otworzyć plik .astro?
Czy mogę wyświetlić plik .astro w przeglądarce?
npm run dev lub zbudować go przez astro build, a Astro zamieni komponent w HTML, który przeglądarka będzie mogła wyświetlić.Jaki program tworzy pliki .astro?
.astro.Czy plik .astro to to samo co HTML?
Dlaczego mój plik .astro ma JavaScript na górze?
---, to skrypt komponentu lub frontmatter. Uruchamia się on w czasie budowania, aby importować komponenty, pobierać dane i ustawiać zmienne używane w szablonie poniżej.