Add first business article and article layout

This commit is contained in:
2026-05-21 12:14:46 -05:00
parent 200e14e2e9
commit 4735704c6f
9617 changed files with 988627 additions and 0 deletions

4
node_modules/astro/dist/core/render/index.d.ts generated vendored Normal file
View File

@@ -0,0 +1,4 @@
export { Pipeline } from '../base-pipeline.js';
export { getParams, getProps } from './params-and-props.js';
export { loadRenderer } from './renderer.js';
export { Slots } from './slots.js';

11
node_modules/astro/dist/core/render/index.js generated vendored Normal file
View File

@@ -0,0 +1,11 @@
import { Pipeline } from "../base-pipeline.js";
import { getParams, getProps } from "./params-and-props.js";
import { loadRenderer } from "./renderer.js";
import { Slots } from "./slots.js";
export {
Pipeline,
Slots,
getParams,
getProps,
loadRenderer
};

4
node_modules/astro/dist/core/render/paginate.d.ts generated vendored Normal file
View File

@@ -0,0 +1,4 @@
import type { PaginateFunction } from '../../types/public/common.js';
import type { AstroConfig } from '../../types/public/index.js';
import type { RouteData } from '../../types/public/internal.js';
export declare function generatePaginateFunction(routeMatch: RouteData, base: AstroConfig['base'], trailingSlash: AstroConfig['trailingSlash']): (...args: Parameters<PaginateFunction>) => ReturnType<PaginateFunction>;

76
node_modules/astro/dist/core/render/paginate.js generated vendored Normal file
View File

@@ -0,0 +1,76 @@
import { AstroError, AstroErrorData } from "../errors/index.js";
import { joinPaths } from "../path.js";
import { getRouteGenerator } from "../routing/generator.js";
function generatePaginateFunction(routeMatch, base, trailingSlash) {
return function paginateUtility(data, args = {}) {
const generate = getRouteGenerator(routeMatch.segments, trailingSlash);
let { pageSize: _pageSize, params: _params, props: _props } = args;
const pageSize = _pageSize || 10;
const paramName = "page";
const additionalParams = _params || {};
const additionalProps = _props || {};
let includesFirstPageNumber;
if (routeMatch.params.includes(`...${paramName}`)) {
includesFirstPageNumber = false;
} else if (routeMatch.params.includes(`${paramName}`)) {
includesFirstPageNumber = true;
} else {
throw new AstroError({
...AstroErrorData.PageNumberParamNotFound,
message: AstroErrorData.PageNumberParamNotFound.message(paramName)
});
}
const lastPage = Math.max(1, Math.ceil(data.length / pageSize));
const result = [...Array(lastPage).keys()].map((num) => {
const pageNum = num + 1;
const start = pageSize === Number.POSITIVE_INFINITY ? 0 : (pageNum - 1) * pageSize;
const end = Math.min(start + pageSize, data.length);
const params = {
...additionalParams,
[paramName]: includesFirstPageNumber || pageNum > 1 ? String(pageNum) : void 0
};
const current = addRouteBase(generate({ ...params }), base);
const next = pageNum === lastPage ? void 0 : addRouteBase(generate({ ...params, page: String(pageNum + 1) }), base);
const prev = pageNum === 1 ? void 0 : addRouteBase(
generate({
...params,
page: !includesFirstPageNumber && pageNum - 1 === 1 ? void 0 : String(pageNum - 1)
}),
base
);
const first = pageNum === 1 ? void 0 : addRouteBase(
generate({
...params,
page: includesFirstPageNumber ? "1" : void 0
}),
base
);
const last = pageNum === lastPage ? void 0 : addRouteBase(generate({ ...params, page: String(lastPage) }), base);
return {
params,
props: {
...additionalProps,
page: {
data: data.slice(start, end),
start,
end: end - 1,
size: pageSize,
total: data.length,
currentPage: pageNum,
lastPage,
url: { current, next, prev, first, last }
}
}
};
});
return result;
};
}
function addRouteBase(route, base) {
let routeWithBase = joinPaths(base, route);
if (routeWithBase === "") routeWithBase = "/";
return routeWithBase;
}
export {
generatePaginateFunction
};

