diff options
-rw-r--r-- | docs/src/pages/en/guides/rss.md | 2 | ||||
-rw-r--r-- | packages/astro/src/@types/astro.ts | 6 | ||||
-rw-r--r-- | packages/astro/src/core/build/page-data.ts | 4 | ||||
-rw-r--r-- | packages/astro/src/core/ssr/rss.ts | 6 | ||||
-rw-r--r-- | packages/astro/src/core/util.ts | 1 |
5 files changed, 10 insertions, 9 deletions
diff --git a/docs/src/pages/en/guides/rss.md b/docs/src/pages/en/guides/rss.md index b40fa98de..52c80ea2d 100644 --- a/docs/src/pages/en/guides/rss.md +++ b/docs/src/pages/en/guides/rss.md @@ -48,6 +48,6 @@ Note: RSS feeds will **not** be built during development. Currently, RSS feeds a RSS Feeds can be styled with an XSL stylesheet for a more pleasant user experience when they are opened directly in a browser. By default, Astro does not set a stylesheet for RSS feeds, but it can be enabled by setting the `stylesheet` option. -Astro can automatically use [Pretty Feed](https://github.com/genmon/aboutfeeds/blob/main/tools/pretty-feed-v3.xsl), a popular open-source XSL stylesheet. To enable this behavior, pass `stylesheet: true`. +Astro can automatically use [Pretty Feed](https://github.com/genmon/aboutfeeds/blob/main/tools/pretty-feed-v3.xsl), a popular open-source XSL stylesheet. To enable this behavior, pass `stylesheet: true`. If you'd like to use a custom XSL stylesheet, you can pass a string value like `stylesheet: '/my-custom-stylesheet.xsl'`. This file should be in your `public/` directory (in this case, `public/my-custom-stylesheet.xsl`). diff --git a/packages/astro/src/@types/astro.ts b/packages/astro/src/@types/astro.ts index 3df6bf41c..805317dfc 100644 --- a/packages/astro/src/@types/astro.ts +++ b/packages/astro/src/@types/astro.ts @@ -339,8 +339,8 @@ export interface RSS { description: string; /** Specify arbitrary metadata on opening <xml> tag */ xmlns?: Record<string, string>; - /** - * If false (default), does not include XSL stylesheet. + /** + * If false (default), does not include XSL stylesheet. * If true, automatically includes 'pretty-feed-v3'. * If a string value, specifies a local custom XSL stylesheet, for example '/custom-feed.xsl'. */ @@ -370,7 +370,7 @@ export interface RSS { export type RSSFunction = (args: RSS) => void; -export type FeedResult = { url: string; content?: string; }; +export type FeedResult = { url: string; content?: string }; export type RSSResult = { xml: FeedResult; xsl?: FeedResult }; export type SSRError = Error & vite.ErrorPayload['err']; diff --git a/packages/astro/src/core/build/page-data.ts b/packages/astro/src/core/build/page-data.ts index 45b7a6089..5b3605c24 100644 --- a/packages/astro/src/core/build/page-data.ts +++ b/packages/astro/src/core/build/page-data.ts @@ -92,7 +92,9 @@ export async function collectPagesData(opts: CollectPagesDataOptions): Promise<C const { url, content } = result.rss.xsl; const stylesheetFile = new URL(url.replace(/^\/?/, './'), astroConfig.dist); if (assets[fileURLToPath(stylesheetFile)]) { - throw new Error(`[getStaticPaths] RSS feed stylesheet ${url} already exists.\nUse \`rss(data, {stylesheet: '...'})\` to choose a unique, custom URL. (${route.component})`); + throw new Error( + `[getStaticPaths] RSS feed stylesheet ${url} already exists.\nUse \`rss(data, {stylesheet: '...'})\` to choose a unique, custom URL. (${route.component})` + ); } assets[fileURLToPath(stylesheetFile)] = content; } diff --git a/packages/astro/src/core/ssr/rss.ts b/packages/astro/src/core/ssr/rss.ts index 2febbc678..a61df7841 100644 --- a/packages/astro/src/core/ssr/rss.ts +++ b/packages/astro/src/core/ssr/rss.ts @@ -95,15 +95,15 @@ export function generateRssFunction(site: string | undefined, route: RouteData): result.xsl = { url: rssData.stylesheet, content: generateRSSStylesheet(), - } + }; } else if (typeof rssData.stylesheet === 'string') { result.xsl = { url: rssData.stylesheet, - } + }; } result.xml = { url: feedURL, - content: generateRSS({ rssData, site, srcFile: route.component, feedURL }) + content: generateRSS({ rssData, site, srcFile: route.component, feedURL }), }; }, rss: result, diff --git a/packages/astro/src/core/util.ts b/packages/astro/src/core/util.ts index b637ce221..10ee44c00 100644 --- a/packages/astro/src/core/util.ts +++ b/packages/astro/src/core/util.ts @@ -83,7 +83,6 @@ export function viteID(filePath: URL): string { return slash(fileURLToPath(filePath)); } - // Vendored from https://github.com/genmon/aboutfeeds/blob/main/tools/pretty-feed-v3.xsl /** Basic stylesheet for RSS feeds */ export const PRETTY_FEED_V3 = `<?xml version="1.0" encoding="utf-8"?> |