Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Remove deprecated features from Astro 3.0 #9168

Merged
merged 7 commits into from
Nov 27, 2023
Merged
Show file tree
Hide file tree
Changes from 6 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions .changeset/slow-hornets-try.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'@astrojs/rss': major
---

Removes the `markdown.drafts` option as the feature is deprecated in Astro 3.0
bluwy marked this conversation as resolved.
Show resolved Hide resolved
11 changes: 11 additions & 0 deletions .changeset/wicked-sloths-develop.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
---
'astro': major
---

Removes deprecated features from Astro 3.0

- Adapters are now required to pass `supportedAstroFeatures` to specify a list of features they support.
- The `build.split` and `build.excludeMiddleware` options are removed. Use `functionPerRoute` and `edgeMiddleware` from adapters instead.
- The `markdown.drafts` option and draft feature is removed. Use content collections instead.
- Lowercase endpoint names are no longer supported. Use uppercase endpoint names instead.
- `getHeaders()` exported from markdown files is removed. Use `getHeadings()` instead.
1 change: 1 addition & 0 deletions benchmark/packages/timer/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ export function getAdapter(): AstroAdapter {
serverEntrypoint: '@benchmark/timer/server.js',
previewEntrypoint: '@benchmark/timer/preview.js',
exports: ['handler'],
supportedAstroFeatures: {},
};
}