View File

@@ -0,0 +1,23 @@
import type { ComponentInstance } from '../../types/astro.js';
import type { Params, Props } from '../../types/public/common.js';
import type { AstroConfig } from '../../types/public/index.js';
import type { RouteData } from '../../types/public/internal.js';
import type { AstroLogger } from '../logger/core.js';
import type { RouteCache } from './route-cache.js';
interface GetParamsAndPropsOptions {
mod: ComponentInstance | undefined;
routeData?: RouteData | undefined;
routeCache: RouteCache;
pathname: string;
logger: AstroLogger;
serverLike: boolean;
base: string;
trailingSlash: AstroConfig['trailingSlash'];
}
export declare function getProps(opts: GetParamsAndPropsOptions): Promise<Props>;
/**
* When given a route with the pattern `/[x]/[y]/[z]/svelte`, and a pathname `/a/b/c/svelte`,
* returns the params object: { x: "a", y: "b", z: "c" }.
*/
export declare function getParams(route: RouteData, pathname: string): Params;
export {};

View File

@@ -0,0 +1,81 @@
import { DEFAULT_404_COMPONENT } from "../constants.js";
import { AstroError, AstroErrorData } from "../errors/index.js";
import { routeHasHtmlExtension, routeIsFallback, routeIsRedirect } from "../routing/helpers.js";
import { callGetStaticPaths, findPathItemByKey } from "./route-cache.js";
async function getProps(opts) {
const {
logger,
mod,
routeData: route,
routeCache,
pathname,
serverLike,
base,
trailingSlash
} = opts;
if (!route || route.pathname) {
return {};
}
if (routeIsRedirect(route) || routeIsFallback(route) || route.component === DEFAULT_404_COMPONENT) {
return {};
}
const staticPaths = await callGetStaticPaths({
mod,
route,
routeCache,
ssr: serverLike,
base,
trailingSlash
});
const params = getParams(route, pathname);
const matchedStaticPath = findPathItemByKey(staticPaths, params, route, logger, trailingSlash);
if (!matchedStaticPath && (serverLike ? route.prerender : true)) {
throw new AstroError({
...AstroErrorData.NoMatchingStaticPathFound,
message: AstroErrorData.NoMatchingStaticPathFound.message(pathname),
hint: AstroErrorData.NoMatchingStaticPathFound.hint([route.component])
});
}
if (mod) {
validatePrerenderEndpointCollision(route, mod, params);
}
const props = matchedStaticPath?.props ? { ...matchedStaticPath.props } : {};
return props;
}
function getParams(route, pathname) {
if (!route.params.length) return {};
const path = pathname.endsWith(".html") && route.type === "page" && !routeHasHtmlExtension(route) ? pathname.slice(0, -5) : pathname;
const allPatterns = [route, ...route.fallbackRoutes].map((r) => r.pattern);
const paramsMatch = allPatterns.map((pattern) => pattern.exec(path)).find((x) => x);
if (!paramsMatch) return {};
const params = {};
route.params.forEach((key, i) => {
if (key.startsWith("...")) {
params[key.slice(3)] = paramsMatch[i + 1] ? paramsMatch[i + 1] : void 0;
} else {
params[key] = paramsMatch[i + 1];
}
});
return params;
}
function validatePrerenderEndpointCollision(route, mod, params) {
if (route.type === "endpoint" && mod.getStaticPaths) {
const lastSegment = route.segments[route.segments.length - 1];
const paramValues = Object.values(params);
const lastParam = paramValues[paramValues.length - 1];
if (lastSegment.length === 1 && lastSegment[0].dynamic && lastParam === void 0) {
throw new AstroError({
...AstroErrorData.PrerenderDynamicEndpointPathCollide,
message: AstroErrorData.PrerenderDynamicEndpointPathCollide.message(route.route),
hint: AstroErrorData.PrerenderDynamicEndpointPathCollide.hint(route.component),
location: {
file: route.component
}
});
}
}
}
export {
getParams,
getProps
};

