Skip to content

Commit

Permalink
Merge pull request #62 from nblackburn/feature/project-feed
Browse files Browse the repository at this point in the history
Project feed
  • Loading branch information
nblackburn committed Nov 15, 2022
2 parents 193bc73 + e5b5556 commit 5a03ea2
Show file tree
Hide file tree
Showing 6 changed files with 73 additions and 10 deletions.
3 changes: 2 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "@nblackburn/website",
"private": true,
"version": "1.10.0",
"version": "1.11.0",
"scripts": {
"start": "astro dev",
"build": "astro build",
Expand All @@ -19,6 +19,7 @@
},
"dependencies": {
"@astrojs/image": "^0.11.4",
"@astrojs/rss": "^1.0.3",
"@astrojs/sitemap": "^1.0.0",
"@astrojs/vue": "^1.2.1",
"@fontsource/nunito-sans": "^4.5.10",
Expand Down
10 changes: 1 addition & 9 deletions src/components/projectCard.vue
Original file line number Diff line number Diff line change
Expand Up @@ -32,19 +32,11 @@

<script lang="ts">
import Link from '@components/link.vue';
import { Project } from '@config/project';
import * as styles from './projectCard.css';
import { format, parseISO } from 'date-fns';
import { defineComponent, PropType } from 'vue';
export type Project = {
url: string;
slug: string;
title: string;
tags: string[];
description: string;
publishedDate: string;
};
export default defineComponent({
components: {
Link
Expand Down
3 changes: 3 additions & 0 deletions src/config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,12 +13,15 @@ type PaginationConfig = {
};

interface Config {
url: string;
seo: SEOConfig;
palette: PaletteConfig;
pagination: PaginationConfig;
}

const config: Config = {
url: 'https://nblackburn.uk',

seo: {
ref: 'nblackburn.uk'
},
Expand Down
8 changes: 8 additions & 0 deletions src/config/project.ts
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;
};
31 changes: 31 additions & 0 deletions src/pages/projects/rss.xml.ts
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
};
})
});
};
28 changes: 28 additions & 0 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -130,6 +130,15 @@ __metadata:
languageName: node
linkType: hard

"@astrojs/rss@npm:^1.0.3":
version: 1.0.3
resolution: "@astrojs/rss@npm:1.0.3"
dependencies:
fast-xml-parser: ^4.0.8
checksum: ca1ffd98def1ef74d63fc383b999a29a9b00caa22d3be007e0bf707e917d77151458073e3f59c472a1809471a86c63c3eda62a001a02e703b8ed46379a66f735
languageName: node
linkType: hard

"@astrojs/sitemap@npm:^1.0.0":
version: 1.0.0
resolution: "@astrojs/sitemap@npm:1.0.0"
Expand Down Expand Up @@ -880,6 +889,7 @@ __metadata:
resolution: "@nblackburn/website@workspace:."
dependencies:
"@astrojs/image": ^0.11.4
"@astrojs/rss": ^1.0.3
"@astrojs/sitemap": ^1.0.0
"@astrojs/vue": ^1.2.1
"@commitlint/cli": ^17.2.0
Expand Down Expand Up @@ -3325,6 +3335,17 @@ __metadata:
languageName: node
linkType: hard

"fast-xml-parser@npm:^4.0.8":
version: 4.0.11
resolution: "fast-xml-parser@npm:4.0.11"
dependencies:
strnum: ^1.0.5
bin:
fxparser: src/cli/cli.js
checksum: d8a08e4d5597e0fc00a86735195872eeb03008913e298830941516f3766e16ee555e2d431acc92e1dda887938edc445252ec5b59494aab60a8389888bd13719c
languageName: node
linkType: hard

"fastq@npm:^1.6.0":
version: 1.13.0
resolution: "fastq@npm:1.13.0"
Expand Down Expand Up @@ -6895,6 +6916,13 @@ __metadata:
languageName: node
linkType: hard

"strnum@npm:^1.0.5":
version: 1.0.5
resolution: "strnum@npm:1.0.5"
checksum: 651b2031db5da1bf4a77fdd2f116a8ac8055157c5420f5569f64879133825915ad461513e7202a16d7fec63c54fd822410d0962f8ca12385c4334891b9ae6dd2
languageName: node
linkType: hard

"style-to-object@npm:^0.3.0":
version: 0.3.0
resolution: "style-to-object@npm:0.3.0"
Expand Down

0 comments on commit 5a03ea2

Please sign in to comment.