-
-
Notifications
You must be signed in to change notification settings - Fork 205
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #57 from styxlab/fix-rss
Fix rss
- Loading branch information
Showing
4 changed files
with
408 additions
and
503 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
import { GetServerSideProps } from 'next' | ||
|
||
import { getAllPosts, getAllSettings, GhostPostsOrPages } from '@lib/ghost' | ||
import { generateRSSFeed } from '@utils/rss' | ||
|
||
const RSS = () => null | ||
|
||
export const getServerSideProps: GetServerSideProps = async ({ res }) => { | ||
let settings | ||
let posts: GhostPostsOrPages | [] | ||
|
||
try { | ||
settings = await getAllSettings() | ||
posts = await getAllPosts() | ||
} catch (error) { | ||
throw new Error('Index creation failed.') | ||
} | ||
|
||
let rssData = null | ||
if (settings.processEnv.rssFeed) { | ||
rssData = generateRSSFeed({ posts, settings }) | ||
} | ||
|
||
if (res && rssData) { | ||
res.setHeader('Content-Type', 'text/xml') | ||
res.write(rssData) | ||
res.end() | ||
} | ||
|
||
return { | ||
props: {}, | ||
} | ||
} | ||
|
||
export default RSS |
Oops, something went wrong.
3d310fa
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Successfully deployed to the following URLs: