Skip to content

Commit 153a5ab

Browse files
authored
Remove deprecated features from Astro 3.0 (#9168)
1 parent c795364 commit 153a5ab

47 files changed

Lines changed: 95 additions & 398 deletions

File tree

Some content is hidden

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

.changeset/slow-hornets-try.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
'@astrojs/rss': major
3+
---
4+
5+
Removes the `drafts` option as the feature is deprecated in Astro 3.0
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
---
2+
'astro': major
3+
---
4+
5+
Removes deprecated features from Astro 3.0
6+
7+
- Adapters are now required to pass `supportedAstroFeatures` to specify a list of features they support.
8+
- The `build.split` and `build.excludeMiddleware` options are removed. Use `functionPerRoute` and `edgeMiddleware` from adapters instead.
9+
- The `markdown.drafts` option and draft feature is removed. Use content collections instead.
10+
- Lowercase endpoint names are no longer supported. Use uppercase endpoint names instead.
11+
- `getHeaders()` exported from markdown files is removed. Use `getHeadings()` instead.

benchmark/packages/timer/src/index.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ export function getAdapter(): AstroAdapter {
66
serverEntrypoint: '@benchmark/timer/server.js',
77
previewEntrypoint: '@benchmark/timer/preview.js',
88
exports: ['handler'],
9+
supportedAstroFeatures: {},
910
};
1011
}
1112

packages/astro-rss/README.md