4
node_modules/astro/dist/core/render/renderer.d.ts generated vendored Normal file
View File

@@ -0,0 +1,4 @@
import type { AstroRenderer } from '../../types/public/integrations.js';
import type { SSRLoadedRenderer } from '../../types/public/internal.js';
import type { ModuleLoader } from '../module-loader/index.js';
export declare function loadRenderer(renderer: AstroRenderer, moduleLoader: ModuleLoader): Promise<SSRLoadedRenderer | undefined>;

13
node_modules/astro/dist/core/render/renderer.js generated vendored Normal file
View File

@@ -0,0 +1,13 @@
async function loadRenderer(renderer, moduleLoader) {
const mod = await moduleLoader.import(renderer.serverEntrypoint.toString());
if (typeof mod.default !== "undefined") {
return {
...renderer,
ssr: mod.default
};
}
return void 0;
}
export {
loadRenderer
};

35
node_modules/astro/dist/core/render/route-cache.d.ts generated vendored Normal file
View File

@@ -0,0 +1,35 @@
import type { ComponentInstance } from '../../types/astro.js';
import type { GetStaticPathsItem, GetStaticPathsResultKeyed, Params } from '../../types/public/common.js';
import type { AstroConfig, RuntimeMode } from '../../types/public/config.js';
import type { RouteData } from '../../types/public/internal.js';
import type { AstroLogger } from '../logger/core.js';
interface CallGetStaticPathsOptions {
mod: ComponentInstance | undefined;
route: RouteData;
routeCache: RouteCache;
ssr: boolean;
base: AstroConfig['base'];
trailingSlash: AstroConfig['trailingSlash'];
}
export declare function callGetStaticPaths({ mod, route, routeCache, ssr, base, trailingSlash, }: CallGetStaticPathsOptions): Promise<GetStaticPathsResultKeyed>;
interface RouteCacheEntry {
staticPaths: GetStaticPathsResultKeyed;
}
/**
* Manage the route cache, responsible for caching data related to each route,
* including the result of calling getStaticPath() so that it can be reused across
* responses during dev and only ever called once during build.
*/
export declare class RouteCache {
private logger;
private cache;
private runtimeMode;
constructor(logger: AstroLogger, runtimeMode?: RuntimeMode);
/** Clear the cache. */
clearAll(): void;
set(route: RouteData, entry: RouteCacheEntry): void;
get(route: RouteData): RouteCacheEntry | undefined;
key(route: RouteData): string;
}
export declare function findPathItemByKey(staticPaths: GetStaticPathsResultKeyed, params: Params, route: RouteData, logger: AstroLogger, trailingSlash: AstroConfig['trailingSlash']): GetStaticPathsItem | undefined;
export {};

83
node_modules/astro/dist/core/render/route-cache.js generated vendored Normal file
View File

