Skip to content

Commit 9399cd9

Browse files
authored
DirectoryListing tag filter (#22064)
* Dynamic * DirectoryListing tag filter
1 parent 23c6705 commit 9399cd9

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

42 files changed

+631
-375
lines changed

public/__redirects

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1584,7 +1584,9 @@
15841584
/workers/tutorials/create-sitemap-from-sanity-cms/ /developer-spotlight/tutorials/create-sitemap-from-sanity-cms/ 301
15851585
/workers/tutorials/custom-access-control-for-files-in-r2-using-d1-and-workers/ /developer-spotlight/tutorials/custom-access-control-for-files/ 301
15861586
/workers/tutorials/generate-dynamic-og-images-using-workers/ /workers/tutorials/ 302
1587-
/workers/static-assets/compatibility-matrix/ /workers/static-assets/migrate-from-pages/ 301
1587+
/workers/static-assets/migrate-from-pages/ /workers/static-assets/migration-guides/migrate-from-pages/ 301
1588+
/workers/static-assets/compatibility-matrix/ /workers/static-assets/migration-guides/migrate-from-pages/ 301
1589+
/workers/static-assets/migrations/vercel-to-workers/ /workers/static-assets/migration-guides/vercel-to-workers/ 301
15881590
/workers/frameworks/framework-guides/remix/ /workers/frameworks/framework-guides/react-router/ 301
15891591
/workers/testing/unit-testing/ /workers/testing/vitest-integration/write-your-first-test/ 301
15901592
/workers/testing/integration-testing/ /workers/testing/ 301

src/components/DirectoryListing.astro

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,9 +15,10 @@ const props = z.object({
1515
descriptions: z.boolean().default(false),
1616
folder: z.string().optional(),
1717
maxDepth: z.number().default(1),
18+
tag: z.string().optional(),
1819
});
1920
20-
let { descriptions, folder, maxDepth } = props.parse(Astro.props);
21+
let { descriptions, folder, maxDepth, tag } = props.parse(Astro.props);
2122
2223
if (!folder) folder = Astro.params.slug!;
2324
@@ -34,7 +35,11 @@ function getChildren(parentPath: string, depth: number) {
3435
return allPages.filter((page) => {
3536
const pagePath = page.id;
3637
const pageDepth = pagePath.split("/").length;
37-
return pageDepth === depth && pagePath.startsWith(parentPath);
38+
return (
39+
pageDepth === depth &&
40+
pagePath.startsWith(parentPath) &&
41+
(tag ? page.data.tags?.includes(tag) : true)
42+
);
3843
});
3944
}
4045

src/content/compatibility-flags/assets-navigation-prefers-asset-serving.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ enable_flag: "assets_navigation_prefers_asset_serving"
1111
disable_flag: "assets_navigation_has_no_effect"
1212
---
1313

14-
For Workers with [static assets](/workers/static-assets/) and this compatibility flag enabled, navigation requests (requests which have a `Sec-Fetch-Mode: navigate` header) will prefer to be served by our asset-serving logic, even when an exact asset match cannot be found. This is particularly useful for applications which operate in either [Single Page Application (SPA) mode](/workers/static-assets/routing/#not_found_handling--404-page--single-page-application--none) or [404 page mode](/workers/static-assets/routing/#not_found_handling--404-page--single-page-application--none), as this now means the fallback pages of `200 /index.html` and `404 /404.html` will be served ahead of invoking a Worker script and will therefore avoid incurring a charge.
14+
For Workers with [static assets](/workers/static-assets/) and this compatibility flag enabled, navigation requests (requests which have a `Sec-Fetch-Mode: navigate` header) will prefer to be served by our asset-serving logic, even when an exact asset match cannot be found. This is particularly useful for applications which operate in either [Single Page Application (SPA) mode](/workers/static-assets/routing/single-page-application/) or have [custom 404 pages](/workers/static-assets/routing/static-site-generation/#custom-404-pages), as this now means the fallback pages of `200 /index.html` and `404 /404.html` will be served ahead of invoking a Worker script and will therefore avoid incurring a charge.
1515

1616
Without this flag, the runtime will continue to apply the old behavior of invoking a Worker script (if present) for any requests which do not exactly match a static asset.
1717

src/content/docs/pages/framework-guides/nextjs/ssr/supported-features.mdx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ The [`@opennextjs/cloudflare` adapter](https://opennext.js.org/cloudflare), whic
2222

2323
`@opennextjs/cloudflare` is pre 1.0, and still in active development. As it approaches 1.0, it will become the clearly better choice for most Next.js apps, since Next.js has been engineered to only support its Node.js "runtime" for many newly introduced features.
2424

25-
Refer to the [OpenNext docs](https://opennext.js.org/cloudflare) and the [Workers vs. Pages compatibility matrix](/workers/static-assets/migrations/migrate-from-pages/#compatibility-matrix) for more information to help you decide which to use.
25+
Refer to the [OpenNext docs](https://opennext.js.org/cloudflare) and the [Workers vs. Pages compatibility matrix](/workers/static-assets/migration-guides/migrate-from-pages/#compatibility-matrix) for more information to help you decide which to use.
2626

2727
#### Supported Node.js APIs when using `@cloudflare/next-on-pages`
2828

src/content/docs/style-guide/components/directory-listing.mdx

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,12 @@ When enabled, shows the [frontmatter `description`](/style-guide/frontmatter/) f
5353

5454
Controls how many levels of nested pages to display. A value of `1` shows only direct children, while higher values will show deeper nesting levels.
5555

56+
### `tag`
57+
58+
**type:** `string`
59+
60+
Optionally, filter the listing to only pages with a specific tag.
61+
5662
## Associated content types
5763

5864
- [Navigation](/style-guide/documentation-content-strategy/content-types/navigation/)

src/content/docs/workers/configuration/multipart-upload-metadata.mdx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -43,8 +43,8 @@ At a minimum, the `main_module` key is required to upload a Worker.
4343

4444
* [Asset](/workers/static-assets/) configuration for a Worker.
4545
* `config` <Type text="object" /> <MetaInfo text="optional" />
46-
* [html_handling](/workers/static-assets/routing/#1-html_handling) determines the redirects and rewrites of requests for HTML content.
47-
* [not_found_handling](/workers/static-assets/routing/#2-not_found_handling) determines the response when a request does not match a static asset, and there is no Worker script.
46+
* [html_handling](/workers/static-assets/routing/advanced/html-handling/) determines the redirects and rewrites of requests for HTML content.
47+
* [not_found_handling](/workers/static-assets/routing/) determines the response when a request does not match a static asset.
4848
* `jwt` field provides a token authorizing assets to be attached to a Worker.
4949

5050
* `keep_assets` <Type text="boolean" /> <MetaInfo text="optional" />

src/content/docs/workers/frameworks/framework-guides/angular.mdx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
---
22
pcx_content_type: how-to
33
title: Angular
4-
head: []
4+
tags: ["full-stack"]
55
description: Create an Angular application and deploy it to Cloudflare Workers with Workers Assets.
66
---
77

src/content/docs/workers/frameworks/framework-guides/astro.mdx

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
---
22
pcx_content_type: how-to
33
title: Astro
4-
head: []
4+
tags: ["ssg", "full-stack"]
55
description: Create an Astro application and deploy it to Cloudflare Workers with Workers Assets.
66
---
77

@@ -38,7 +38,7 @@ import {
3838

3939
Astro emphasizes performance through minimal client-side JavaScript - by default, it renders as much content as possible at build time, or [on-demand](https://docs.astro.build/en/guides/on-demand-rendering/) on the "server" - this can be a Cloudflare Worker. [“Islands”](https://docs.astro.build/en/concepts/islands/) of JavaScript are added only where interactivity or personalization is needed.
4040

41-
Astro is also framework-agnostic, and supports every major UI framework, including React, Preact, Svelte, Vue, SolidJS , via its official [integrations](https://astro.build/integrations/).
41+
Astro is also framework-agnostic, and supports every major UI framework, including React, Preact, Svelte, Vue, SolidJS, via its official [integrations](https://astro.build/integrations/).
4242

4343
## Deploy a new Astro project on Workers
4444

@@ -96,7 +96,7 @@ If your Astro project is entirely pre-rendered, follow these steps:
9696
</WranglerConfig>
9797
<Details header="What's this configuration doing?">
9898
The key part of this config is the `assets` field, which tells Wrangler where to find your static assets. In this case, we're telling Wrangler to look in the `./dist` directory. If your assets are in a different directory, update the `directory` value accordingly.
99-
Read about other [asset configuration options](/workers/static-assets/routing/).
99+
Read about other [asset configuration options](/workers/wrangler/configuration/#assets).
100100

101101
Also note how there's no `main` field in this config - this is because you're only serving static assets, so no Worker code is needed for on demand rendering/SSR.
102102
</Details>
@@ -161,7 +161,7 @@ If your Astro project uses [on demand rendering (also known as SSR)](https://doc
161161
- `main` points to the entry point of your Worker script. This is generated by the Astro adaptor, and is what powers your server-rendered pages.
162162
- `assets.directory` tells Wrangler where to find your static assets. In this case, we're telling Wrangler to look in the `./dist` directory. If your assets are in a different directory, update the `directory` value accordingly.
163163

164-
Read more about [Wrangler configuration options](/workers/wrangler/configuration/) and [asset configuration options](/workers/static-assets/routing/).
164+
Read more about [Wrangler configuration options](/workers/wrangler/configuration/) and [asset configuration options](/workers/wrangler/configuration/#assets).
165165
</Details>
166166

167167
4. **Build and deploy your project**

src/content/docs/workers/frameworks/framework-guides/docusaurus.mdx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
---
22
pcx_content_type: how-to
33
title: Docusaurus
4-
head: []
4+
tags: ["ssg"]
55
description: Create a Docusaurus application and deploy it to Cloudflare Workers with Workers Assets.
66
---
77

src/content/docs/workers/frameworks/framework-guides/gatsby.mdx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
---
22
pcx_content_type: how-to
33
title: Gatsby
4-
head: []
4+
tags: ["ssg"]
55
description: Create a Gatsby application and deploy it to Cloudflare Workers with Workers Assets.
66
---
77

0 commit comments

Comments
 (0)