Skip to content
Open
Show file tree
Hide file tree
Changes from all 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
7 changes: 6 additions & 1 deletion astro.config.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,8 @@ import {
} from './src/remark/directives';
import remarkOnlyStrong from './src/remark/only-strong';
import svgr from 'vite-plugin-svgr';
import sitemap from '@astrojs/sitemap';


// https://astro.build/config
export default defineConfig({
Expand All @@ -37,6 +39,9 @@ export default defineConfig({
mdx(),
react(),
dotHtmlRedirects(),
sitemap({
filter: (page) => page !== 'https://unitary.foundation/author/image/',
}),
],
markdown: {
remarkPlugins: [
Expand All @@ -63,4 +68,4 @@ export default defineConfig({
}),
],
},
});
});
1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
"@astrojs/mdx": "^4.3.0",
"@astrojs/react": "4.3.0",
"@astrojs/rss": "^4.0.12",
"@astrojs/sitemap": "^3.4.1",
"@astrojs/tailwind": "6.0.2",
"@cloudinary/url-gen": "^1.21.0",
"@emotion/css": "^11.13.5",
Expand Down
46 changes: 46 additions & 0 deletions pnpm-lock.yaml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

13 changes: 11 additions & 2 deletions src/layouts/Layout.astro
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ if (title) {

<!-- Twitter -->
<meta name="twitter:card" content="summary_large_image" />
<meta name="twitter:site" content="@unitaryfdn">
<meta name="twitter:site" content="@unitaryfdn" />
<meta property="twitter:url" content={Astro.url} />
<meta property="twitter:title" content={metaTitle ? metaTitle : title ? title : titleName} />
<meta property="twitter:description" content={metaDescription ? metaDescription : titleName} />
Expand All @@ -81,9 +81,15 @@ if (title) {
<link
rel="alternate"
type="application/rss+xml"
title={titleName}
title="Unitary Foundation RSS Feed (Blog)"
href={`${Astro.url.origin}/posts/feed.xml`}
/>
<link
rel="alternate"
type="application/rss+xml"
title="Unitary Foundation RSS Feed (Grants)"
href={`${Astro.url.origin}/grants/feed.xml`}
/>

<!-- Scripts -->
<script
Expand All @@ -97,6 +103,9 @@ if (title) {
integrity="sha384-+VBxd3r6XgURycqtZ117nYw44OOcIax56Z4dCRWbxyPt0Koah1uHoK0o4+/RRE05"
crossorigin="anonymous"
onload="renderMathInElement(document.body);"></script>

<!-- Sitemap -->
<link rel="sitemap" href="./sitemap-index.xml" />
</head>
<body
class:list={[
Expand Down
43 changes: 43 additions & 0 deletions src/pages/grants/feed.xml.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
import rss from "@astrojs/rss";
import { type CollectionEntry, getCollection } from "astro:content";
import sanitizeHtml from "sanitize-html";
import MarkdownIt from "markdown-it";

interface SiteContext {
site: string;
}

const parser = new MarkdownIt();

function getDateFromPost(grant: CollectionEntry<"grant">): Date {
return new Date(`${grant.data.year || 2018}-${grant.data.month || 1}-${grant.data.day || 1}`)
}

export async function GET(context: SiteContext) {
// HTML tags allowed in content
const allowedTags = ["img", "p", "h1", "h2", "h3", "a", "ul", "ol", "li", "blockquote", "code", "pre", "strong"]

// Get grants, order, and slice them
let grants = await getCollection("grant");
grants = grants.sort((a, b) => {
return getDateFromPost(b).getTime() - getDateFromPost(a).getTime();
}).slice(0, 20);

// Return RSS feed
return rss({
title: "Unitary Foundation Grants",
description: "Unitary Foundation is a non-profit working to create a quantum technology ecosystem that benefits the most people.",
site: context.site,
items: grants
.map((grant) => ({
title: grant.data.name,
link: `/grants/${grant.slug}/`,
pubDate: getDateFromPost(grant),
categories: grant.data.tags || [],
content: sanitizeHtml(parser.render(grant.body), {
allowedTags: sanitizeHtml.defaults.allowedTags.concat(allowedTags)
}),
})),
customData: `<language>en-us</language>`,
});
}
34 changes: 0 additions & 34 deletions src/pages/test.mdx

This file was deleted.