Lines changed: 7 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ Start by [adding a `site` to your project's `astro.config` for link generation](
2828
import rss from '@astrojs/rss';
2929
import { getCollection } from 'astro:content';
3030

31-
export async function get(context) {
31+
export async function GET(context) {
3232
const posts = await getCollection('blog');
3333
return rss({
3434
title: 'Buzz’s Blog',
@@ -55,7 +55,7 @@ Read **[Astro's RSS docs][astro-rss]** for more on using content collections, an
5555
The `rss` default export offers a number of configuration options. Here's a quick reference:
5656

5757
```js
58-
export function get(context) {
58+
export function GET(context) {
5959
return rss({
6060
// `<title>` field in output xml
6161
title: 'Buzz’s Blog',
@@ -98,7 +98,7 @@ The base URL to use when generating RSS item links. We recommend using the [endp
9898
```ts
9999
import rss from '@astrojs/rss';
100100

101-
export const get = (context) =>
101+
export const GET = (context) =>
102102
rss({
103103
site: context.site,
104104
// ...
@@ -113,14 +113,6 @@ A list of formatted RSS feed items. See [Astro's RSS items documentation](https:
113113

114114
When providing a formatted RSS item list, see the [`RSSFeedItem` type reference](#rssfeeditem).
115115

116-
### drafts
117-
118-
Type: `boolean (optional)`
119-
120-
**Deprecated**: Manually filter `items` instead.
121-
122-
Set `drafts: true` to include [draft posts](https://docs.astro.build/en/guides/markdown-content/#draft-pages) in the feed output. By default, this option is `false` and draft posts are not included.
123-
124116
### stylesheet
125117

126118
Type: `string (optional)`
@@ -136,7 +128,7 @@ A string of valid XML to be injected between your feed's `<description>` and `<i
136128
```js
137129
import rss from '@astrojs/rss';
138130

139-
export const get = () => rss({
131+
export const GET = () => rss({
140132
...
141133
customData: '<language>en-us</language>',
142134
});
@@ -181,7 +173,7 @@ By default, the library will add trailing slashes to the emitted URLs. To preven
181173
```js
182174
import rss from '@astrojs/rss';
183175
184-
export const get = () =>
176+
export const GET = () =>
185177
rss({
186178
trailingSlash: false,
187179
});
@@ -361,7 +353,7 @@ This function assumes, but does not verify, you are globbing for items inside `s
361353
// src/pages/rss.xml.js
362354
import rss, { pagesGlobToRssItems } from '@astrojs/rss';
363355
364-
export async function get(context) {
356+
export async function GET(context) {
365357
return rss({
366358
title: 'Buzz’s Blog',
367359
description: 'A humble Astronaut’s guide to the stars',
@@ -379,7 +371,7 @@ As `rss()` returns a `Response`, you can also use `getRssString()` to get the RS
379371
// src/pages/rss.xml.js
380372
import { getRssString } from '@astrojs/rss';
381373
382-
export async function get(context) {
374+
export async function GET(context) {
383375
const rssString = await getRssString({
384376
title: 'Buzz’s Blog',
385377
...

packages/astro-rss/src/index.ts

Lines changed: 1 addition & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -27,11 +27,6 @@ export type RSSOptions = {
2727
stylesheet?: z.infer<typeof rssOptionsValidator>['stylesheet'];
2828
/** Specify custom data in opening of file */
2929
customData?: z.infer<typeof rssOptionsValidator>['customData'];
30-
/**
31-
* Whether to include drafts or not
32-
* @deprecated Deprecated since version 3.0. Use content collections instead.
33-
*/
34-
drafts?: z.infer<typeof rssOptionsValidator>['drafts'];
3530
trailingSlash?: z.infer<typeof rssOptionsValidator>['trailingSlash'];
3631
};
3732

@@ -48,11 +43,6 @@ export type RSSFeedItem = {
4843
description?: z.infer<typeof rssSchema>['description'];
4944
/** Append some other XML-valid data to this item */
5045
customData?: z.infer<typeof rssSchema>['customData'];
51-
/**
52-
* Whether draft or not
53-
* @deprecated Deprecated since version 3.0. Use content collections instead.
54-
*/
55-
draft?: z.infer<typeof rssSchema>['draft'];
5646
/** Categories or tags related to the item */
5747
categories?: z.infer<typeof rssSchema>['categories'];
5848
/** The item author's email address */
@@ -92,7 +82,6 @@ const rssOptionsValidator = z.object({
9282
return items;
9383
}),
9484
xmlns: z.record(z.string()).optional(),
95-
drafts: z.boolean().default(false),
9685
stylesheet: z.union([z.string(), z.boolean()]).optional(),
9786
customData: z.string().optional(),
9887
trailingSlash: z.boolean().default(true),
@@ -159,10 +148,7 @@ export function pagesGlobToRssItems(items: GlobResult): Promise<ValidatedRSSFeed
159148

160149
/** Generate RSS 2.0 feed */
161150
async function generateRSS(rssOptions: ValidatedRSSOptions): Promise<string> {
162-
const { site } = rssOptions;
163-
const items = rssOptions.drafts
164-
? rssOptions.items
165-
: rssOptions.items.filter((item) => !item.draft);
151+
const { items, site } = rssOptions;
166152

167153
const xmlOptions = {
168154
ignoreAttributes: false,

packages/astro-rss/src/schema.ts

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,6 @@ export const rssSchema = z.object({
88
.refine((value) => !isNaN(value.getTime())),
99
description: z.string().optional(),
1010
customData: z.string().optional(),
11-
draft: z.boolean().optional(),
1211
categories: z.array(z.string()).optional(),
1312
author: z.string().optional(),
1413
commentsUrl: z.string().optional(),

packages/astro-rss/test/rss.test.js

Lines changed: 1 addition & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -156,36 +156,12 @@ describe('getRssString', () => {
156156
chai.expect(str).to.contain(customData);
157157
});
158158

159-
it('should filter out entries marked as `draft`', async () => {
160-
const str = await getRssString({
161-
title,
162-
description,
163-
items: [phpFeedItem, { ...web1FeedItem, draft: true }],
164-
site,
165-
});
166-
167-
chai.expect(str).xml.to.equal(validXmlWithoutWeb1FeedResult);
168-
});
169-
170-
it('should respect drafts option', async () => {
171-
const str = await getRssString({
172-
title,
173-
description,
174-
items: [phpFeedItem, { ...web1FeedItem, draft: true }],
175-
site,
176-
drafts: true,
177-
});
178-
179-
chai.expect(str).xml.to.equal(validXmlResult);
180-
});
181-
182159
it('should not append trailing slash to URLs with the given option', async () => {
183160
const str = await getRssString({
184161
title,
185162
description,
186-
items: [phpFeedItem, { ...web1FeedItem, draft: true }],
163+
items: [phpFeedItem],
187164
site,
188-
drafts: true,
189165
trailingSlash: false,
190166
});
191167

packages/astro/client.d.ts

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -242,8 +242,6 @@ interface ExportedMarkdownModuleEntities {
242242
file: MD['file'];
243243
url: MD['url'];
244244
getHeadings: MD['getHeadings'];
245-
/** @deprecated Renamed to `getHeadings()` */
246-
getHeaders: () => void;
247245
Content: MD['Content'];
248246
rawContent: MD['rawContent'];
249247
compiledContent: MD['compiledContent'];

packages/astro/src/@types/astro.ts

Lines changed: 4 additions & 58 deletions
Original file line numberDiff line numberDiff line change
@@ -143,7 +143,6 @@ export interface CLIFlags {
143143
host?: string | boolean;
144144
port?: number;
145145
config?: string;
146-
drafts?: boolean;
147146
open?: boolean;
148147
}
149148

@@ -886,33 +885,6 @@ export interface AstroUserConfig {
886885
* ```
887886
*/
888887
inlineStylesheets?: 'always' | 'auto' | 'never';
889-
890-
/**
891-
* @docs
892-
* @name build.split
893-
* @type {boolean}
894-
* @default `false`
895-
* @deprecated Deprecated since version 3.0.
896-
* @description
897-
* The build config option `build.split` has been replaced by the adapter configuration option [`functionPerRoute`](/en/reference/adapter-reference/#functionperroute).
898-
*
899-
* Please see your [SSR adapter's documentation](/en/guides/integrations-guide/#official-integrations) for using `functionPerRoute` to define how your SSR code is bundled.
900-
*
901-
*/
902-
split?: boolean;
903-
904-
/**
905-
* @docs
906-
* @name build.excludeMiddleware
907-
* @type {boolean}
908-
* @default `false`
909-
* @deprecated Deprecated since version 3.0.
910-
* @description
911-
* The build config option `build.excludeMiddleware` has been replaced by the adapter configuration option [`edgeMiddleware`](/en/reference/adapter-reference/#edgemiddleware).
912-
*
913-
* Please see your [SSR adapter's documentation](/en/guides/integrations-guide/#official-integrations) for using `edgeMiddleware` to define whether or not any SSR middleware code will be bundled when built.
914-
*/
915-
excludeMiddleware?: boolean;
916888
};
917889

918890
/**
@@ -1183,28 +1155,6 @@ export interface AstroUserConfig {
11831155
* @name Markdown Options
11841156
*/
11851157
markdown?: {
1186-
/**
1187-
* @docs
1188-
* @name markdown.drafts
1189-
* @type {boolean}
1190-
* @default `false`
1191-
* @deprecated Deprecated since version 3.0. Use content collections instead.
1192-
* @description
1193-
* Control whether Markdown draft pages should be included in the build.
1194-
*
1195-
* A Markdown page is considered a draft if it includes `draft: true` in its frontmatter. Draft pages are always included & visible during development (`astro dev`) but by default they will not be included in your final build.
1196-
*
1197-
* ```js
1198-
* {
1199-
* markdown: {
1200-
* // Example: Include all drafts in your final build
1201-
* drafts: true,
1202-
* }
1203-
* }
1204-
* ```
1205-
*/
1206-
drafts?: boolean;
1207-
12081158
/**
12091159
* @docs
12101160
* @name markdown.shikiConfig
@@ -1749,10 +1699,6 @@ export interface ComponentInstance {
17491699
css?: string[];
17501700
partial?: boolean;
17511701
prerender?: boolean;
1752-
/**
1753-
* Only used for logging if deprecated drafts feature is used
1754-
*/
1755-
frontmatter?: Record<string, any>;
17561702
getStaticPaths?: (options: GetStaticPathsOptions) => GetStaticPathsResult;
17571703
}
17581704

@@ -2056,7 +2002,7 @@ export interface AstroAdapter {
20562002
*
20572003
* If the adapter is not able to handle certain configurations, Astro will throw an error.
20582004
*/
2059-
supportedAstroFeatures?: AstroFeatureMap;
2005+
supportedAstroFeatures: AstroFeatureMap;
20602006
}
20612007

20622008
type Body = string;
@@ -2145,7 +2091,7 @@ export interface APIContext<
21452091
* ];
21462092
* }
21472093
*
2148-
* export async function get({ params }) {
2094+
* export async function GET({ params }) {
21492095
* return {
21502096
* body: `Hello user ${params.id}!`,
21512097
* }
@@ -2168,7 +2114,7 @@ export interface APIContext<
21682114
* ];
21692115
* }
21702116
*
2171-
* export function get({ props }) {
2117+
* export function GET({ props }) {
21722118
* return {
21732119
* body: `Hello ${props.name}!`,
21742120
* }
@@ -2184,7 +2130,7 @@ export interface APIContext<
21842130
* Example usage:
21852131
* ```ts
21862132
* // src/pages/secret.ts
2187-
* export function get({ redirect }) {
2133+
* export function GET({ redirect }) {
21882134
* return redirect('/login');
21892135
* }
21902136
* ```

packages/astro/src/cli/build/index.ts

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,6 @@ export async function build({ flags }: BuildOptions) {
1414
usage: '[...flags]',
1515
tables: {
1616
Flags: [
17-
['--drafts', `Include Markdown draft pages in the build.`],
1817
['--outDir <directory>', `Specify the output directory for the build.`],
1918
['--help (-h)', 'See all available flags.'],
2019
],

0 commit comments

Comments
 (0)