release: WRNexusJS 0.2.28
This commit is contained in:
@@ -124,8 +124,11 @@ export interface PropDecl {
|
||||
|
||||
export interface PageAst {
|
||||
type: "page";
|
||||
/** `page` (a route) or `component` (a reusable, prop-driven fragment). */
|
||||
kind: "page" | "component";
|
||||
/**
|
||||
* `page` is a route, `component` is a reusable fragment,
|
||||
* and `layout` is a reusable page wrapper.
|
||||
*/
|
||||
kind: "page" | "component" | "layout";
|
||||
name: string;
|
||||
/** Name of the page layout (`app/layouts/<layout>.wrn`), if the page sets one. */
|
||||
layout?: string;
|
||||
@@ -183,14 +186,18 @@ export function parse(source: string): PageAst {
|
||||
};
|
||||
|
||||
try {
|
||||
// A file is either a `page` (a route) or a `component` (a reusable fragment).
|
||||
// A file may contain a page, reusable component, or reusable layout.
|
||||
const opener = lx.next();
|
||||
if (opener.type !== "ident" || (opener.value !== "page" && opener.value !== "component")) {
|
||||
|
||||
if (opener.type !== "ident" || !["page", "component", "layout"].includes(opener.value)) {
|
||||
throw new ParseError(
|
||||
`Expected 'page' or 'component' but got '${opener.value || opener.type}' at offset ${opener.pos}`,
|
||||
`Expected 'page', 'component', or 'layout' but got '${
|
||||
opener.value || opener.type
|
||||
}' at offset ${opener.pos}`,
|
||||
);
|
||||
}
|
||||
const kind: "page" | "component" = opener.value === "component" ? "component" : "page";
|
||||
|
||||
const kind = opener.value as "page" | "component" | "layout";
|
||||
const name = expect("ident").value;
|
||||
expect("lbrace");
|
||||
|
||||
|
||||
Reference in New Issue
Block a user