Skip to content

Commit

Permalink
Modify twitter card and footer. Rename all "blog" to "posts"
Browse files Browse the repository at this point in the history
  • Loading branch information
Jeff-Russ committed Apr 24, 2022
1 parent 26885fc commit 70bfa75
Show file tree
Hide file tree
Showing 45 changed files with 65 additions and 68 deletions.
12 changes: 6 additions & 6 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,9 @@

[![Deploy with Vercel](https://vercel.com/button)](https://vercel.com/new/git/external?repository-url=https://github.com/timlrx/tailwind-nextjs-starter-blog)

This is a personal or professional journal/blog starter build on [Next.js](https://nextjs.org/), a [React](https://reactjs.org) framework, with [Tailwind CSS](https://tailwindcss.com) and content provided as markdown or [MDX](https://mdxjs.com) files by one or more authors. It is adapted from [Tailwind Nextjs Starter Blog](https://github.com/timlrx/tailwind-nextjs-starter-blog) template by [Timothy Lin](https://github.com/timlrx), extended to include a resume and support non-blog pages (also authored in MD or MDX), among other features. It is the source code for [jeffruss.com](https://www.jeffruss.com/blog) but, like the Tailwind Nextjs Starter Blog, can be used as a template as well. Here are some other features:
This is a personal or professional journal/posts starter build on [Next.js](https://nextjs.org/), a [React](https://reactjs.org) framework, with [Tailwind CSS](https://tailwindcss.com) and content provided as markdown or [MDX](https://mdxjs.com) files by one or more authors. It is adapted from [Tailwind Nextjs Starter Blog](https://github.com/timlrx/tailwind-nextjs-starter-blog) template by [Timothy Lin](https://github.com/timlrx), extended to include a resume and support non-blog pages (also authored in MD or MDX), among other features. It is the source code for [jeffruss.com](https://www.jeffruss.com/posts) but, like the Tailwind Nextjs Starter Blog, can be used as a template as well. Here are some other features:

- Light and dark theme with easy styling customization with [Tailwind 3.0](https://tailwindcss.com/blog/tailwindcss-v3).
- Light and dark theme with easy styling customization with [Tailwind 3.0](https://tailwindcss.com/posts/tailwindcss-v3).
- Mobile-friendly and responsive
- SEO friendly with RSS feed, sitemaps, etc.
- Preconfigured security headers
Expand Down Expand Up @@ -90,8 +90,8 @@ Overall, you'll at least need to create or modify the following files:
* Create `` `authors/${siteMetadata.defaultAuthorSlug}.md|mdx` `` which is the default author information. Additional authors can be added as files in `data/authors/`.
* Modify `data/projectsData.js` to generate styled cards on the `/projects` page.
* Replace images in `public/static/favicons/` with your own logo.
* Replace/add images in `public/static/images/` referenced in `data/siteMetadata.js` as well in author files in `data/authors/` and any posts you may create in `data/blog` and `data/pages`.
* Replace files in `data/blog` with your own posts.
* Replace/add images in `public/static/images/` referenced in `data/siteMetadata.js` as well in author files in `data/authors/` and any posts you may create in `data/posts` and `data/pages`.
* Replace files in `data/posts` with your own posts.

Additionally you may need or want to do the following:

Expand Down Expand Up @@ -368,7 +368,7 @@ First, configure `siteMetadata.js` with the settings that correspond with the de
```js
analytics: {
// supports plausible, simpleAnalytics or googleAnalytics
plausibleDataDomain: '', // e.g. tailwind-nextjs-starter-blog.vercel.app
plausibleDataDomain: '', // e.g. next-markdown-journal.vercel.app
simpleAnalytics: false, // true or false
umamiWebsiteId: process.env.NEXT_PUBLIC_UMAMI_WEBSITE_ID, // e.g. 123e4567-e89b-12d3-a456-426614174000
googleAnalyticsId: process.env.NEXT_PUBLIC_GOOGLE_ANALYTICS_ID, // e.g. UA-000000-2 or G-XXXXXXX
Expand Down Expand Up @@ -443,7 +443,7 @@ Here is a quick overview to important items in the menu:
* [Settings](https://buttondown.email/settings) is where you can change your **Username**, **Newsletter name** and **Newsletter description**, among other things.
* [Subscribing](https://buttondown.email/settings/subscribing) is where you can modify how people sign up (confirmation and welcome emails, etc).

Sometimes email confirmations from Buttondown are identified as spam by Gmail and possibly others. [Here is advice from Buttondown on this](https://blog.buttondown.email/2019/05/16/sending-newsletters-that-get-delivered).
Sometimes email confirmations from Buttondown are identified as spam by Gmail and possibly others. [Here is advice from Buttondown on this](https://posts.buttondown.email/2019/05/16/sending-newsletters-that-get-delivered).

### Deployment

Expand Down
10 changes: 2 additions & 8 deletions components/Footer.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,16 +16,10 @@ export default function Footer() {
<SocialLink kind="twitter" href={siteMetadata.twitter} size="6" />
</div>
<div className="mb-2 flex space-x-2 text-sm text-gray-500 dark:text-gray-400">
<div>{siteMetadata.author}</div>
<div>{` • `}</div>
<div>{${new Date().getFullYear()}`}</div>
<div>{` • `}</div>
<Link href="/">{siteMetadata.title}</Link>
<Link href="/">{${new Date().getFullYear()} ${siteMetadata.author}`}</Link>
</div>
<div className="mb-8 text-sm text-gray-500 dark:text-gray-400">
<Link href="https://github.com/timlrx/tailwind-nextjs-starter-blog">
Tailwind Nextjs Theme
</Link>
<Link href={siteMetadata.siteRepo}>Built with Next.js Markdown Journal</Link>
</div>
</div>
</footer>
Expand Down
2 changes: 1 addition & 1 deletion components/Image.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import NextImage from 'next/image'

// eslint-disable-next-line jsx-a11y/alt-text
// Used in compoents/MDXComponents.js, components/Card.js, layouts/AuthorLayout.js, layouts/PostLayout.js,
// and various sample blog posts
// and various sample posts
const Image = ({ ...rest }) => <NextImage {...rest} />

export default Image
2 changes: 1 addition & 1 deletion components/LayoutWrapper.js
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ const LayoutWrapper = ({ children }) => {
<Link
key={link.title}
href={link.href}
className="p-1 font-medium text-gray-900 dark:text-orange-100 sm:p-2"
className="p-0.5 font-medium text-gray-900 dark:text-orange-100 sm:p-2 md:p-3"
>
{link.title}
</Link>
Expand Down
2 changes: 1 addition & 1 deletion components/MDXComponents.js
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ export const MDXComponents = {
},
}

// Used only in pages/blog/[...slug].js, pages/about.js
// Used only in pages/posts/[...slug].js, pages/about.js
export const MDXLayoutRenderer = ({ layout, mdxSource, ...rest }) => {
const MDXLayout = useMemo(() => getMDXComponent(mdxSource), [mdxSource])

Expand Down
2 changes: 1 addition & 1 deletion components/PageTitle.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// Used only in layouts/PostLayout.js, layouts/PostSimpleLayout.js, pages/blog/[...slug].js
// Used only in layouts/PostLayout.js, layouts/PostSimpleLayout.js, pages/posts/[...slug].js
export default function PageTitle({ children }) {
return (
<h1 className="text-3xl font-extrabold leading-9 tracking-tight text-gray-900 dark:text-orange-100 sm:text-4xl sm:leading-10 md:text-5xl md:leading-14">
Expand Down
4 changes: 2 additions & 2 deletions components/Pagination.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ export default function Pagination({ totalPages, currentPage }) {
</button>
)}
{prevPage && (
<Link href={currentPage - 1 === 1 ? `/blog/` : `/blog/page/${currentPage - 1}`}>
<Link href={currentPage - 1 === 1 ? `/posts/` : `/posts/page/${currentPage - 1}`}>
<button rel="previous">Previous</button>
</Link>
)}
Expand All @@ -27,7 +27,7 @@ export default function Pagination({ totalPages, currentPage }) {
</button>
)}
{nextPage && (
<Link href={`/blog/page/${currentPage + 1}`}>
<Link href={`/posts/page/${currentPage + 1}`}>
<button rel="next">Next</button>
</Link>
)}
Expand Down
2 changes: 1 addition & 1 deletion components/TOCInline.js
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@
*
*/
// Used only in components/MDXComponents.js and in a
// sample blog post (new-features-in-vq.mdx)
// sample post (new-features-in-vq.mdx)
const TOCInline = ({
toc,
indentRem = 1,
Expand Down
2 changes: 1 addition & 1 deletion data/headerNavLinks.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
const headerNavLinks = [
{ href: '/blog/page/1', title: 'Blog' },
{ href: '/posts/page/1', title: 'Posts' },
{ href: '/tags', title: 'Tags' },
{ href: '/projects', title: 'Projects' },
{ href: '/about', title: 'About' },
Expand Down
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
2 changes: 1 addition & 1 deletion data/projectsData.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ const projectsData = [
to the desired date and press "Go". No more worrying about lost keys or
forgotten headphones with this simple yet affordable solution.`,
imgSrc: '/static/images/time-machine.jpg',
href: '/blog/the-time-machine',
href: '/posts/the-time-machine',
},
]

Expand Down
4 changes: 2 additions & 2 deletions data/siteMetadata.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ const siteMetadata = {
title: 'Jeff Russ | Programmer',
author: 'Jeff Russ',
headerTitle: 'Jeff Russ',
description: 'A blog created with Next.js, Markdown and Tailwind.css',
description: 'A journal created with Next.js, Markdown and Tailwind.css',
language: 'en-us',
theme: 'system', // system, dark or light
siteUrl: 'https://www.jeffruss.com',
Expand All @@ -22,7 +22,7 @@ const siteMetadata = {
// If you want to use an analytics provider you have to add it to the
// content security policy in the `next.config.js` file.
// supports plausible, simpleAnalytics, umami or googleAnalytics
plausibleDataDomain: '', // e.g. tailwind-nextjs-starter-blog.vercel.app
plausibleDataDomain: '', // e.g. next-markdown-journal.vercel.app
simpleAnalytics: false, // true or false
umamiWebsiteId: process.env.NEXT_PUBLIC_UMAMI_WEBSITE_ID, // e.g. 123e4567-e89b-12d3-a456-426614174000
googleAnalyticsId: process.env.NEXT_PUBLIC_GOOGLE_ANALYTICS_ID, // e.g. UA-000000-2 or G-XXXXXXX
Expand Down
5 changes: 4 additions & 1 deletion layouts/ListLayout.js
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,10 @@ export default function ListLayout({ posts, title, initialDisplayPosts = [], pag
<div className="space-y-3 xl:col-span-3">
<div>
<h3 className="text-2xl font-bold leading-8 tracking-tight">
<Link href={`/blog/${slug}`} className="text-gray-900 dark:text-orange-100">
<Link
href={`/posts/${slug}`}
className="text-gray-900 dark:text-orange-100"
>
{title}
</Link>
</h3>
Expand Down
14 changes: 7 additions & 7 deletions layouts/PostLayout.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,10 +8,10 @@ import siteMetadata from '@/data/siteMetadata'
import Comments from '@/components/comments'
import ScrollTopAndComment from '@/components/ScrollTopAndComment'

const editUrl = (fileName) => `${siteMetadata.siteRepo}/blob/master/data/blog/${fileName}`
const editUrl = (fileName) => `${siteMetadata.siteRepo}/blob/master/data/posts/${fileName}`
const discussUrl = (slug) =>
`https://mobile.twitter.com/search?q=${encodeURIComponent(
`${siteMetadata.siteUrl}/blog/${slug}`
`${siteMetadata.siteUrl}/posts/${slug}`
)}`

const postDateTemplate = { weekday: 'long', year: 'numeric', month: 'long', day: 'numeric' }
Expand All @@ -22,7 +22,7 @@ export default function PostLayout({ frontMatter, authorDetails, next, prev, chi
return (
<SectionContainer>
<BlogSEO
url={`${siteMetadata.siteUrl}/blog/${slug}`}
url={`${siteMetadata.siteUrl}/posts/${slug}`}
authorDetails={authorDetails}
{...frontMatter}
/>
Expand Down Expand Up @@ -118,7 +118,7 @@ export default function PostLayout({ frontMatter, authorDetails, next, prev, chi
Previous Article
</h2>
<div className="text-primary-500 hover:text-primary-600 dark:hover:text-primary-400">
<Link href={`/blog/${prev.slug}`}>{prev.title}</Link>
<Link href={`/posts/${prev.slug}`}>{prev.title}</Link>
</div>
</div>
)}
Expand All @@ -128,7 +128,7 @@ export default function PostLayout({ frontMatter, authorDetails, next, prev, chi
Next Article
</h2>
<div className="text-primary-500 hover:text-primary-600 dark:hover:text-primary-400">
<Link href={`/blog/${next.slug}`}>{next.title}</Link>
<Link href={`/posts/${next.slug}`}>{next.title}</Link>
</div>
</div>
)}
Expand All @@ -137,10 +137,10 @@ export default function PostLayout({ frontMatter, authorDetails, next, prev, chi
</div>
<div className="pt-4 xl:pt-8">
<Link
href="/blog"
href="/posts"
className="text-primary-500 hover:text-primary-600 dark:hover:text-primary-400"
>
&larr; Back to the blog
&larr; Back to Posts
</Link>
</div>
</footer>
Expand Down
6 changes: 3 additions & 3 deletions layouts/PostSimpleLayout.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ export default function PostLayout({ frontMatter, authorDetails, next, prev, chi

return (
<SectionContainer>
<BlogSEO url={`${siteMetadata.siteUrl}/blog/${frontMatter.slug}`} {...frontMatter} />
<BlogSEO url={`${siteMetadata.siteUrl}/posts/${frontMatter.slug}`} {...frontMatter} />
<ScrollTopAndComment />
<article>
<div>
Expand Down Expand Up @@ -44,7 +44,7 @@ export default function PostLayout({ frontMatter, authorDetails, next, prev, chi
{prev && (
<div className="pt-4 xl:pt-8">
<Link
href={`/blog/${prev.slug}`}
href={`/posts/${prev.slug}`}
className="text-primary-500 hover:text-primary-600 dark:hover:text-primary-400"
>
&larr; {prev.title}
Expand All @@ -54,7 +54,7 @@ export default function PostLayout({ frontMatter, authorDetails, next, prev, chi
{next && (
<div className="pt-4 xl:pt-8">
<Link
href={`/blog/${next.slug}`}
href={`/posts/${next.slug}`}
className="text-primary-500 hover:text-primary-600 dark:hover:text-primary-400"
>
{next.title} &rarr;
Expand Down
4 changes: 2 additions & 2 deletions layouts/ResumeLayout.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,10 @@ import PageTitle from '@/components/PageTitle'
import { PageSEO } from '@/components/SEO'
import siteMetadata from '@/data/siteMetadata'

const editUrl = (fileName) => `${siteMetadata.siteRepo}/blob/master/data/blog/${fileName}`
const editUrl = (fileName) => `${siteMetadata.siteRepo}/blob/master/data/posts/${fileName}`
const discussUrl = (slug) =>
`https://mobile.twitter.com/search?q=${encodeURIComponent(
`${siteMetadata.siteUrl}/blog/${slug}`
`${siteMetadata.siteUrl}/posts/${slug}`
)}`

const postDateTemplate = { weekday: 'long', year: 'numeric', month: 'long', day: 'numeric' }
Expand Down
6 changes: 3 additions & 3 deletions lib/generate-rss.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,9 @@ import siteMetadata from '@/data/siteMetadata'

const generateRssItem = (post) => `
<item>
<guid>${siteMetadata.siteUrl}/blog/${post.slug}</guid>
<guid>${siteMetadata.siteUrl}/posts/${post.slug}</guid>
<title>${escape(post.title)}</title>
<link>${siteMetadata.siteUrl}/blog/${post.slug}</link>
<link>${siteMetadata.siteUrl}/posts/${post.slug}</link>
${post.summary && `<description>${escape(post.summary)}</description>`}
<pubDate>${new Date(post.date).toUTCString()}</pubDate>
<author>${siteMetadata.email} (${siteMetadata.author})</author>
Expand All @@ -18,7 +18,7 @@ const generateRss = (posts, page = 'feed.xml') => `
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom">
<channel>
<title>${escape(siteMetadata.title)}</title>
<link>${siteMetadata.siteUrl}/blog</link>
<link>${siteMetadata.siteUrl}/posts</link>
<description>${escape(siteMetadata.description)}</description>
<language>${siteMetadata.language}</language>
<managingEditor>${siteMetadata.email} (${siteMetadata.author})</managingEditor>
Expand Down
2 changes: 1 addition & 1 deletion lib/mdx.js
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ const root = process.cwd()
export function getFiles(type) {
const prefixPaths = path.join(root, 'data', type)
const files = getAllFilesRecursively(prefixPaths)
// Only want to return blog/path and ignore root, replace is needed to work on Windows
// Only want to return posts/path and ignore root, replace is needed to work on Windows
return files.map((file) => file.slice(prefixPaths.length + 1).replace(/\\/g, '/'))
}

Expand Down
4 changes: 2 additions & 2 deletions next.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -57,8 +57,8 @@ module.exports = withBundleAnalyzer({
return [
{
source: '/',
destination: '/blog',
permanent: true,
destination: '/posts',
permanent: false,
},
// {
// source: '/',
Expand Down
14 changes: 7 additions & 7 deletions pages/blog/[...blog_slug].js → pages/posts/[...post_slug].js
Original file line number Diff line number Diff line change
Expand Up @@ -8,10 +8,10 @@ import siteMetadata from '@/data/siteMetadata'
const DEFAULT_LAYOUT = 'PostLayout'

export async function getStaticPaths() {
const posts = getFiles('blog')
const posts = getFiles('posts')
const paths = posts.map((p) => ({
params: {
blog_slug: formatSlug(p).split('/'),
post_slug: formatSlug(p).split('/'),
},
}))
return {
Expand All @@ -21,13 +21,13 @@ export async function getStaticPaths() {
}

export async function getStaticProps({ params }) {
const allPosts = await getAllFilesFrontMatter('blog')
const allPosts = await getAllFilesFrontMatter('posts')
const postIndex = allPosts.findIndex(
(post) => formatSlug(post.slug) === params.blog_slug.join('/')
(post) => formatSlug(post.slug) === params.post_slug.join('/')
)
const prev = allPosts[postIndex + 1] || null
const next = allPosts[postIndex - 1] || null
const post = await getFileBySlug('blog', params.blog_slug.join('/'))
const post = await getFileBySlug('posts', params.post_slug.join('/'))
const authorList = post.frontMatter.authors || [siteMetadata.defaultAuthorSlug]
const authorPromise = authorList.map(async (author) => {
const authorResults = await getFileBySlug('authors', [author])
Expand All @@ -40,9 +40,9 @@ export async function getStaticProps({ params }) {
const rss = generateRss(allPosts)
fs.writeFileSync('./public/feed.xml', rss)
}
/* When rendering /blog/deriving-ols-estimator (which has LaTeX):
/* When rendering /posts/deriving-ols-estimator (which has LaTeX):
"Warning: data for page "/blog/[...blog_slug]" is 143 kB, this amount of data can reduce performance.
"Warning: data for page "/posts/[...post_slug]" is 143 kB, this amount of data can reduce performance.
See more info here: https://nextjs.org/docs/messages/large-page-data"
The main problem is that post.mdxSource is in the 200KB+ for most posts
Expand Down
8 changes: 4 additions & 4 deletions pages/blog/index.js → pages/posts/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ import NewsletterForm from '@/components/NewsletterForm'
const MAX_DISPLAY = 5

export async function getStaticProps() {
const posts = await getAllFilesFrontMatter('blog')
const posts = await getAllFilesFrontMatter('posts')

return { props: { posts } }
}
Expand Down Expand Up @@ -47,7 +47,7 @@ export default function Blog({ posts }) {
<div>
<h2 className="text-2xl font-bold leading-8 tracking-tight">
<Link
href={`/blog/${slug}`}
href={`/posts/${slug}`}
className="text-gray-900 dark:text-orange-100"
>
{title}
Expand All @@ -65,7 +65,7 @@ export default function Blog({ posts }) {
</div>
<div className="text-base font-medium leading-6">
<Link
href={`/blog/${slug}`}
href={`/posts/${slug}`}
className="text-primary-500 hover:text-primary-600 dark:hover:text-primary-400"
aria-label={`Read "${title}"`}
>
Expand All @@ -83,7 +83,7 @@ export default function Blog({ posts }) {
{(true || posts.length > MAX_DISPLAY) /*check disabled with true ( ... ) */ && (
<div className="flex justify-end text-base font-medium leading-6">
<Link
href="/blog/page/1"
href="/posts/page/1"
className="text-primary-500 hover:text-primary-600 dark:hover:text-primary-400"
aria-label="all posts"
>
Expand Down
Loading

0 comments on commit 70bfa75

Please sign in to comment.