Expand Down
22 changes: 7 additions & 15 deletions packages/astro-rss/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ Start by [adding a `site` to your project's `astro.config` for link generation](
import rss from '@astrojs/rss';
import { getCollection } from 'astro:content';

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

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

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

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

### drafts

Type: `boolean (optional)`

**Deprecated**: Manually filter `items` instead.

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.

### stylesheet

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

export const get = () => rss({
export const GET = () => rss({
...
customData: '<language>en-us</language>',
});
Expand Down Expand Up @@ -181,7 +173,7 @@ By default, the library will add trailing slashes to the emitted URLs. To preven
```js
import rss from '@astrojs/rss';

export const get = () =>
export const GET = () =>
rss({
trailingSlash: false,
});
Expand Down Expand Up @@ -361,7 +353,7 @@ This function assumes, but does not verify, you are globbing for items inside `s
// src/pages/rss.xml.js
import rss, { pagesGlobToRssItems } from '@astrojs/rss';

export async function get(context) {
export async function GET(context) {
return rss({
title: 'Buzz’s Blog',
description: 'A humble Astronaut’s guide to the stars',
Expand All @@ -379,7 +371,7 @@ As `rss()` returns a `Response`, you can also use `getRssString()` to get the RS
// src/pages/rss.xml.js
import { getRssString } from '@astrojs/rss';

export async function get(context) {
export async function GET(context) {
const rssString = await getRssString({
title: 'Buzz’s Blog',
...
Expand Down
16 changes: 1 addition & 15 deletions packages/astro-rss/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -27,11 +27,6 @@ export type RSSOptions = {
stylesheet?: z.infer<typeof rssOptionsValidator>['stylesheet'];
/** Specify custom data in opening of file */
customData?: z.infer<typeof rssOptionsValidator>['customData'];
/**
* Whether to include drafts or not
* @deprecated Deprecated since version 3.0. Use content collections instead.
*/
drafts?: z.infer<typeof rssOptionsValidator>['drafts'];
trailingSlash?: z.infer<typeof rssOptionsValidator>['trailingSlash'];
};

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

/** Generate RSS 2.0 feed */
async function generateRSS(rssOptions: ValidatedRSSOptions): Promise<string> {
const { site } = rssOptions;
const items = rssOptions.drafts
? rssOptions.items
: rssOptions.items.filter((item) => !item.draft);
const { items, site } = rssOptions;

const xmlOptions = {
ignoreAttributes: false,
Expand Down
1 change: 0 additions & 1 deletion packages/astro-rss/src/schema.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@ export const rssSchema = z.object({
.refine((value) => !isNaN(value.getTime())),
description: z.string().optional(),
customData: z.string().optional(),
draft: z.boolean().optional(),
categories: z.array(z.string()).optional(),
author: z.string().optional(),
commentsUrl: z.string().optional(),
Expand Down
26 changes: 1 addition & 25 deletions packages/astro-rss/test/rss.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -156,36 +156,12 @@ describe('getRssString', () => {
chai.expect(str).to.contain(customData);
});

it('should filter out entries marked as `draft`', async () => {
const str = await getRssString({
title,
description,
items: [phpFeedItem, { ...web1FeedItem, draft: true }],
site,
});

chai.expect(str).xml.to.equal(validXmlWithoutWeb1FeedResult);
});

it('should respect drafts option', async () => {
const str = await getRssString({
title,
description,
items: [phpFeedItem, { ...web1FeedItem, draft: true }],
site,
drafts: true,
});

chai.expect(str).xml.to.equal(validXmlResult);
});

it('should not append trailing slash to URLs with the given option', async () => {
const str = await getRssString({
title,
description,
items: [phpFeedItem, { ...web1FeedItem, draft: true }],
items: [phpFeedItem],
site,
drafts: true,
trailingSlash: false,
});

Expand Down
2 changes: 0 additions & 2 deletions packages/astro/client.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -242,8 +242,6 @@ interface ExportedMarkdownModuleEntities {
file: MD['file'];
url: MD['url'];
getHeadings: MD['getHeadings'];
/** @deprecated Renamed to `getHeadings()` */
getHeaders: () => void;
Content: MD['Content'];
rawContent: MD['rawContent'];
compiledContent: MD['compiledContent'];
Expand Down
62 changes: 4 additions & 58 deletions packages/astro/src/@types/astro.ts
Original file line number Diff line number Diff line change
Expand Up @@ -143,7 +143,6 @@ export interface CLIFlags {
host?: string | boolean;
port?: number;
config?: string;
drafts?: boolean;
open?: boolean;
}

Expand Down Expand Up @@ -886,33 +885,6 @@ export interface AstroUserConfig {
* ```
*/
inlineStylesheets?: 'always' | 'auto' | 'never';

/**
* @docs
* @name build.split
* @type {boolean}
* @default `false`
* @deprecated Deprecated since version 3.0.
* @description
* The build config option `build.split` has been replaced by the adapter configuration option [`functionPerRoute`](/en/reference/adapter-reference/#functionperroute).
*
* Please see your [SSR adapter's documentation](/en/guides/integrations-guide/#official-integrations) for using `functionPerRoute` to define how your SSR code is bundled.
*
*/
split?: boolean;

/**
* @docs
* @name build.excludeMiddleware
* @type {boolean}
* @default `false`
* @deprecated Deprecated since version 3.0.
* @description
* The build config option `build.excludeMiddleware` has been replaced by the adapter configuration option [`edgeMiddleware`](/en/reference/adapter-reference/#edgemiddleware).
*
* 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.
*/
excludeMiddleware?: boolean;
};

/**
Expand Down Expand Up @@ -1183,28 +1155,6 @@ export interface AstroUserConfig {
* @name Markdown Options
*/
markdown?: {
/**
* @docs
* @name markdown.drafts
* @type {boolean}
* @default `false`
* @deprecated Deprecated since version 3.0. Use content collections instead.
* @description
* Control whether Markdown draft pages should be included in the build.
*
* 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.
*
* ```js
* {
* markdown: {
* // Example: Include all drafts in your final build
* drafts: true,
* }
* }
* ```
*/
drafts?: boolean;

/**
* @docs
* @name markdown.shikiConfig
Expand Down Expand Up @@ -1749,10 +1699,6 @@ export interface ComponentInstance {
css?: string[];
partial?: boolean;
prerender?: boolean;
/**
* Only used for logging if deprecated drafts feature is used
*/
frontmatter?: Record<string, any>;
getStaticPaths?: (options: GetStaticPathsOptions) => GetStaticPathsResult;
}

Expand Down Expand Up @@ -2056,7 +2002,7 @@ export interface AstroAdapter {
*
* If the adapter is not able to handle certain configurations, Astro will throw an error.
*/
supportedAstroFeatures?: AstroFeatureMap;
supportedAstroFeatures: AstroFeatureMap;
}

type Body = string;
Expand Down Expand Up @@ -2145,7 +2091,7 @@ export interface APIContext<
* ];
* }
*
* export async function get({ params }) {
* export async function GET({ params }) {
* return {
* body: `Hello user ${params.id}!`,
* }
Expand All @@ -2168,7 +2114,7 @@ export interface APIContext<
* ];
* }
*
* export function get({ props }) {
* export function GET({ props }) {
* return {
* body: `Hello ${props.name}!`,
* }
Expand All @@ -2184,7 +2130,7 @@ export interface APIContext<
* Example usage:
* ```ts
* // src/pages/secret.ts
* export function get({ redirect }) {
* export function GET({ redirect }) {
* return redirect('/login');
* }
* ```
Expand Down
1 change: 0 additions & 1 deletion packages/astro/src/cli/build/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@ export async function build({ flags }: BuildOptions) {
usage: '[...flags]',
tables: {
Flags: [
['--drafts', `Include Markdown draft pages in the build.`],
['--outDir <directory>', `Specify the output directory for the build.`],
['--help (-h)', 'See all available flags.'],
],
Expand Down
3 changes: 0 additions & 3 deletions packages/astro/src/cli/flags.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,9 +15,6 @@ export function flagsToAstroInlineConfig(flags: Flags): AstroInlineConfig {
site: typeof flags.site === 'string' ? flags.site : undefined,
base: typeof flags.base === 'string' ? flags.base : undefined,
outDir: typeof flags.outDir === 'string' ? flags.outDir : undefined,
markdown: {
drafts: typeof flags.drafts === 'boolean' ? flags.drafts : undefined,
},
server: {
port: typeof flags.port === 'number' ? flags.port : undefined,
host:
Expand Down
Loading
Loading