@@ -0,0 +1,83 @@
import { stringifyParams } from "../routing/params.js";
import { validateDynamicRouteModule, validateGetStaticPathsResult } from "../routing/validation.js";
import { generatePaginateFunction } from "./paginate.js";
async function callGetStaticPaths({
mod,
route,
routeCache,
ssr,
base,
trailingSlash
}) {
const cached = routeCache.get(route);
if (!mod) {
throw new Error("This is an error caused by Astro and not your code. Please file an issue.");
}
if (cached?.staticPaths) {
return cached.staticPaths;
}
validateDynamicRouteModule(mod, { ssr, route });
if (ssr && !route.prerender) {
const entry = Object.assign([], { keyed: /* @__PURE__ */ new Map() });
routeCache.set(route, { ...cached, staticPaths: entry });
return entry;
}
let staticPaths = [];
if (!mod.getStaticPaths) {
throw new Error("Unexpected Error.");
}
staticPaths = await mod.getStaticPaths({
// Q: Why the cast?
// A: So users downstream can have nicer typings, we have to make some sacrifice in our internal typings, which necessitate a cast here
paginate: generatePaginateFunction(route, base, trailingSlash),
routePattern: route.route
});
validateGetStaticPathsResult(staticPaths, route);
const keyedStaticPaths = staticPaths;
keyedStaticPaths.keyed = /* @__PURE__ */ new Map();
for (const sp of keyedStaticPaths) {
const paramsKey = stringifyParams(sp.params, route, trailingSlash);
keyedStaticPaths.keyed.set(paramsKey, sp);
}
routeCache.set(route, { ...cached, staticPaths: keyedStaticPaths });
return keyedStaticPaths;
}
class RouteCache {
logger;
cache = {};
runtimeMode;
constructor(logger, runtimeMode = "production") {
this.logger = logger;
this.runtimeMode = runtimeMode;
}
/** Clear the cache. */
clearAll() {
this.cache = {};
}
set(route, entry) {
const key = this.key(route);
if (this.runtimeMode === "production" && this.cache[key]?.staticPaths) {
this.logger.warn(null, `Internal Warning: route cache overwritten. (${key})`);
}
this.cache[key] = entry;
}
get(route) {
return this.cache[this.key(route)];
}
key(route) {
return `${route.route}_${route.component}`;
}
}
function findPathItemByKey(staticPaths, params, route, logger, trailingSlash) {
const paramsKey = stringifyParams(params, route, trailingSlash);
const matchedStaticPath = staticPaths.keyed.get(paramsKey);
if (matchedStaticPath) {
return matchedStaticPath;
}
logger.debug("router", `findPathItemByKey() - Unexpected cache miss looking for ${paramsKey}`);
}
export {
RouteCache,
callGetStaticPaths,
findPathItemByKey
};

9
node_modules/astro/dist/core/render/slots.d.ts generated vendored Normal file
View File

@@ -0,0 +1,9 @@
import { type ComponentSlots } from '../../runtime/server/index.js';
import type { SSRResult } from '../../types/public/internal.js';
import type { AstroLogger } from '../logger/core.js';
export declare class Slots {
#private;
constructor(result: SSRResult, slots: ComponentSlots | null, logger: AstroLogger);
has(name: string): boolean;
render(name: string, args?: any[]): Promise<any>;
}

79
node_modules/astro/dist/core/render/slots.js generated vendored Normal file
View File

