Skip to content

Commit

Permalink
Fix RSS feed generator (#1935)
Browse files Browse the repository at this point in the history
* Fix RSS feed generator

* fix links in siteconfig

* add rss feed to head

* fix more tinacms.org's
  • Loading branch information
bradystroud authored Jul 23, 2024
1 parent 596a4e5 commit b2957fe
Show file tree
Hide file tree
Showing 9 changed files with 78 additions and 72 deletions.
24 changes: 12 additions & 12 deletions .github/pull_request_template.md
Original file line number Diff line number Diff line change
@@ -1,19 +1,19 @@
### General Contributing:

* [ ] Have you followed the guidelines in our [Contributing document](https://github.com/tinacms/tinacms.org/blob/master/CONTRIBUTING.md)?
* [ ] Have you checked to ensure there aren't other open [Pull Requests](../../../pulls) for the same update/change?
- [ ] Have you followed the guidelines in our [Contributing document](https://github.com/tinacms/tina.io/blob/master/CONTRIBUTING.md)?
- [ ] Have you checked to ensure there aren't other open [Pull Requests](../../../pulls) for the same update/change?

<!-- For non content related updates, or fixing things like typos, you can erase the following section -->

### All New Content Submissions: (To be confirmed by reviewer)

* [ ] Title is short & specific
* [ ] Headers are logically ordered & consistent
* [ ] Purpose of document is explained in the first paragraph
* [ ] Procedures are tested and work
* [ ] Any technical concepts are explained or linked to
* [ ] Document follows structure from templates
* [ ] All links work
* [ ] The spelling and grammar checker has been run
* [ ] Graphics and images are clear and useful
* [ ] Any prerequisites and next steps are defined.
- [ ] Title is short & specific
- [ ] Headers are logically ordered & consistent
- [ ] Purpose of document is explained in the first paragraph
- [ ] Procedures are tested and work
- [ ] Any technical concepts are explained or linked to
- [ ] Document follows structure from templates
- [ ] All links work
- [ ] The spelling and grammar checker has been run
- [ ] Graphics and images are clear and useful
- [ ] Any prerequisites and next steps are defined.
2 changes: 1 addition & 1 deletion components/layout/DocsLayout.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ export const DocsLayout = React.memo(
<>
<DefaultSeo
openGraph={{
url: 'https://tinacms.org' + router.asPath,
url: 'https://tina.io' + router.asPath,
}}
/>
<DocsLayoutGrid>
Expand Down
2 changes: 1 addition & 1 deletion components/search/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -146,7 +146,7 @@ const AllIndicesResults = connectStateResults(
{!hasResults && (
<NoResultsLabel>
No results found for '{state.query}'. Check the &nbsp;
<a href="https://community.tinacms.org" target="_blank">
<a href="https://tina.io/community" target="_blank">
Forum
</a>
&nbsp; or &nbsp;
Expand Down
4 changes: 2 additions & 2 deletions content/pages/community.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
"alt": "Join the club"
},
"supporting_headline": "Open-source, extensible and community driven",
"supporting_body": "Tina is made better by the wisdom of crowds. If you find a bug or have ideas about a feature, please open an issue on [GitHub](https://github.com/tinacms/tinacms/issues). If you have a question about how to use Tina or want to engage in broader discussions, add to our [GitHub Discussion](https://github.com/tinacms/tinacms/discussions) or chat with us on [Discord](https://discord.com/invite/zumN63Ybpf).\n\nCheck out our [contribution guidelines](https://tinacms.org/docs/contributing/guidelines) for more info on how to get involved with development. If you are excited about TinaCMS, help us grow the community by ⭐️' ing the [repo on GitHub](https://github.com/tinacms/tinacms).",
"supporting_body": "Tina is made better by the wisdom of crowds. If you find a bug or have ideas about a feature, please open an issue on [GitHub](https://github.com/tinacms/tinacms/issues). If you have a question about how to use Tina or want to engage in broader discussions, add to our [GitHub Discussion](https://github.com/tinacms/tinacms/discussions) or chat with us on [Discord](https://discord.com/invite/zumN63Ybpf).\n\nCheck out our [contribution guidelines](https://tina.io/docs/contributing/guidelines) for more info on how to get involved with development. If you are excited about TinaCMS, help us grow the community by ⭐️' ing the [repo on GitHub](https://github.com/tinacms/tinacms).",
"default": {
"title": "",
"headline": "Open-source, extensible and community driven",
Expand All @@ -34,4 +34,4 @@
"src": "/img/rico-replacement.jpg",
"alt": "Join the club"
}
}
}
8 changes: 4 additions & 4 deletions content/siteConfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,11 @@
"title": "Tina",
"sidebarTitle": "Tina",
"seoDefaultTitle": "The Markdown CMS",
"description": "An open-source CMS backed by Git",
"siteUrl": "https://tinacms.org",
"roadmapUrl": "https://github.com/tinacms/tinacms/blob/master/ROADMAP.md",
"description": "TinaCMS is a fully open-source headless CMS that supports Git",
"siteUrl": "https://tina.io",
"roadmapUrl": "https://tina.io/roadmap/",
"licenseUrl": "https://github.com/tinacms/tinacms/blob/master/LICENSE",
"keywords": "nextjs, react, cms, next",
"keywords": "nextjs, react, cms, next, tina, markdown, git, open-source, headless",
"social": {
"twitterHandle": "@tinacms",
"twitter": "https://twitter.com/tinacms",
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"name": "tinacms.org",
"name": "tina.io",
"version": "1.0.0",
"description": "A hub for Tina's documentation, blog & general info.",
"author": "Forestry.io",
Expand Down
71 changes: 38 additions & 33 deletions pages/_app.tsx
Original file line number Diff line number Diff line change
@@ -1,28 +1,27 @@
import React, { useEffect } from 'react';
import App from 'next/app';
import Head from 'next/head';
import { DefaultSeo } from 'next-seo';
import data from '../content/siteConfig.json';
import { GlobalStyle } from 'components/styles/GlobalStyle';
import 'components/styles/fontImports.css';
import path from 'path';
import '../styles/tailwind.css';
import { useEditState } from 'tinacms/dist/react';
import { CloudBanner } from '../components/layout/CloudBanner';
import dynamic from 'next/dynamic';
import ChatBaseBot from '../components/ui/TinaChatBot';
import ConsentBanner from '../components/ui/ConsentBanner';
import Cookies from 'js-cookie';
import React, { useEffect } from 'react'
import App from 'next/app'
import Head from 'next/head'
import { DefaultSeo } from 'next-seo'
import data from '../content/siteConfig.json'
import { GlobalStyle } from 'components/styles/GlobalStyle'
import 'components/styles/fontImports.css'
import path from 'path'
import '../styles/tailwind.css'
import { useEditState } from 'tinacms/dist/react'
import { CloudBanner } from '../components/layout/CloudBanner'
import ChatBaseBot from '../components/ui/TinaChatBot'
import ConsentBanner from '../components/ui/ConsentBanner'
import Cookies from 'js-cookie'

path.resolve('./content/');
path.resolve('./content/')

const MainLayout = ({ Component, pageProps }) => {
useEffect(() => {
const consentGiven = Cookies.get('consentGiven');
const consentGiven = Cookies.get('consentGiven')
if (consentGiven) {
const consentState = JSON.parse(consentGiven);
const consentState = JSON.parse(consentGiven)
}
}, []);
}, [])

return (
<>
Expand All @@ -37,7 +36,7 @@ const MainLayout = ({ Component, pageProps }) => {
site_name: data.title,
images: [
{
url: 'https://tinacms.org/img/tina-og.png',
url: 'https://tina.io/img/tina-og.png',
width: 1200,
height: 628,
alt: `Tina - The Markdown CMS`,
Expand All @@ -53,6 +52,12 @@ const MainLayout = ({ Component, pageProps }) => {
<Head>
<link rel="shortcut icon" href="/favicon/favicon.ico" />
<meta name="theme-color" content="#E6FAF8" />
<link
rel="alternate"
type="application/rss+xml"
title="RSS Feed"
href={data.siteUrl + '/rss.xml'}
/>
</Head>
<GlobalStyle />
<ConsentBanner />
Expand All @@ -61,24 +66,24 @@ const MainLayout = ({ Component, pageProps }) => {
<Component {...pageProps} />
<ChatBaseBot />
</>
);
};
)
}

const AdminLink = () => {
const { edit } = useEditState();
const [showAdminLink, setShowAdminLink] = React.useState(false);
const { edit } = useEditState()
const [showAdminLink, setShowAdminLink] = React.useState(false)

useEffect(() => {
setShowAdminLink(
!edit &&
JSON.parse((window.localStorage.getItem('tinacms-auth') as any) || '{}')
?.access_token
);
}, [edit]);
)
}, [edit])

const handleDismiss = () => {
setShowAdminLink(false);
};
setShowAdminLink(false)
}

return (
<>
Expand All @@ -96,15 +101,15 @@ const AdminLink = () => {
</div>
)}
</>
);
};
)
}

