Skip to content

Commit

Permalink
RSS feed
Browse files Browse the repository at this point in the history
  • Loading branch information
UnsignedArduino committed Mar 16, 2024
1 parent 9abd337 commit 1df6a9d
Show file tree
Hide file tree
Showing 30 changed files with 182 additions and 76 deletions.
3 changes: 2 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@ next-env.d.ts
/public/oldExtensions.json
/public/extensions.json
/public/tools.json
/public/rss.xml

node_modules
.env
.env
4 changes: 4 additions & 0 deletions .prettierignore
Original file line number Diff line number Diff line change
Expand Up @@ -39,3 +39,7 @@ next-env.d.ts
/public/oldExtensions.json
/public/extensions.json
/public/tools.json
/public/rss.xml

node_modules
.env
2 changes: 1 addition & 1 deletion content/posts/Awesome-Arcades-First-Blog.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
---
title: Awesome Arcade's First Blog!
author: content/authors/UnsignedArduino.md
description: "*The last time I started a blog, I forgot about it after two posts. Hopefully, that doesn't happen this time! \U0001F92A*\n"
description: "The last time I started a blog, I forgot about it after two posts. Hopefully, that doesn't happen this time! \U0001F92A"
tags:
- Experiences
- Tips and tricks
Expand Down
1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,7 @@
"bootstrap-icons": "^1.11.3",
"dompurify": "^3.0.8",
"fast-xml-parser": "^4.3.4",
"feed": "^4.2.2",
"isomorphic-dompurify": "^2.3.0",
"midifile-ts": "^1.5.1",
"next": "14.1.0",
Expand Down
2 changes: 1 addition & 1 deletion src/components/AwesomeArcadeList/extension.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { Extension, ExtensionRef, URLLink } from "@/scripts/Utils/ParseListXML";
import { Extension, ExtensionRef, URLLink } from "../../scripts/ParseListXML";
import React from "react";
import "tippy.js/dist/tippy.css";
import { copyTextToClipboard } from "@/scripts/Utils/Clipboard";
Expand Down
2 changes: 1 addition & 1 deletion src/components/AwesomeArcadeList/list.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import getElement from "@/scripts/Utils/Element";
import { forceOutboundLinksToNewPage } from "@/scripts/Utils/PageUtils";
import { AwesomeArcadeExtensionGroup } from "@/components/AwesomeArcadeList/extension";
import { AwesomeArcadeToolGroup } from "@/components/AwesomeArcadeList/tool";
import { Extension, Tool } from "@/scripts/Utils/ParseListXML";
import { Extension, Tool } from "../../scripts/ParseListXML";

export function AwesomeArcadeExtensionsList({
list,
Expand Down
2 changes: 1 addition & 1 deletion src/components/AwesomeArcadeList/tool.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { Tool, ToolRef, URLLink } from "@/scripts/Utils/ParseListXML";
import { Tool, ToolRef, URLLink } from "../../scripts/ParseListXML";
import React from "react";
import Link from "next/link";
import { smoothScrollHash } from "@/components/Linkable/Header";
Expand Down
2 changes: 1 addition & 1 deletion src/components/Blog/Post/Post.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ export default function BlogPost({
) : null}
</p>
<small>
<RichTextSectionRenderer content={data.post.description} />
<p>{data.post.description}</p>
</small>
<RichTextSectionRenderer content={data.post.body} />
<small>
Expand Down
9 changes: 2 additions & 7 deletions src/components/Blog/Post/Preview.tsx
Original file line number Diff line number Diff line change
@@ -1,9 +1,6 @@
import { Authors } from "../../../../tina/__generated__/types";
import React from "react";
import {
RichTextSectionRenderer,
ShortAuthorRenderer,
} from "@/components/Blog/Elements";
import { ShortAuthorRenderer } from "@/components/Blog/Elements";
import { formatDateAndTime } from "@/scripts/Utils/DateAndTime/Format";
import Link from "next/link";

Expand Down Expand Up @@ -35,9 +32,7 @@ export default function BlogPostPreviewRenderer({
<ShortAuthorRenderer author={preview.author} />
)}
</h6>
<div className="card-text">
<RichTextSectionRenderer content={preview.description} />
</div>
<p className="card-text">{preview.description}</p>
<Link href={preview.link} className="card-link">
View post
</Link>
Expand Down
6 changes: 3 additions & 3 deletions src/components/OldAwesomeArcadeExtensionList/extension.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import {
Extension,
ExtensionRef,
URLLink,
} from "@/scripts/Utils/ParseOldExtensionsXML";
} from "../../scripts/ParseOldExtensionsXML";
import React from "react";
import "tippy.js/dist/tippy.css";
import { copyTextToClipboard } from "@/scripts/Utils/Clipboard";
Expand Down Expand Up @@ -109,14 +109,14 @@ export function AwesomeArcadeExtension({
setTooltip("Copied!");
} else {
setTooltip(
"Failed to copy - did you give us clipboard permission?"
"Failed to copy - did you give us clipboard permission?",
);
}
tipRef.current.setContent(tooltip);
window.document.documentElement.dispatchEvent(
new CustomEvent<string>("clickrepo", {
detail: ext.repo,
})
}),
);
AnalyticEvents.sendAwesomeClick(ext.repo);
}}
Expand Down
2 changes: 1 addition & 1 deletion src/components/OldAwesomeArcadeExtensionList/list.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { ExtensionList } from "@/scripts/Utils/ParseOldExtensionsXML";
import { ExtensionList } from "../../scripts/ParseOldExtensionsXML";
import React from "react";
import getElement from "@/scripts/Utils/Element";
import { forceOutboundLinksToNewPage } from "@/scripts/Utils/PageUtils";
Expand Down
4 changes: 2 additions & 2 deletions src/components/OldAwesomeArcadeExtensionList/tool.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { Tool, ToolRef, URLLink } from "@/scripts/Utils/ParseOldExtensionsXML";
import { Tool, ToolRef, URLLink } from "../../scripts/ParseOldExtensionsXML";
import React from "react";
import Link from "next/link";
import { smoothScrollHash } from "@/components/OldAwesomeArcadeExtensionList/linkableHeader";
Expand Down Expand Up @@ -57,7 +57,7 @@ export function AwesomeArcadeTool({
window.document.documentElement.dispatchEvent(
new CustomEvent<string>("clicktool", {
detail: tool.repo,
})
}),
);
AnalyticEvents.sendAwesomeClick(tool.repo);
};
Expand Down
16 changes: 15 additions & 1 deletion src/components/WithAppProps/appProps.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { parseExtensionXML, parseToolXML } from "@/scripts/Utils/ParseListXML";
import { parseExtensionXML, parseToolXML } from "../../scripts/ParseListXML";
import { promises as fs } from "fs";
import path from "path";

