Commit graph

51 commits

Author SHA1 Message Date
Nate Moore
633bb46dc4
Fix: plain string children bug (#138)
* fix: string children bug

* test: add string children test

* test: add other child test scenarios
2021-04-28 14:43:50 -05:00
Matthew Phillips
41c64b30af
Move the request object from import.meta to Astro (#134)
* Move the `request` object from import.meta to Astro

This moves the `request` object to the Astro "global" (really just a render-level variable).

* Document Astro.request
2021-04-27 14:00:33 -04:00
Nate Moore
dea1a6dfc9
Update defaults directory structure to src and dist (#132)
* chore: update defaults in docs

* chore: update config defaults

* test: update tests to config defaults

* chore: update gitignore to new defaults

* docs: update readme to new defaults

* chore: update examples to new defaults

* chore: update default exclude in lang server

* chore: update tests

* test: fix failing tests

* chore: update www defaults
2021-04-26 15:54:20 -06:00
Drew Powers
510e7920d2
Add RSS generation (#123) 2021-04-23 10:44:41 -06:00
Kevin (Kun) "Kassimo" Qian
5eb232501f
Allow multiple JSX children appear in Mustache tag (#125)
* fix(www): link styles (#100)

Co-authored-by: Nate Moore <nate@skypack.dev>

* Add `assets/` (#102)

* chore: add assets

* docs: update readme

Co-authored-by: Nate Moore <nate@skypack.dev>

* docs: fix readme

* docs: fix readme

* chore: remove github banner

* Allow multiple JSX in mustache

* Manually discard package-lock update (due to local use of npm v7)

* Tidy up

* Revert mode ts-ignore

Co-authored-by: Nate Moore <natemoo-re@users.noreply.github.com>
Co-authored-by: Nate Moore <nate@skypack.dev>
2021-04-22 15:10:06 -04:00
Matthew Phillips
da033e27ea
CLI docs (#121)
* Start of cli docs

* Document the CLI

Also adds support for the `--config` option and `--port` option for the dev server.

* Add tests for --config and --port flags

* Add port to validateConfig
2021-04-22 08:25:57 -04:00
Drew Powers
a7185735da
Add sitemap generation (#120)
* Add sitemap generation

* Update README

* Fix index handling, sort sitemap

* Add --no-sitemap CLI flag (and config option)
2021-04-21 14:14:24 -06:00
Nate Moore
54409a0702
Prettier support for .astro files (#106)
* docs: fix readme

* chore: scaffold prettier plugin

* chore(prettier): switch to cjs

* test(prettier): scaffold prettier tests

* test(prettier): add simple prettier tests

* feat(prettier): first pass

* refactor: expose parser as CJS export

* test(prettier): add long expression

* refactor(prettier): use Astro parser + built-in prettier doc for prettier plugin

* chore: remove parser from git

* chore: add prettier-plugin-astro `build` to workflow

* chore: update package-lock

* chore: do not build prettier-plugin-astro

* fix: update engines

* chore: remove NPM restriction

* chore: fix workflow paths

* chore: update build script

* test: fix prettier expr test

* chore: fix parser build on windows

* refactor: add parser tsconfig, extending base config

* chore: relax ban-ts-comment

* chore: fix lint issue

Co-authored-by: Nate Moore <nate@skypack.dev>
2021-04-21 11:14:44 -05:00
Drew Powers
3263c02d77
Update Snowpack, Add CSS Modules SSR (#116)
* Add CSS Modules SSR

* Update docs
2021-04-20 15:06:33 -06:00
matthewp
f6f01a7d7b [ci] npm run format 2021-04-19 20:14:27 +00:00
Matthew Phillips
cc1a318c41
Fix building of dynamic Svelte components (#115)
Svelte component resolution wasn't handled correctly during the build.

Note that in the future we need to consolidate a "framework" API, so this stuff is not sprinkled throughout the codebase.
2021-04-19 16:13:53 -04:00
matthewp
46a6ba6093 [ci] npm run format 2021-04-19 18:41:37 +00:00
Matthew Phillips
eb984559a8
Fix dynamic React components (#111)
Another change in snowpack@3 caused this bug. It's not actually a bug in snowpack. Previously snowpack was keeping its list of installed packages in a global cache. In 3.3 it stopped doing so. We were accidentally relying on that global cache to be able to resolve dynamic components.

This fixes it so that we use the frontend snowpack instance to resolve dynamic components. Doing so means they are available when we try to load them.
2021-04-19 14:41:06 -04:00
Matthew Phillips
58c499dc85
Pass mode into snowpack runtime (#99)
* Pass the `mode` through to snowpack

This allows the production packages to be prepared.

* Use snowpack 3.3.1

* Update path to prism loadComponents external ref

* Upgrade to snowpack 3.3.2
2021-04-16 13:15:27 -04:00
Drew Powers
034674c88c
Add Windows Support (#93)
* Add Windows to test suite

* Try implicit URL
2021-04-14 13:21:25 -06:00
Drew Powers
3d0d53486c
Add Astro.fetchContent API (#91) 2021-04-13 18:08:32 -06:00
Matt Mulder
ac22d94e11
fix: bundle client-side code for components used in .md pages (#78) 2021-04-13 13:04:01 -04:00
duncanhealy
687ff5bacd
chore fix lint reduce errors generated (#83)
* add dep domhandler imported in in src/build/static

* lint and jsDoc error

* move domhandler to devDep

* chore: add package lock

* escape string jsDoc

* chore: add astro dep in until prism import is refactored

* chore: add snowpack example package lock
2021-04-12 16:20:58 +01:00
Drew Powers
e3ca67d6dc
Use import specifier rather than filename (#71) 2021-04-09 14:23:25 -06:00
matthewp
62924b3162 [ci] npm run format 2021-04-09 18:09:44 +00:00
Matthew Phillips
ad9c3b1d8d
Parse inner JSX as Astro (#67)
* Parse inner JSX as Astro

This completes the compiler changes, updating the parser so that it parses inner "JSX" as Astro. It does this by finding the start and end of HTML tags and feeds that back into the parser.

The result is a structure like this:

```
{
  type: 'MustacheTag',
  expression: [
    {
      type: 'Expression',
      codeStart: 'colors.map(color => (',
      codeEnd: '}}'
      children: [ {
        type: 'Fragment',
        children: [ {
          type: 'Element',
          name: 'div'
        } ]
      } ]
    }
  ]
}
```

There is a new Node type, `Expression`.  Note that `MustacheTag` remains in the tree, all it contains is an Expression though. I could spend some time trying to remove it, there's just a few places that expect it to exist.

* Update import to the transform

* Transform prism components into expressions
2021-04-09 14:09:13 -04:00
matthewp
3adb9ea87c [ci] npm run format 2021-04-06 20:15:14 +00:00
Matthew Phillips
72d9ece6db
Compiler cleanup (#64)
* Compiler cleanup

This is general compiler cleanup, especially around the codegen part. Goals here were too:

1. Make it possible to compile HTML recursively (needed for future astro-in-expressions work) by moving that work into its own function.
1. Get rid of collectionItems and have compiling the HTML return just a source string.

Also not planned, this change gets rid of the different between components and pages. All Astro components compile to the same JavaScript.

* Remove unused node types
2021-04-06 16:14:42 -04:00
Drew Powers
1acd5ee310
Allow no config (#61)
* Allow no config

* Update README
2021-04-05 15:56:46 -06:00
matthewp
71e5de76f1 [ci] npm run format 2021-04-05 18:18:39 +00:00
Matthew Phillips
c9bc6ffef7
Improve searching for pages (#60)
This improves the algorithm for searching for pages. It now works like:

1. If pathname ends with /
  1. Look for PATHNAME/index.astro
  1. Look for PATHNAME/index.md
1. else
  1. Look for PATHNAME.astro
  1. Look for PATHNAME.md
1. Look for PATHNAME/index.astro
  1. 301
1. Look for PATHNAME/index.md
  1. 301
1. 404
2021-04-05 14:18:09 -04:00
Drew Powers
008ffc2951
Fix scoping issues (#58) 2021-04-02 20:44:23 -06:00
Drew Powers
b58b493948
Fix body from being scoped (#56) 2021-04-02 12:50:30 -06:00
Drew Powers
003b3c395f
Get CSS Modules working in Vue (#53) 2021-04-02 10:16:16 -06:00
Matthew Phillips
54ba9f5ee1
Fix complex MDX parsing (#50)
* Fix complex MDX parsing

This allows fully MDX support using the micromark MDX extension. One caveat is that if you do something like use the less than sign, you need to escape it because the parser expects these to be tags otherwise.

* Move micromark definition
2021-04-01 16:34:11 -04:00
Matthew Phillips
7c10d563f2
Implements import.meta.request (#46)
This adds `import.meta.request` to pages (not components).
2021-03-31 16:47:03 -04:00
Matthew Phillips
d9084ff4ad
Implement fallback capability (#44)
* Implement fallback capability

This makes it possible for a dynamic component to render fallback content on the server.

The mechanism is a special `static` prop passed to the component. If `static` is true then the component knows it can render static content.

Putting aside the word `static`, is this the right approach? I think giving components the flexibility to make the decision themselves *is* the right approach.

However in this case we have a special property that is passed in non-explicitly. I think we have to do it this way because if the caller passes in a prop it will get serialized and appear on the client. By making this something we *add* during rendering, it only happens on the server (and only when using `:load`).

Assuming this is the right approach, is `static` the right name for this prop? Other candidates:

* `server`

That's all I have!

* Use `import.meta.env.astro` to tell if running in SSR mode.

* Run formatter
2021-03-31 16:10:27 -04:00
Drew Powers
3fa6396a7b
Extract Astro styles to external stylesheets (#43)
* Extract Astro styles to external stylesheets

* Require relative URLs in Markdown layouts
2021-03-31 13:04:18 -06:00
Drew Powers
7334a550d8
Fix nested parens bug (#39) 2021-03-30 10:37:04 -06:00
Drew Powers
ee6ef81cf3
Convert CSS Modules to scoped styles (#38)
* Convert CSS Modules to scoped styles

* Update README

* Move class scoping into HTML walker

* Fix SSR styles test

* Fix mustache tags

* Update PostCSS plugin name

* Add JSDoc comment

* Update test
2021-03-30 10:11:21 -06:00
matthewp
d267fa461b [ci] npm run format 2021-03-30 14:52:09 +00:00
Matthew Phillips
3b27eaac43
Add support for doctype (#37)
* Add support for doctype

* Automatically prepend doctype
2021-03-30 10:51:31 -04:00
Drew Powers
88df57e690
Add SSR Styles test (#35) 2021-03-26 13:59:41 -06:00
Drew Powers
3ddd3594f0
Absorb Snowpack config inside Astro (#32)
* Absorb Snowpack config inside Astro

* Add basic README

* Format tests

* Update esbuild

* Format tests
2021-03-26 13:14:32 -06:00
Fred K. Schott
a72ab10c62
Redesign pages, remove layout nesting (#24)
* wip

* new svelte-style prop declaration is working

* got it working!

* revert h changes

* format

* style lang update
2021-03-24 16:01:28 -07:00
Matthew Phillips
3c24faa8ca
hmx ☞ astro (#22)
This changes all hmx files to astro files and updates all code to not reference hmx any more.
2021-03-24 11:45:38 -04:00
Fred K. Schott
195b131f43 add support for frontmatter scripts 2021-03-23 20:15:44 -07:00
Matthew Phillips
ed85702581
Allow HMX components in markdown (#19)
* Allow HMX components in markdown

This adds support for HMX components in markdown. The mechanism for importing is via frontmatter. We could do this differently (setup script maybe?) but since this was the easiest to implement I thought it was a good first-pass option.

* Remove node-fetch from snowpack config

* Assert that the runtime is created successfully

* Add back in the micromark extension for encoding entities

* Encode both codeTextData and codeFlowValue

* Install snowpack app's deps
2021-03-23 15:20:03 -04:00
Matthew Phillips
854d0feb34
Add support for React components. (#18)
* Add support for React components.

This adds support for react components via a new `extensions` config in astro.config.mjs. In the future we can extend this to do things like look at the import statements, as Snowpack does.

* Fix the tests
2021-03-23 13:47:54 -04:00
Fred K. Schott
3f16550765 fix broken test 2021-03-22 23:06:25 -07:00
Fred K. Schott
799db34d55 fix broken tests 2021-03-22 21:34:47 -07:00
Fred K. Schott
6e4367fd49 another pass at head/body handling in pages 2021-03-21 20:34:11 -07:00
Fred K. Schott
558ef18b58 get test runner running 2021-03-21 15:13:38 -07:00
Fred K. Schott
417657f138 lots of improvements 2021-03-21 00:44:42 -07:00
Matthew Phillips
2082001ff8
Add snowpack as an example project. (#11)
* Initial tests set up

This adds tests using uvu (we can switch if people want) and restructures things a bit so that it's easier to test.

Like in snowpack you set up a little project. In our tests you can say:

```js
const result = await runtime.load('/blog/hello-world')
```

And analyze the result. I included a `test-helpers.js` which has a function that will turn HTML into a cheerio instance, for inspecting the result HTML.

* Bring snowpack example in

* Formatting
2021-03-19 17:17:38 -04:00