Skip to content
| Marketplace
Sign in
Visual Studio Code>Other>Astro File GeneratorNew to Visual Studio Code? Get it now.
Astro File Generator

Astro File Generator

Manuel Gil

|
1,477 installs
| (1) | Free
| Sponsor
👩‍🚀 Astro File Generator is a Visual Studio Code extension that allows you to generate a list of files based on the files in your workspace.
Installation
Launch VS Code Quick Open (Ctrl+P), paste the following command, and press enter.
Copied to clipboard
More Info

Astro File Generator

Visual Studio Marketplace Version Visual Studio Marketplace Installs Visual Studio Marketplace Downloads Visual Studio Marketplace Rating GitHub Repo stars GitHub license

👩‍🚀 Astro File Generator is a Visual Studio Code extension that automatically generates Astro files based on a template. It is useful for creating Astro files quickly and efficiently.

With a few clicks, you can create:

  • Basic Page: Create a Basic Page file for Astro.
  • Basic Component: Create a Basic Component file for Astro.
  • Layout with Slots: Create a Layout file with slots.
  • Static Data Page: Create a Page file with static data.
  • Page with getStaticProps: Create a Page file with getStaticProps.
  • Styled Component: Create a Styled Component file for Astro.
  • Custom Component: Create a Custom Component file with a simple template.

The extension is highly customizable, allowing you to create custom templates for your files. It also automatically formats the file upon saving and integrates with Astro for easy installation.

Astro File Generator

Table of Contents

  • Astro File Generator
    • Table of Contents
    • Requirements
    • Key Features
    • Project Settings
    • Settings Options
    • Connect with me
    • VSXpert Template
    • Other Extensions
    • Contributing
    • Code of Conduct
    • Changelog
    • Authors
    • License

Requirements

  • VSCode 1.88.0 or later

Key Features

  • Create Astro Files: Quickly create Astro files with a template.
  • Custom Templates: Create custom templates for your files.
  • Automatic Formatting: Automatically format the file upon saving.
  • Integrations for Astro: Install the integrations for Astro easily.
  • File Watcher: Watch for changes in the files and automatically format them.
  • Customizable: Customize the extension to fit your needs.
  • Open Source: The extension is open source and free to use.

Project Settings

Configure your project by creating or updating a settings.json file at the project's root. If you already have a .vscode/settings.json file, skip the first two steps.

  1. Open the command palette in VSCode:

    • CTRL + SHIFT + P (Windows)
    • CMD + SHIFT + P (Mac OS)
  2. Type Preferences: Open Workspace Settings (JSON).

  3. In the .vscode/settings.json file, copy and paste the following settings:

    {
      "astroGenerator.enable": true, // Enable or disable the extension
      "astroGenerator.files.include": [
          "astro"
      ], // The file extensions to watch for changes. Example: "json", "jsonc"
      "astroGenerator.files.exclude": [
          "**/node_modules/**",
          "**/dist/**",
          "**/out/**",
          "**/build/**",
          "**/.*/**"
      ], // The files to exclude from watching. Example: "**/node_modules/**", "**/dist/**", "**/out/**", "**/build/**", "**/.*/**"
      "astroGenerator.files.showPath": true, // Show the path of the file in the file name. Example: "home.component.tsx (pages/home)"
      "astroGenerator.files.skipFolderConfirmation": false, // Skip the folder confirmation when creating a new file
      "astroGenerator.formatting.headerCommentTemplate": [
          "/*",
          " * This file was generated by Astro File Generator",
          " */"
      ], // The template to use for the header comment
      "astroGenerator.formatting.insertFinalNewline": true, // Insert a final newline at the end of the file
      "astroGenerator.templates.customComponents": [
          {
              "name": "React Page",
              "description": "Create a new page",
              "extension": ".jsx",
              "template": [
                  "export const meta = { title: 'Page Title' };",
                  "export default function Page() {",
                  "  return <h1>Hello, World!</h1>;",
                  "}"
              ]
          },
          {
              "name": "React Layout",
              "description": "Create a new layout",
              "extension": ".jsx",
              "template": [
                  "export default function Layout({ children }) {",
                  "  return <div>{children}</div>;",
                  "}"
              ]
          },
          {
              "name": "React Component",
              "description": "Create a new component",
              "extension": ".jsx",
              "template": [
                  "export default function {{ComponentName}}() {",
                  "  return <div>Hello, World!</div>;",
                  "}"
              ]
          }
      ] // The templates to use when creating a new file
    }
    
  4. Restart VS Code

Your project is now set up to automatically format code upon saving.

Settings Options

Configure Astro File Generator settings in your .vscode/settings.json file to customize the extension's behavior. The following settings are available:

  • astroGenerator.enable: Enable or disable the extension. Default is true.
  • astroGenerator.files.include: The file extensions to watch for changes. Default is ["astro"].
  • astroGenerator.files.exclude: The files to exclude from watching. Default is ["**/node_modules/**", "**/dist/**", "**/out/**", "**/build/**", "**/.*/**"].
  • astroGenerator.files.showPath: Show the path of the file in the file name. Default is true.
  • astroGenerator.files.skipFolderConfirmation: Skip the folder confirmation when creating a new file. Default is false.
  • astroGenerator.formatting.headerCommentTemplate: The template to use for the header comment. Default is ["/*", " * This file was generated by Astro File Generator", " */"].
  • astroGenerator.formatting.insertFinalNewline: Insert a final newline at the end of the file. Default is true.
  • astroGenerator.templates.customComponents: The templates to use when creating a new file. You can create custom templates for your files.

The astroGenerator.templates.customComponents setting is an array of objects with the following properties:

  • name: The name of the template. Example: "React Page".
  • description: A description of the template. Example: "Create a new page".
  • extension: The file extension for the template. Example: .jsx.
  • template: The template content for the file. Use {{ComponentName}} as a placeholder for the component name.

For more information on configuring Auto TS Generator settings, refer to the Project Settings section.

Connect with me

GitHub followers X (formerly Twitter) Follow

VSXpert Template

This extension was created using VSXpert, a template that helps you create Visual Studio Code extensions with ease. VSXpert provides a simple and easy-to-use structure to get you started quickly.

Other Extensions

  • NestJS File Generator
  • NestJS Snippets
  • Angular File Generator
  • T3 Stack / NextJS / ReactJS File Generator
  • CodeIgniter 4 Snippets
  • CodeIgniter 4 Shield Snippets
  • CodeIgniter 4 Spark
  • Moodle Pack
  • Mustache Template Engine - Snippets & Autocomplete

Contributing

Please read CONTRIBUTING.md for details on our code of conduct, and the process for submitting pull requests to us.

Code of Conduct

Please read CODE_OF_CONDUCT.md for details on our code of conduct.

Changelog

See CHANGELOG.md

Authors

  • Manuel Gil - Owner - ManuelGil

See also the list of contributors who participated in this project.

License

Astro File Generator is licensed under the MIT License - see the MIT License for details.

  • Contact us
  • Jobs
  • Privacy
  • Manage cookies
  • Terms of use
  • Trademarks
© 2025 Microsoft