Expand All @@ -12,6 +12,20 @@ export function getEnvironment(): Environment {
: "production";
}

export function getBaseURL(): string {
switch (getEnvironment()) {
case "production": {
return "https://awesome-arcade.vercel.app";
}
case "preview": {
return "https://awesome-arcade-beta.vercel.app";
}
case "development": {
return "http://localhost:3000";
}
}
}

export function getBranch(): "main" | "staging" {
return getEnvironment() === "production" ? "main" : "staging";
}
Expand Down
33 changes: 32 additions & 1 deletion src/pages/blog/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,8 @@ import BlogPostPreviewRenderer, {
BlogPostPreview,
} from "@/components/Blog/Post/Preview";
import Link from "next/link";
import { promises as fs } from "fs";
import generateRSSFeed from "@/scripts/RSS";

type BlogProps = {
blogPostPreviews: BlogPostPreview[];
Expand All @@ -31,7 +33,31 @@ export default function BlogPage(props: BlogProps) {
MakeCode Arcade.
</p>
<p>
Find all blog posts <Link href="/blog/all">here</Link>.
I hope you find these posts useful and interesting. If you have any
questions, suggestions, or feedback, feel free to reach out to me on{" "}
<a
href="https://github.com/UnsignedArduino/Awesome-Arcade-Extensions-Website/discussions"
target="_blank"
rel="noopener noreferrer"
>
GitHub Discussions
</a>{" "}
or the{" "}
<a
href="https://forum.makecode.com/"
target="_blank"
rel="noopener noreferrer"
>
MakeCode forums
</a>
.
</p>
<p>
You can also subscribe to this blog with a{" "}
<a href="/rss.xml" target="_blank" rel="noopener noreferrer">
RSS feed reader
</a>
!
</p>
<h2>Latest blog posts</h2>
{
Expand All @@ -43,6 +69,9 @@ export default function BlogPage(props: BlogProps) {
})}
</>
}
<p>
View all <Link href="/blog/all">here</Link>.
</p>
</Layout>
);
}
Expand Down Expand Up @@ -78,6 +107,8 @@ export async function getStaticProps(): Promise<{
return new Date(b.postedDate).getTime() - new Date(a.postedDate).getTime();
});

await fs.writeFile("./public/rss.xml", await generateRSSFeed(previews));

previews.splice(5);

