Refactor routing in App component to enhance navigation and improve error handling by integrating dynamic routes and updating the NotFound route.
This commit is contained in:
37
node_modules/astro/dist/runtime/server/astro-component.js
generated
vendored
Normal file
37
node_modules/astro/dist/runtime/server/astro-component.js
generated
vendored
Normal file
@@ -0,0 +1,37 @@
|
||||
import { AstroError, AstroErrorData } from "../../core/errors/index.js";
|
||||
function validateArgs(args) {
|
||||
if (args.length !== 3) return false;
|
||||
if (!args[0] || typeof args[0] !== "object") return false;
|
||||
return true;
|
||||
}
|
||||
function baseCreateComponent(cb, moduleId, propagation) {
|
||||
const name = moduleId?.split("/").pop()?.replace(".astro", "") ?? "";
|
||||
const fn = (...args) => {
|
||||
if (!validateArgs(args)) {
|
||||
throw new AstroError({
|
||||
...AstroErrorData.InvalidComponentArgs,
|
||||
message: AstroErrorData.InvalidComponentArgs.message(name)
|
||||
});
|
||||
}
|
||||
return cb(...args);
|
||||
};
|
||||
Object.defineProperty(fn, "name", { value: name, writable: false });
|
||||
fn.isAstroComponentFactory = true;
|
||||
fn.moduleId = moduleId;
|
||||
fn.propagation = propagation;
|
||||
return fn;
|
||||
}
|
||||
function createComponentWithOptions(opts) {
|
||||
const cb = baseCreateComponent(opts.factory, opts.moduleId, opts.propagation);
|
||||
return cb;
|
||||
}
|
||||
function createComponent(arg1, moduleId, propagation) {
|
||||
if (typeof arg1 === "function") {
|
||||
return baseCreateComponent(arg1, moduleId, propagation);
|
||||
} else {
|
||||
return createComponentWithOptions(arg1);
|
||||
}
|
||||
}
|
||||
export {
|
||||
createComponent
|
||||
};
|
Reference in New Issue
Block a user