Skip to content

Commit

Permalink
Merge branch 'main' into delucis/preact-compat
Browse files Browse the repository at this point in the history
  • Loading branch information
delucis authored Jun 29, 2022
2 parents 6e29b81 + 54cd6b8 commit 85cf581
Show file tree
Hide file tree
Showing 4 changed files with 30 additions and 7 deletions.
5 changes: 5 additions & 0 deletions .changeset/seven-rocks-sort.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'astro': patch
---

Fixes how `injectRoute` parses route patterns on Windows
28 changes: 22 additions & 6 deletions packages/astro/src/@types/astro.ts
Original file line number Diff line number Diff line change
Expand Up @@ -777,7 +777,8 @@ export type GetHydrateCallback = () => Promise<() => void | Promise<void>>;

/**
* getStaticPaths() options
* Docs: https://docs.astro.build/reference/api-reference/#getstaticpaths
*
* [Astro Reference](https://docs.astro.build/en/reference/api-reference/#getstaticpaths)
*/ export interface GetStaticPathsOptions {
paginate: PaginateFunction;
/**
Expand All @@ -793,6 +794,18 @@ export type GetStaticPathsResultKeyed = GetStaticPathsResult & {
keyed: Map<string, GetStaticPathsItem>;
};

/**
* Return an array of pages to generate for a [dynamic route](https://docs.astro.build/en/core-concepts/routing/#dynamic-routes). (**SSG Only**)
*
* [Astro Reference](https://docs.astro.build/en/reference/api-reference/#getstaticpaths)
*/
export type GetStaticPaths = (
options: GetStaticPathsOptions
) =>
| Promise<GetStaticPathsResult | GetStaticPathsResult[]>
| GetStaticPathsResult
| GetStaticPathsResult[];

export interface HydrateOptions {
name: string;
value?: string;
Expand Down Expand Up @@ -820,15 +833,17 @@ export interface MarkdownParserResponse extends MarkdownRenderingResult {

/**
* The `content` prop given to a Layout
* https://docs.astro.build/guides/markdown-content/#markdown-layouts
*
* [Astro reference](https://docs.astro.build/en/guides/markdown-content/#markdown-layouts)
*/
export type MarkdownContent<T extends Record<string, any> = Record<string, any>> = T & {
astro: MarkdownMetadata;
};

/**
* paginate() Options
* Docs: https://docs.astro.build/guides/pagination/#calling-the-paginate-function
*
* [Astro reference](https://docs.astro.build/en/reference/api-reference/#paginate)
*/
export interface PaginateOptions {
/** the number of items per-page (default: `10`) */
Expand All @@ -840,8 +855,9 @@ export interface PaginateOptions {
}

/**
* Page Prop
* Docs: https://docs.astro.build/guides/pagination/#using-the-page-prop
* Represents a single page of data in a paginated collection
*
* [Astro reference](https://docs.astro.build/en/reference/api-reference/#the-pagination-page-prop)
*/
export interface Page<T = any> {
/** result */
Expand Down Expand Up @@ -869,7 +885,7 @@ export interface Page<T = any> {
};
}

export type PaginateFunction = (data: [], args?: PaginateOptions) => GetStaticPathsResult;
export type PaginateFunction = (data: any[], args?: PaginateOptions) => GetStaticPathsResult;

export type Params = Record<string, string | number | undefined>;

Expand Down
3 changes: 2 additions & 1 deletion packages/astro/src/core/routing/manifest/create.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import path from 'path';
import slash from 'slash';
import { fileURLToPath } from 'url';
import { warn } from '../../logger/core.js';
import { removeLeadingForwardSlash } from '../../path.js';
import { resolvePages } from '../../util.js';
import { getRouteGenerator } from './generator.js';
const require = createRequire(import.meta.url);
Expand Down Expand Up @@ -294,7 +295,7 @@ export function createRouteManifest(
const isDynamic = (str: string) => str?.[0] === '[';
const normalize = (str: string) => str?.substring(1, str?.length - 1);

const segments = name
const segments = removeLeadingForwardSlash(name)
.split(path.sep)
.filter(Boolean)
.map((s: string) => {
Expand Down
1 change: 1 addition & 0 deletions packages/create-astro/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@ const { version } = JSON.parse(

const FILES_TO_REMOVE = ['.stackblitzrc', 'sandbox.config.json', 'CHANGELOG.md']; // some files are only needed for online editors when using astro.new. Remove for create-astro installs.

// Please also update the installation instructions in the docs at https://github.com/withastro/docs/blob/main/src/pages/en/install/auto.md if you make any changes to the flow or wording here.
export async function main() {
const pkgManager = pkgManagerFromUserAgent(process.env.npm_config_user_agent);

Expand Down

0 comments on commit 85cf581

Please sign in to comment.