return {
Expand Down
4 changes: 2 additions & 2 deletions src/pages/extensions.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -9,10 +9,10 @@ import { AwesomeArcadeExtensionsList } from "@/components/AwesomeArcadeList";
import { debounce } from "@/scripts/Utils/Timers";
import { AnalyticEvents } from "@/components/Analytics";
import { useSession } from "next-auth/react";
import { Extension, parseExtensionXML } from "@/scripts/Utils/ParseListXML";
import { Extension, parseExtensionXML } from "../scripts/ParseListXML";
import { useFeatureIsOn } from "@growthbook/growthbook-react";
import Tippy from "@tippyjs/react";
import { stringToBool } from "@/scripts/Utils/ParseListXML/helpers";
import { stringToBool } from "@/scripts/ParseListXML/helpers";

const pageName = "Extensions";

Expand Down
9 changes: 8 additions & 1 deletion src/pages/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import React from "react";
import { promises as fs } from "fs";
import Layout from "../components/Layout";
import getAppProps, { AppProps } from "../components/WithAppProps";
import generateSiteWebmanifest from "../scripts/Utils/SiteWebmanifest/manifest";
import generateSiteWebmanifest from "@/scripts/SiteWebmanifest/manifest";
import Link from "next/link";
import { useSession } from "next-auth/react";
import { useFeatureIsOn } from "@growthbook/growthbook-react";
Expand Down Expand Up @@ -31,6 +31,13 @@ export function Home({ appProps }: HomeProps): JSX.Element {
link: "/tools",
linkText: "View awesome tools",
},
{
name: "Blog",
description:
"Read about the latest news and updates in the MakeCode Arcade world!",
link: "/blog",
linkText: "Read the blog",
},
];

return (
Expand Down
4 changes: 1 addition & 3 deletions src/pages/old.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,7 @@ import React from "react";
import Layout from "../components/Layout";
import getAppProps, { AppProps } from "@/components/WithAppProps";
import AwesomeArcadeExtensionList from "@/components/OldAwesomeArcadeExtensionList/list";
import parseListXML, {
ExtensionList,
} from "../scripts/Utils/ParseOldExtensionsXML";
import parseListXML, { ExtensionList } from "../scripts/ParseOldExtensionsXML";
import { smoothScrollToID } from "@/components/OldAwesomeArcadeExtensionList/linkableHeader";
import { debounce } from "@/scripts/Utils/Timers";
import { AnalyticEvents } from "@/components/Analytics";
Expand Down
4 changes: 2 additions & 2 deletions src/pages/tools.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,9 @@ import { debounce } from "@/scripts/Utils/Timers";
import { AnalyticEvents } from "@/components/Analytics";
import Tippy from "@tippyjs/react";
import { useSession } from "next-auth/react";
import { parseToolXML, Tool } from "@/scripts/Utils/ParseListXML";
import { parseToolXML, Tool } from "../scripts/ParseListXML";
import { useFeatureIsOn } from "@growthbook/growthbook-react";
import { stringToBool } from "@/scripts/Utils/ParseListXML/helpers";
import { stringToBool } from "@/scripts/ParseListXML/helpers";

const pageName = "Tools";

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ export function findElementInElement(element: any, elementName: string): any {
export function findElementWithAttributeValue(
elements: any[],
attributeName: string,
attributeValue: string
attributeValue: string,
): any {
for (const element of elements) {
const attributes = element[":@"];
Expand Down
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -6,12 +6,12 @@ import {
Tool,
ToolRef,
URLLink,
} from "@/scripts/Utils/ParseListXML/types";
} from "@/scripts/ParseListXML/types";
import {
findElementInElement,
findElementWithAttributeValue,
stringToBool,
} from "@/scripts/Utils/ParseListXML/helpers";
} from "@/scripts/ParseListXML/helpers";

export function gatherExtensionRefList(exts: any[]): ExtensionRef[] {
const newExtsRef = [];
Expand Down
File renamed without changes.
File renamed without changes.
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
import { XMLParser } from "fast-xml-parser";
import { Extension, Tool } from "@/scripts/Utils/ParseListXML";
import { Extension, Tool } from "@/scripts/ParseListXML";
import {
gatherExtensionList,
gatherToolList,
} from "@/scripts/Utils/ParseListXML/parse";
import { findElementWithAttributeValue } from "@/scripts/Utils/ParseListXML/helpers";
} from "@/scripts/ParseListXML/parse";
import { findElementWithAttributeValue } from "@/scripts/ParseListXML/helpers";

export type ExtensionList = {
builtIn: Extension[];
Expand All @@ -13,7 +13,7 @@ export type ExtensionList = {
};

export default async function parseListXML(
xml: string
xml: string,
): Promise<ExtensionList> {
const parser = new XMLParser({
preserveOrder: true,
Expand All @@ -26,17 +26,17 @@ export default async function parseListXML(
const builtIn = findElementWithAttributeValue(
allExtensions,
"label",
"Built in"
"Built in",
).extensionList;
const notBuiltIn = findElementWithAttributeValue(
allExtensions,
"label",
"Not built in"
"Not built in",
).extensionList;
const tools = findElementWithAttributeValue(
allExtensions,
"label",
"Tools"
"Tools",
).toolList;

return {
Expand Down
Loading

0 comments on commit 1df6a9d

Please sign in to comment.