-
Notifications
You must be signed in to change notification settings - Fork 1
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 #62 from nblackburn/feature/project-feed
Project feed
- Loading branch information
Showing
6 changed files
with
73 additions
and
10 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
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,8 @@ | ||
export type Project = { | ||
url: string; | ||
slug: string; | ||
title: string; | ||
tags: string[]; | ||
description: string; | ||
publishedDate: string; | ||
}; |
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,31 @@ | ||
import rss from '@astrojs/rss'; | ||
import config from '@app/config'; | ||
import { parseISO } from 'date-fns'; | ||
import { Project } from '@config/project'; | ||
import type { MarkdownInstance } from 'astro'; | ||
|
||
const importedProjects = import.meta.glob<MarkdownInstance<Project>>('./*.md', { | ||
eager: true | ||
}); | ||
|
||
export const get = () => { | ||
const projectsURL = `${config.url}/projects`; | ||
const projects = Object.values(importedProjects); | ||
|
||
return rss({ | ||
title: 'Projects', | ||
site: projectsURL, | ||
description: 'Some of the things i have worked on', | ||
items: projects.map((project) => { | ||
const frontmatter = project.frontmatter; | ||
const publishedDate = parseISO(frontmatter.publishedDate); | ||
|
||
return { | ||
link: frontmatter.url, | ||
pubDate: publishedDate, | ||
title: frontmatter.title, | ||
description: frontmatter.description | ||
}; | ||
}) | ||
}); | ||
}; |
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