Skip to content

Commit

Permalink
feat: update compiler (#1421)
Browse files Browse the repository at this point in the history
  • Loading branch information
natemoo-re authored and drwpow committed Oct 15, 2021
1 parent 7e42b00 commit 73eb8ed
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 5 deletions.
2 changes: 1 addition & 1 deletion packages/astro/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@
"test": "NODE_OPTIONS=--experimental-vm-modules jest"
},
"dependencies": {
"@astrojs/compiler": "^0.1.0-canary.45",
"@astrojs/compiler": "^0.1.0-canary.46",
"@astrojs/language-server": "^0.7.16",
"@astrojs/markdown-remark": "^0.3.1",
"@astrojs/markdown-support": "0.3.1",
Expand Down
15 changes: 15 additions & 0 deletions packages/astro/src/runtime/astro.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
import type { AstroComponent, AstroComponentFactory } from '../internal';

import { spreadAttributes, defineStyleVars, defineScriptVars } from '../internal';

export async function renderAstroComponent(component: InstanceType<typeof AstroComponent>) {
let template = '';

Expand All @@ -24,3 +26,16 @@ export async function renderPage(result: any, Component: AstroComponentFactory,
const scripts = Array.from(result.scripts);
return template.replace('</head>', styles.join('\n') + scripts.join('\n') + '</head>');
}

function renderElement(name: string, { props: _props, children = ''}: { props: Record<any, any>, children?: string }) {
const { hoist: _, "data-astro-id": astroId, "define:vars": defineVars, ...props } = _props;
if (defineVars) {
if (name === 'style') {
children = defineStyleVars(astroId, defineVars) + '\n' + children;
}
if (name === 'script') {
children = defineScriptVars(defineVars) + '\n' + children;
}
}
return `<${name}${spreadAttributes(props)}>${children}</${name}>`
}
8 changes: 4 additions & 4 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -106,10 +106,10 @@
"@algolia/logger-common" "4.10.5"
"@algolia/requester-common" "4.10.5"

"@astrojs/compiler@^0.1.0-canary.45":
version "0.1.0-canary.45"
resolved "https://registry.yarnpkg.com/@astrojs/compiler/-/compiler-0.1.0-canary.45.tgz#826ec2eba4785eb08095bd04210b74d1fada4b95"
integrity sha512-B68nKGSHh319vum/XP6o8mNcv6bYqg7ipvtqlT7kiaxqXQ/2zA4PZcnWShF7XZ4s6jgs8WG3Pv+vo5/1rPs8pw==
"@astrojs/compiler@^0.1.0-canary.46":
version "0.1.0-canary.46"
resolved "https://registry.yarnpkg.com/@astrojs/compiler/-/compiler-0.1.0-canary.46.tgz#99d12c9148c9233df81929204b823112ea26cb69"
integrity sha512-JwcPl90H59wjxP/Jx2Ub+OHGqgzkU+QFoZxur2CU028/2rwjkp2N1B5biAakS6g/8trIPwnZK/7iETKWOCGc+Q==
dependencies:
typescript "^4.3.5"

Expand Down

0 comments on commit 73eb8ed

Please sign in to comment.