Skip to content

Commit 8b5f881

Browse files
authored
Merge pull request #622 from rishichawda/rss-feed
add rss feed
2 parents f61cbd4 + c41ebdf commit 8b5f881

File tree

9 files changed

+1614
-1417
lines changed

9 files changed

+1614
-1417
lines changed

gatsby-browser.ts

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,15 @@
1-
import 'normalize.css';
21
import "@fontsource/open-sans";
2+
import 'normalize.css';
33
import './src/stylesheets/global.scss';
4-
import './src/stylesheets/scales/space.scss';
5-
import './src/stylesheets/scales/type.scss';
4+
import ReactDOM from "react-dom/client"
65

76
// Reload the page when updates are found so that new changes are
87
// visible without manual page refresh.
98
export const onServiceWorkerUpdateReady = () => window.location.reload();
9+
10+
export const replaceHydrateFunction = () => {
11+
return (element, container) => {
12+
const root = ReactDOM.createRoot(container)
13+
root.render(element)
14+
}
15+
}

gatsby-config.ts

Lines changed: 57 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -199,6 +199,63 @@ const config: GatsbyConfig = {
199199
})),
200200
},
201201
},
202+
{
203+
resolve: "gatsby-plugin-feed",
204+
options: {
205+
query: `
206+
{
207+
site {
208+
siteMetadata {
209+
title
210+
description
211+
siteUrl
212+
site_url: siteUrl
213+
}
214+
}
215+
}
216+
`,
217+
feeds: [
218+
{
219+
serialize: ({ query: { site, allMdx } }) => {
220+
return allMdx.edges.map(edge => {
221+
222+
const siteUrl = site.siteMetadata.siteUrl
223+
const slug = siteUrl + edge.node.fields.slug
224+
225+
return Object.assign({}, edge.node.frontmatter, {
226+
url: slug,
227+
guid: slug,
228+
custom_elements: [
229+
{ "content:encoded": edge.node.excerpt }
230+
],
231+
})
232+
})
233+
},
234+
query: `
235+
{
236+
allMdx(sort: {frontmatter: {date: DESC}}) {
237+
edges {
238+
node {
239+
excerpt(pruneLength: 340)
240+
fields {
241+
slug
242+
}
243+
frontmatter {
244+
title
245+
description
246+
date
247+
}
248+
}
249+
}
250+
}
251+
}
252+
`,
253+
output: "/rss.xml",
254+
title: "Rishi's Blog - rishikc.com",
255+
},
256+
]
257+
}
258+
},
202259
"gatsby-plugin-image",
203260
"gatsby-plugin-sharp",
204261
"gatsby-transformer-sharp",

package.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,7 @@
3737
"gatsby-plugin-canonical-urls": "^5.10.0",
3838
"gatsby-plugin-dark-mode": "^1.1.2",
3939
"gatsby-plugin-disqus": "^1.2.6",
40+
"gatsby-plugin-feed": "^5.11.0",
4041
"gatsby-plugin-image": "^3.10.0",
4142
"gatsby-plugin-local-search": "^2.0.1",
4243
"gatsby-plugin-manifest": "^5.10.0",
@@ -80,4 +81,4 @@
8081
"tailwindcss": "^3.3.2",
8182
"typescript": "^5.0.4"
8283
}
83-
}
84+
}

src/components/gallery/card.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ type Props = {
88
};
99

1010
const Card = ({ data }: Props) => {
11-
const image = getImage(data.node.localFile);
11+
const image = getImage(data.node.localImage);
1212

1313
return (
1414
<div className="inline-flex w-full items-stretch cursor-pointer aspect-square instagram-gallery-image-wrapper">

src/hooks/use-insta-nodes.tsx

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -17,10 +17,16 @@ const useInstagramNodes = () => {
1717
edges {
1818
node {
1919
id
20-
caption
21-
localFile {
20+
localImage {
21+
id
2222
childImageSharp {
23-
gatsbyImageData(placeholder: BLURRED, width: 250)
23+
gatsbyImageData(
24+
aspectRatio: 1
25+
transformOptions: { cropFocus: CENTER }
26+
width: 200
27+
formats: [WEBP]
28+
placeholder: DOMINANT_COLOR
29+
)
2430
}
2531
}
2632
}

src/pages/404.tsx

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,8 @@ const NotFoundPage: React.FC<PageProps> = () => (
1515
imgStyle={{ objectFit: "contain" }}
1616
src="../../static/assets/404.png"
1717
alt="404image"
18+
formats={["webp"]}
19+
placeholder="tracedSVG"
1820
/>
1921
<main className="dark:text-gray-200 grid place-items-center px-6 lg:px-8">
2022
<div className="text-center">

src/pages/index.tsx

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,8 @@ const IndexPage: React.FC<PageProps> = () => {
4343
<StaticImage
4444
src="../../static/assets/handsome-guy.webp"
4545
alt="handsome"
46+
formats={["webp"]}
47+
placeholder="tracedSVG"
4648
/>
4749
</div>
4850
</div>

src/stylesheets/global.scss

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,10 +2,8 @@
22
@tailwind components;
33
@tailwind utilities;
44
@import "colors.scss";
5-
6-
:root {
7-
--fontsource-display: swap;
8-
}
5+
@import "./scales/space.scss";
6+
@import "./scales/type.scss";
97

108
body {
119
font-family: "Open Sans", sans-serif;

0 commit comments

Comments
 (0)