@@ -0,0 +1,79 @@
import { renderSlotToString } from "../../runtime/server/index.js";
import { renderJSX } from "../../runtime/server/jsx.js";
import { isRenderTemplateResult } from "../../runtime/server/render/astro/index.js";
import { chunkToString } from "../../runtime/server/render/index.js";
import { isRenderInstruction } from "../../runtime/server/render/instruction.js";
import { AstroError, AstroErrorData } from "../errors/index.js";
function getFunctionExpression(slot) {
if (!slot) return;
const expressions = slot?.expressions?.filter(
(e) => isRenderInstruction(e) === false || isRenderTemplateResult(e)
);
if (expressions?.length !== 1) return;
const expression = expressions[0];
if (isRenderTemplateResult(expression)) {
return getFunctionExpression(expression);
}
return expression;
}
class Slots {
#result;
#slots;
#logger;
constructor(result, slots, logger) {
this.#result = result;
this.#slots = slots;
this.#logger = logger;
if (slots) {
for (const key of Object.keys(slots)) {
if (this[key] !== void 0) {
throw new AstroError({
...AstroErrorData.ReservedSlotName,
message: AstroErrorData.ReservedSlotName.message(key)
});
}
Object.defineProperty(this, key, {
get() {
return true;
},
enumerable: true
});
}
}
}
has(name) {
if (!this.#slots) return false;
return Boolean(this.#slots[name]);
}
async render(name, args = []) {
if (!this.#slots || !this.has(name)) return;
const result = this.#result;
if (!Array.isArray(args)) {
this.#logger.warn(
null,
`Expected second parameter to be an array, received a ${typeof args}. If you're trying to pass an array as a single argument and getting unexpected results, make sure you're passing your array as an item of an array. Ex: Astro.slots.render('default', [["Hello", "World"]])`
);
} else if (args.length > 0) {
const slotValue = this.#slots[name];
const component = typeof slotValue === "function" ? await slotValue(result) : await slotValue;
const expression = getFunctionExpression(component);
if (expression) {
const slot = async () => typeof expression === "function" ? expression(...args) : expression;
return await renderSlotToString(result, slot).then((res) => {
return res;
});
}
if (typeof component === "function") {
return await renderJSX(result, component(...args)).then(
(res) => res != null ? String(res) : res
);
}
}
const content = await renderSlotToString(result, this.#slots[name]);
const outHTML = chunkToString(result, content);
return outHTML;
}
}
export {
Slots
};

8
node_modules/astro/dist/core/render/ssr-element.d.ts generated vendored Normal file
View File

@@ -0,0 +1,8 @@
import type { SSRElement } from '../../types/public/internal.js';
import type { AssetsPrefix, StylesheetAsset } from '../app/types.js';
export declare function createAssetLink(href: string, base?: string, assetsPrefix?: AssetsPrefix, queryParams?: URLSearchParams): string;
export declare function createStylesheetElementSet(stylesheets: StylesheetAsset[], base?: string, assetsPrefix?: AssetsPrefix, queryParams?: URLSearchParams): Set<SSRElement>;
export declare function createModuleScriptElement(script: {
type: 'inline' | 'external';
value: string;
}, base?: string, assetsPrefix?: AssetsPrefix, queryParams?: URLSearchParams): SSRElement;

86
node_modules/astro/dist/core/render/ssr-element.js generated vendored Normal file
View File

@@ -0,0 +1,86 @@
import { getAssetsPrefix } from "../../assets/utils/getAssetsPrefix.js";
import { fileExtension, joinPaths, prependForwardSlash, slash } from "../../core/path.js";
const URL_PARSE_BASE = "https://astro.build";
function splitAssetPath(path) {
const parsed = new URL(path, URL_PARSE_BASE);
const isAbsolute = URL.canParse(path);
const pathname = !isAbsolute && !path.startsWith("/") ? parsed.pathname.slice(1) : parsed.pathname;
return {
pathname,
suffix: `${parsed.search}${parsed.hash}`
};
}
function appendQueryParams(path, queryParams) {
const queryString = queryParams.toString();
if (!queryString) {
return path;
}
const hashIndex = path.indexOf("#");
const basePath = hashIndex === -1 ? path : path.slice(0, hashIndex);
const hash = hashIndex === -1 ? "" : path.slice(hashIndex);
const separator = basePath.includes("?") ? "&" : "?";
return `${basePath}${separator}${queryString}${hash}`;
}
function createAssetLink(href, base, assetsPrefix, queryParams) {
const { pathname, suffix } = splitAssetPath(href);
let url = "";
if (assetsPrefix) {
const pf = getAssetsPrefix(fileExtension(pathname), assetsPrefix);
url = joinPaths(pf, slash(pathname)) + suffix;
} else if (base) {
url = prependForwardSlash(joinPaths(base, slash(pathname))) + suffix;
} else {
url = href;
}
if (queryParams) {
url = appendQueryParams(url, queryParams);
}
return url;
}
function createStylesheetElement(stylesheet, base, assetsPrefix, queryParams) {
if (stylesheet.type === "inline") {
return {
props: {},
children: stylesheet.content
};
} else {
return {
props: {
rel: "stylesheet",
href: createAssetLink(stylesheet.src, base, assetsPrefix, queryParams)
},
children: ""
};
}
}
function createStylesheetElementSet(stylesheets, base, assetsPrefix, queryParams) {
return new Set(
stylesheets.map((s) => createStylesheetElement(s, base, assetsPrefix, queryParams))
);
}
function createModuleScriptElement(script, base, assetsPrefix, queryParams) {
if (script.type === "external") {
return createModuleScriptElementWithSrc(script.value, base, assetsPrefix, queryParams);
} else {
return {
props: {
type: "module"
},
children: script.value
};
}
}
function createModuleScriptElementWithSrc(src, base, assetsPrefix, queryParams) {
return {
props: {
type: "module",
src: createAssetLink(src, base, assetsPrefix, queryParams)
},
children: ""
};
}
export {
createAssetLink,
createModuleScriptElement,
createStylesheetElementSet
};