Skip to content

Commit

Permalink
refactor(get-og-image): Rename
Browse files Browse the repository at this point in the history
  • Loading branch information
Dave Bitter committed Sep 14, 2021
1 parent f270f12 commit 09bdf70
Show file tree
Hide file tree
Showing 17 changed files with 30 additions and 41 deletions.
12 changes: 0 additions & 12 deletions .github/workflows/main.yml

This file was deleted.

2 changes: 1 addition & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -26,4 +26,4 @@ yarn-debug.log*
yarn-error.log*

# Other
.env
.env*.local
3 changes: 2 additions & 1 deletion next.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -23,5 +23,6 @@ module.exports = {
},
future: {
webpack5: true
}
},
generateBuildId: () => 'build'
};
4 changes: 2 additions & 2 deletions pages/404.tsx
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
import { GetStaticProps } from 'next';
import generateOGImage from '../src/static/js/utils/generateOGImage';
import getOGImage from '../src/static/js/utils/getOGImage';
import query from '../src/static/js/utils/api/query';
import ErrorPage from './error/[status]';

export const getStaticProps: GetStaticProps = async () => {
const { copy } = await query('/content/ui');
const status = '404';

const ogImage = await generateOGImage('/error', {});
const ogImage = await getOGImage('/error', {});

return {
props: {
Expand Down
2 changes: 1 addition & 1 deletion pages/api/content/friday-tips/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import convertYoutubeDataToFridayTip from 'static/js/utils/convertYoutubeDataToF

export default async (req: NextApiRequest, res: NextApiResponse) => {
const baseURL = "https://www.googleapis.com/youtube/v3/";
const playlistId = "AIzaSyA2cTY2EnBIr4iSGrIkCZAqzL85UDwhnqI";
const playlistId = "PLsES66lgcKHD9oRnyN3PEvyTjWXJF4IgT";

const { items } = await fetch(`${baseURL}playlistItems?maxResults=50&part=snippet,contentDetails&playlistId=${playlistId}&key=${process.env.YOUTUBE_API_KEY}`)
.then(res => res.json())
Expand Down
4 changes: 2 additions & 2 deletions pages/articles/[slug].tsx
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import { GetStaticProps } from 'next'
import query from '../../src/static/js/utils/api/query';
import { ArticleInterface, ContentObjectInterface } from '../../src/static/js/utils/Interfaces/Interfaces';
import { ArticleTypeType } from '../../src/static/js/utils/Interfaces/Types';
import generateOGImage from '../../src/static/js/utils/generateOGImage';
import getOGImage from '../../src/static/js/utils/getOGImage';

// Resources

Expand Down Expand Up @@ -54,7 +54,7 @@ export const getStaticProps: GetStaticProps = async (context) => {

const articleData = articles.find((article: ArticleInterface) => context && context.params ? article.slug === context.params.slug : false);

const ogImage = await generateOGImage(`/articles_${articleData.slug}`, { title: articleData.title, image: articleData.teaserImage, date: articleData.date });
const ogImage = await getOGImage(`/articles_${articleData.slug}`, { title: articleData.title, image: articleData.teaserImage, date: articleData.date });

return {
props: {
Expand Down
4 changes: 2 additions & 2 deletions pages/articles/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import { GetStaticProps } from 'next'
import query from '../../src/static/js/utils/api/query';
import { ArticleInterface } from '../../src/static/js/utils/Interfaces/Interfaces';
import { ArticleTypeType } from '../../src/static/js/utils/Interfaces/Types';
import generateOGImage from '../../src/static/js/utils/generateOGImage';
import getOGImage from '../../src/static/js/utils/getOGImage';

// Resources

Expand All @@ -32,7 +32,7 @@ export const getStaticProps: GetStaticProps = async () => {
const { copy, headings } = await query('/content/ui');
const { articles } = await query('/content/articles');

const ogImage = await generateOGImage('/articles', { title: headings.latestArticles, image: '/img/articles.jpg' });
const ogImage = await getOGImage('/articles', { title: headings.latestArticles, image: '/img/articles.jpg' });

return {
props: {
Expand Down
4 changes: 2 additions & 2 deletions pages/error/[status].tsx
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import { GetStaticProps } from 'next';
// Utils
import query from '../../src/static/js/utils/api/query';
import { HTTPStatusCodeType } from '../../src/static/js/utils/Interfaces/Types';
import generateOGImage from '../../src/static/js/utils/generateOGImage';
import getOGImage from '../../src/static/js/utils/getOGImage';

// Components

Expand Down Expand Up @@ -33,7 +33,7 @@ export const getStaticPaths = async () => {
export const getStaticProps: GetStaticProps = async () => {
const { copy } = await query('/content/ui'); const status = '500';

const ogImage = await generateOGImage('/error', {});
const ogImage = await getOGImage('/error', {});

return {
props: {
Expand Down
4 changes: 2 additions & 2 deletions pages/friday-tips/[slug].tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import { GetStaticProps } from 'next';

// Uitls
import query from '../../src/static/js/utils/api/query';
import generateOGImage from '../../src/static/js/utils/generateOGImage';
import getOGImage from '../../src/static/js/utils/getOGImage';
import { ArticleInterface } from '../../src/static/js/utils/Interfaces/Interfaces';

// Components
Expand All @@ -24,7 +24,7 @@ export const getStaticProps: GetStaticProps = async (context) => {

const articleData = fridayTips.find((fridayTip: ArticleInterface) => context && context.params ? fridayTip.slug === context.params.slug : false);

const ogImage = await generateOGImage(`/friday-tips_${articleData.slug}`, { title: articleData.title, image: articleData.teaserImage, date: articleData.date });
const ogImage = await getOGImage(`/friday-tips_${articleData.slug}`, { title: articleData.title, image: articleData.teaserImage, date: articleData.date });

return {
props: {
Expand Down
4 changes: 2 additions & 2 deletions pages/friday-tips/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import { GetStaticProps } from 'next';

// Utils
import query from '../../src/static/js/utils/api/query';
import generateOGImage from '../../src/static/js/utils/generateOGImage';
import getOGImage from '../../src/static/js/utils/getOGImage';

// Components
import Index from '../articles/index';
Expand All @@ -12,7 +12,7 @@ export const getStaticProps: GetStaticProps = async () => {
const { copy, headings } = await query('/content/ui');
const { fridayTips } = await query('/content/friday-tips');

const ogImage = await generateOGImage('/friday-tips', { title: headings.latestFridayTips, image: '/img/friday-tips.jpg' });
const ogImage = await getOGImage('/friday-tips', { title: headings.latestFridayTips, image: '/img/friday-tips.jpg' });

return {
props: {
Expand Down
4 changes: 2 additions & 2 deletions pages/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ import query from '../src/static/js/utils/api/query';
import ArticleTeasers from '../src/components/Article/ArticleTeasers/ArticleTeasers';
import ResumePitch from '../src/components/Resume/ResumePitch/ResumePitch';
import { ArticleInterface, ContentObjectInterface } from '../src/static/js/utils/Interfaces/Interfaces';
import generateOGImage from 'static/js/utils/generateOGImage';
import getOGImage from 'static/js/utils/getOGImage';

// Interface
interface IProps {
Expand Down Expand Up @@ -95,7 +95,7 @@ export const getStaticProps: GetStaticProps = async () => {
const quickBitTeaserItems = quickBits.slice(0, 3);
const fridayTipTeaserItems = fridayTips.slice(0, 3);

const ogImage = await generateOGImage('/index', {});
const ogImage = await getOGImage('/index', {});

return {
props: {
Expand Down
4 changes: 2 additions & 2 deletions pages/quick-bits/[slug].tsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import { GetStaticProps } from 'next';
// Uitls
import query from '../../src/static/js/utils/api/query';
import { ArticleInterface } from '../../src/static/js/utils/Interfaces/Interfaces';
import generateOGImage from '../../src/static/js/utils/generateOGImage';
import getOGImage from '../../src/static/js/utils/getOGImage';

// Components
import Index from '../articles/[slug]';
Expand All @@ -24,7 +24,7 @@ export const getStaticProps: GetStaticProps = async (context) => {

const articleData = quickBits.find((quickBit: ArticleInterface) => context && context.params ? quickBit.slug === context.params.slug : false);

const ogImage = await generateOGImage(`/quick-bits_${articleData.slug}`, { title: articleData.title, image: articleData.teaserImage, date: articleData.date });
const ogImage = await getOGImage(`/quick-bits_${articleData.slug}`, { title: articleData.title, image: articleData.teaserImage, date: articleData.date });

return {
props: {
Expand Down
4 changes: 2 additions & 2 deletions pages/quick-bits/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import { GetStaticProps } from 'next';

// Utils
import query from '../../src/static/js/utils/api/query';
import generateOGImage from '../../src/static/js/utils/generateOGImage';
import getOGImage from '../../src/static/js/utils/getOGImage';

// Components
import Index from '../articles/index';
Expand All @@ -12,7 +12,7 @@ export const getStaticProps: GetStaticProps = async () => {
const { copy, headings } = await query('/content/ui');
const { quickBits } = await query('/content/quick-bits');

const ogImage = await generateOGImage('/quick-bits', { title: headings.latestQuickBits, image: '/img/articles.jpg' });
const ogImage = await getOGImage('/quick-bits', { title: headings.latestQuickBits, image: '/img/articles.jpg' });

return {
props: {
Expand Down
4 changes: 2 additions & 2 deletions pages/resume/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import { GetStaticProps } from 'next';

// Utils
import query from '../../src/static/js/utils/api/query';
import generateOGImage from '../../src/static/js/utils/generateOGImage';
import getOGImage from '../../src/static/js/utils/getOGImage';

// Resources

Expand Down Expand Up @@ -43,7 +43,7 @@ export const getStaticProps: GetStaticProps = async () => {
const { copy, headings } = await query('/content/ui');
const { workExperience, education } = await query('/content/work-and-education');

const ogImage = await generateOGImage('/resume', { title: headings.greeting });
const ogImage = await getOGImage('/resume', { title: headings.greeting });

return {
props: {
Expand Down
4 changes: 2 additions & 2 deletions pages/tags/[tag].tsx
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import { GetStaticProps } from 'next';
// Utils
import query from '../../src/static/js/utils/api/query';
import { ArticleInterface, ContentObjectInterface, TagInterface } from '../../src/static/js/utils/Interfaces/Interfaces';
import generateOGImage from '../../src/static/js/utils/generateOGImage';
import getOGImage from '../../src/static/js/utils/getOGImage';

// Resources

Expand Down Expand Up @@ -68,7 +68,7 @@ export const getStaticProps: GetStaticProps = async (context) => {
.filter((quickBit: ArticleInterface) => quickBit.tags.find((tag: TagInterface) => tag.key === activeTag));
const tagLabel = context.params && context.params.tag && activeTag ? tags[Array.isArray(activeTag) ? activeTag[0] : activeTag] : null;

const ogImage = await generateOGImage(`/tags_${activeTag}`, { title: tagLabel || activeTag, image: `/img/tags/${activeTag}.jpg` });
const ogImage = await getOGImage(`/tags_${activeTag}`, { title: tagLabel || activeTag, image: `/img/tags/${activeTag}.jpg` });

return {
props: {
Expand Down
4 changes: 2 additions & 2 deletions pages/tags/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import { GetStaticProps } from 'next'
import query from '../../src/static/js/utils/api/query';
import { ArticleInterface } from '../../src/static/js/utils/Interfaces/Interfaces';
import { ArticleTypeType } from '../../src/static/js/utils/Interfaces/Types';
import generateOGImage from '../../src/static/js/utils/generateOGImage';
import getOGImage from '../../src/static/js/utils/getOGImage';

// Resources

Expand All @@ -33,7 +33,7 @@ export const getStaticProps: GetStaticProps = async () => {
const { articles } = await query('/content/articles');
const { quickBits } = await query('/content/quick-bits');

const ogImage = await generateOGImage('/tags_index', { title: headings.latestArticlesAndTags, image: '/img/articles.jpg' });
const ogImage = await getOGImage('/tags_index', { title: headings.latestArticlesAndTags, image: '/img/articles.jpg' });

return {
props: {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import query from './api/query';
import generateQueryString from './generateQueryString';
import { OGImageRequestInterface } from "./Interfaces/Interfaces";

const generateOGImage = async (path: string, { title = 'davebitter.com', date, image }: OGImageRequestInterface) => {
const getOGImage = async (path: string, { title = 'davebitter.com', date, image }: OGImageRequestInterface) => {
if (process.env.NODE_ENV === 'development') {
return path;
}
Expand Down Expand Up @@ -35,4 +35,4 @@ const generateOGImage = async (path: string, { title = 'davebitter.com', date, i
}
};

export default generateOGImage;
export default getOGImage;

0 comments on commit 09bdf70

Please sign in to comment.