Commit graph

34 commits

Author SHA1 Message Date
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
Matthew Phillips
17c3c98f07
Initial tests set up (#10)
* Begin debugging

* 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.

* Add CI

* Remove extra console logs

* Formatting
2021-03-19 17:07:45 -04:00