Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Docs: add .astro Syntax guide #137

Merged
merged 9 commits into from
Apr 28, 2021
Merged

Docs: add .astro Syntax guide #137

merged 9 commits into from
Apr 28, 2021

Conversation

natemoo-re
Copy link
Member

@natemoo-re natemoo-re commented Apr 28, 2021

Changes

Adds docs/syntax.md to provide an overview of the Astro syntax

Testing

N/A

Docs

  • Docs / READMEs updated

docs/syntax.md Outdated Show resolved Hide resolved

When you finally do need to introduce dynamic functionality, Astro allows you to _bring your own framework_, so you're free to use any component format you'd like without commiting to a holistic architectural approach up-front. "The big question" is deferred until it actually needs to be answered.

During a long-term project, you might even decide to switch frameworks somewhere down the road. Since Astro decouples decisions about data-loading and static rendering from your framework, that decision has a much smaller impact—try out the new framework on a single page or even mix both frameworks on some pages while you migrate.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

❤️

| Requires JS import | No | Yes, `jsxPragma` (`React` or `h`) must be in scope |
| Fragments | Automatic | Wrap with `<Fragment>` or `<>` |
| Mutliple frameworks per-file | Yes | No |
| Modifying `<head>` | Just use `<head>` | Per-framework (`<Head>`, `<svelte:head>`, etc) |
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Haha! 💯

docs/syntax.md Outdated Show resolved Hide resolved
Copy link
Member

@drwpow drwpow left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Love this! This is looking great. I don’t have any other feedback. Great covering of the entire concept in a very easy-to-read length.

`.astro` components can also accept props when they are rendered. Public props can be marked using the `export` keyword.

Local values are overwritten when props are passed, otherwise they are considered the default value.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is a pretty confusing/surprising API. Typically export provides data to other modules, but this inverts that. I’m not sure I have a better solution in mind, but I’ll think on it if there’s interest on the Astro team.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fair point. This is borrowed from Svelte's prop syntax. One benefit is that it makes it really easy to statically analyze for IDE support, but I agree that overloading the export keyword isn't great.

Would be interested to hear alternative suggestions! I'll spin up a separate issue.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Opened #139!

Co-authored-by: Drew Powers <1369770+drwpow@users.noreply.github.com>
docs/syntax.md Outdated Show resolved Hide resolved
@natemoo-re natemoo-re merged commit 961eee5 into main Apr 28, 2021
@natemoo-re natemoo-re deleted the astro-syntax branch April 28, 2021 19:55
@natemoo-re natemoo-re added this to Done in MVP Roadmap Apr 30, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
No open projects
Development

Successfully merging this pull request may close these issues.

None yet

4 participants