Skip to content

Instantly share code, notes, and snippets.

Avatar

Fredrik Bergqvist fredrikbergqvist

View GitHub Profile
@fredrikbergqvist
fredrikbergqvist / Rss.ts
Created Nov 29, 2019
How to create an RSS feed for next.js
View Rss.ts
import React from "react";
import { NextPageContext } from "next";
const blogPostsRssXml = (blogPosts: IBlogPost[]) => {
let latestPostDate: string = "";
let rssItemsXml = "";
blogPosts.forEach(post => {
const postDate = Date.parse(post.createdAt);
if (!latestPostDate || postDate > Date.parse(latestPostDate)) {
latestPostDate = post.createdAt;
@fredrikbergqvist
fredrikbergqvist / sitemap.xml.ts
Last active Jun 9, 2020
A sitemap example for next.js
View sitemap.xml.ts
import { NextPageContext } from "next";
const blogPostsXml = (blogPosts: IBlogPostListItem[]) => {
let latestPost = 0;
let postsXml = "";
blogPosts.map(post => {
const postDate = Date.parse(post.createdAt);
if (!latestPost || postDate > latestPost) {
latestPost = postDate;
}
@fredrikbergqvist
fredrikbergqvist / types1.tsx
Last active Nov 11, 2019
Examples of TypeScript with React, Redux and Material UI
View types1.tsx
import * as React from "react";
interface OwnProps {
myProp:string;
}
const MyButton: React.FC<OwnProps> = (props) => {
return (<button />);
}
You can’t perform that action at this time.