// TODO: Probably should use hooks here
class Site extends App {
render() {
const { Component, pageProps } = this.props;
return <MainLayout Component={Component} pageProps={pageProps} />;
const { Component, pageProps } = this.props
return <MainLayout Component={Component} pageProps={pageProps} />
}
}

export default Site;
export default Site
35 changes: 18 additions & 17 deletions rss/generateRss.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,39 +4,40 @@ import { fetchRelevantBlogs } from '../data-api/fetchBlogs'
import { formatExcerpt, orderPosts } from '../utils/blog_helpers'
const fs = require('fs')

const formatTitle = title => title.replace(/&/g, '&amp;').replace(/</g, '&lt;').replace(/>/g, '&gt;')


const blogPostsRssXml = async blogPosts => {
let latestPostDate: string = ''
let rssItemsXml = ''
for (let post of blogPosts) {
const postDate = Date.parse(post.data.date)
const postDate = new Date(post.data.date).toUTCString();
const excerpt = await formatExcerpt(post.content, 1000, '…')
if (!latestPostDate || postDate > Date.parse(latestPostDate)) {
latestPostDate = post.createdAt
}
const title = formatTitle(post.data.title);
rssItemsXml += `<item>
<title>${post.data.title}</title>
<link>https://tinacms.org/blog/${post.data.slug}</link>
<pubDate>${post.data.date}</pubDate>
<title>${title}</title>
<link>https://tina.io/blog/${post.data.slug}</link>
<guid>https://tina.io/blog/${post.data.slug}</guid>
<pubDate>${postDate}</pubDate>
<description><![CDATA[${excerpt}]]>
</description>
</item>`
}
return {
rssItemsXml,
latestPostDate,
</item>\n`
}
return rssItemsXml
}

const getRssXml = async blogPosts => {
const { rssItemsXml, latestPostDate } = await blogPostsRssXml(blogPosts)
const rssItemsXml = await blogPostsRssXml(blogPosts)
const now = new Date().toUTCString();

return `<?xml version="1.0" encoding="UTF-8" ?>
<rss version="2.0" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:atom="http://www.w3.org/2005/Atom">
<channel>
<title>TinaCMS Blog RSS Feed</title>
<link>https://tinacms.org/</link>
<description>A site editor for the modern web</description>
<link>https://tina.io/</link>
<description>TinaCMS is a fully open-source headless CMS that supports Git</description>
<language>en</language>
<lastBuildDate>${latestPostDate}</lastBuildDate>
<lastBuildDate>${now}</lastBuildDate>
<atom:link href="https://tina.io/rss.xml" rel="self" type="application/rss+xml" />
${rssItemsXml}
</channel>
</rss>`
Expand Down
2 changes: 1 addition & 1 deletion tina/tina-lock.json

Large diffs are not rendered by default.

0 comments on commit b2957fe

Please sign in to comment.