diff options
author | 2021-03-25 00:00:22 -0700 | |
---|---|---|
committer | 2021-03-25 00:00:22 -0700 | |
commit | 30cccdf7154b6470e876464da9e412af10894dd5 (patch) | |
tree | 73ed40b30af23ba3e5b94070e478f3e2ca1670c0 /src/parser/parse/state/setup.ts | |
parent | a72ab10c623022860691d6a095b74dea70cc6f69 (diff) | |
download | astro-30cccdf7154b6470e876464da9e412af10894dd5.tar.gz astro-30cccdf7154b6470e876464da9e412af10894dd5.tar.zst astro-30cccdf7154b6470e876464da9e412af10894dd5.zip |
add component state, top-level await support (#26)
Diffstat (limited to 'src/parser/parse/state/setup.ts')
-rw-r--r-- | src/parser/parse/state/setup.ts | 35 |
1 files changed, 35 insertions, 0 deletions
diff --git a/src/parser/parse/state/setup.ts b/src/parser/parse/state/setup.ts new file mode 100644 index 000000000..f64d8c52b --- /dev/null +++ b/src/parser/parse/state/setup.ts @@ -0,0 +1,35 @@ +// @ts-nocheck + +import { Parser } from '../index.js'; + +export default function setup(parser: Parser): void { + // TODO: Error if not at top of file? currently, we ignore / just treat as text. + // if (parser.html.children.length > 0) { + // parser.error({ + // code: 'unexpected-token', + // message: 'Frontmatter scripts only supported at the top of file.', + // }); + // } + + const start = parser.index; + parser.index += 3; + const content_start = parser.index; + const setupScriptContent = parser.read_until(/^---/m); + const content_end = parser.index; + parser.eat('---', true); + const end = parser.index; + parser.js.push({ + type: 'Script', + context: 'setup', + start, + end, + content: setupScriptContent, + // attributes, + // content: { + // start: content_start, + // end: content_end, + // styles, + // }, + }); + return; +} |