Skip to content

Commit 29160fe

Browse files
authored
Merge pull request #157 from jerboa88/151-configure-pdf-generation-for-resume
151 configure pdf generation for resume
2 parents 75df745 + f3f65b6 commit 29160fe

File tree

8 files changed

+50
-34
lines changed

8 files changed

+50
-34
lines changed

gatsby-config.ts

+6-3
Original file line numberDiff line numberDiff line change
@@ -12,13 +12,15 @@ import {
1212
getTheme,
1313
} from './src/common/config-manager';
1414
import { SOCIAL_IMAGES_DIR } from './src/common/constants';
15-
import { ThemeType } from './src/common/types';
15+
import { SocialImageType, ThemeType } from './src/common/types';
1616
import { getAbsoluteUrl } from './src/common/utils';
1717
import tailwindConfig from './tailwind.config';
1818

1919
const SITE_METADATA = getSiteMetadata();
2020
const DARK_THEME = getTheme(ThemeType.Dark);
21-
const OG_IMAGE_GENERATION_CONFIG = getSocialImageGenerationConfigForType('og');
21+
const OG_IMAGE_GENERATION_CONFIG = getSocialImageGenerationConfigForType(
22+
SocialImageType.OpenGraph,
23+
);
2224

2325
// Load environment variables from relevant .env file
2426
dotenv.config({
@@ -53,8 +55,9 @@ const config: GatsbyConfig = {
5355
resolve: 'gatsby-plugin-purgecss',
5456
options: {
5557
tailwind: true,
58+
// biome-ignore lint/style/useNamingConvention: Naming convention is enforced by the plugin
5659
purgeCSSOptions: {
57-
safelist: [/where/],
60+
safelist: [/where/, /data-theme/],
5861
},
5962
},
6063
},

src/common/config-manager.ts

+4-7
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ import type {
1212
PageMetadata,
1313
Role,
1414
SentenceString,
15-
SocialImageTypes,
15+
SocialImageType,
1616
SocialImagesGenerationConfig,
1717
Theme,
1818
ThemesConfig,
@@ -141,12 +141,9 @@ export function getSocialImageGenerationConfigDefaults(): SocialImagesGeneration
141141

142142
// Returns the social image generation config for a given type
143143
export function getSocialImageGenerationConfigForType(
144-
type: SocialImageTypes,
145-
): JobOptions {
146-
const config =
147-
socialImagesGenerationConfig.types[
148-
type as keyof (typeof socialImagesGenerationConfig)['types']
149-
];
144+
type: SocialImageType,
145+
): Partial<JobOptions> {
146+
const config = socialImagesGenerationConfig.types[type];
150147

151148
if (!config) {
152149
console.warn(`Social image generation config for '${type}' not found`);

src/common/types.ts

+10-8
Original file line numberDiff line numberDiff line change
@@ -103,24 +103,26 @@ export interface PagesMetadataConfig {
103103
[pagePath: AbsolutePathString]: PageMetadata;
104104
}
105105

106-
// TODO: Use this type in interfaces below
107-
// TODO: Change this to an enum
108-
export type SocialImageTypes = 'og' | 'twitter';
106+
// Variant names for social images
107+
export enum SocialImageType {
108+
OpenGraph = 'og',
109+
Twitter = 'twitter',
110+
}
109111

110112
// Raw social image metadata config
111113
export interface SocialImagesGenerationConfig {
112-
defaults: DefaultOptions;
114+
defaults: Partial<DefaultOptions>;
113115
types: {
114-
og: JobOptions;
115-
twitter: JobOptions;
116+
[SocialImageType.OpenGraph]: Partial<JobOptions>;
117+
[SocialImageType.Twitter]: Partial<JobOptions>;
116118
};
117119
}
118120

119121
// Social image metadata added to the pageContext of pages when they are created
120122
export interface SocialImagesMetadataProp {
121123
socialImagesMetadata: {
122-
og: JobOptions;
123-
twitter: JobOptions;
124+
[SocialImageType.OpenGraph]: JobOptions;
125+
[SocialImageType.Twitter]: JobOptions;
124126
};
125127
}
126128

src/components/layout/section.tsx

+2-2
Original file line numberDiff line numberDiff line change
@@ -34,8 +34,8 @@ export const Section = forwardRef(
3434
ref: ForwardedRef<HTMLElement>,
3535
) => {
3636
const classNameProps = getClassNameProps(
37-
'flex z-10 flex-col justify-center w-full',
38-
responsive && 'w-10/12 max-w-5xl lg:w-9/12 xl:w-8/12', // Adjust width based on screen size
37+
'flex z-10 flex-col justify-center break-inside-avoid-page',
38+
responsive ? 'w-10/12 lg:w-9/12 xl:w-8/12 max-w-5xl' : 'w-full', // Adjust width based on screen size
3939
className,
4040
);
4141
const sectionHeaderClassNameProps = getClassNameProps(

src/components/seo/page-head.tsx

+11-4
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
import { getSiteMetadata, getTheme } from '../../common/config-manager';
77
import {
88
type PageMetadata,
9+
SocialImageType,
910
type SocialImagesMetadataProp,
1011
ThemeType,
1112
} from '../../common/types';
@@ -32,9 +33,11 @@ export function PageHead({
3233
socialImagesMetadata,
3334
}: Props) {
3435
const pageUrl = getAbsoluteUrl(path);
35-
const ogImageUrl = getAbsoluteUrl(socialImagesMetadata.og.imagePath);
36+
const ogImageUrl = getAbsoluteUrl(
37+
socialImagesMetadata[SocialImageType.OpenGraph].imagePath,
38+
);
3639
const twitterImageUrl = getAbsoluteUrl(
37-
socialImagesMetadata.twitter.imagePath,
40+
socialImagesMetadata[SocialImageType.Twitter].imagePath,
3841
);
3942

4043
return (
@@ -54,11 +57,15 @@ export function PageHead({
5457
<meta property="og:image:type" content={getMimeType(ogImageUrl)} />
5558
<meta
5659
property="og:image:width"
57-
content={socialImagesMetadata.og.size.width.toString()}
60+
content={socialImagesMetadata[
61+
SocialImageType.OpenGraph
62+
].size.width.toString()}
5863
/>
5964
<meta
6065
property="og:image:height"
61-
content={socialImagesMetadata.og.size.height.toString()}
66+
content={socialImagesMetadata[
67+
SocialImageType.OpenGraph
68+
].size.height.toString()}
6269
/>
6370

6471
{/* Twitter meta tags */}

src/config/social-images-generation.ts

+6-3
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,10 @@
33
--------------------------------------
44
*/
55

6-
import type { SocialImagesGenerationConfig } from '../common/types';
6+
import {
7+
SocialImageType,
8+
type SocialImagesGenerationConfig,
9+
} from '../common/types';
710

811
export const socialImagesGenerationConfig: SocialImagesGenerationConfig = {
912
defaults: {
@@ -12,13 +15,13 @@ export const socialImagesGenerationConfig: SocialImagesGenerationConfig = {
1215
verbose: false,
1316
},
1417
types: {
15-
og: {
18+
[SocialImageType.OpenGraph]: {
1619
size: {
1720
width: 2400,
1821
height: 1260,
1922
},
2023
},
21-
twitter: {
24+
[SocialImageType.Twitter]: {
2225
size: {
2326
width: 2400,
2427
height: 1200,

src/content/resume-highlights.md

+1-3
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,6 @@
11
- **Goal Getter:** I am seeking to benefit your company and gain valuable skills as a software developer or software engineer.
2-
- **Creative Powerhouse:** I have a passion for designing, creating, and sharing new things. I have over 20 public projects on [GitHub] with a combined 60+ stars.
2+
- **Creative Powerhouse:** I have a passion for designing, creating, and sharing new things. I have over 20 public projects on GitHub with a combined 60+ stars.
33
- **Polyglot Programmer:** I am experienced with a variety of programming languages and tools including React, TypeScript, CSS, Python, C/C++, Java, and SQL.
44
- **Team Player:** I am comfortable working both independently and as part of a team. I have experience working on Agile projects and in self-organized teams.
55
- **Problem Solver:** I am capable of working with tight time constraints, limited human resources, and in challenging conditions as per previous work experience.
66
- **Lifelong Learner:** I am creative and excited to learn more tools and technologies in the future!
7-
8-
[GitHub]: https://github.com/jerboa88

src/node/utils.ts

+10-4
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ import type { Actions, Page } from 'gatsby';
77
import { createImage } from 'gatsby-plugin-component-to-image';
88
import { getSocialImageGenerationConfigForType } from '../common/config-manager';
99
import { SOCIAL_IMAGES_DIR as SOCIAL_IMAGE_PAGES_DIR } from '../common/constants';
10-
import type { AbsolutePathString, SocialImageTypes } from '../common/types';
10+
import { type AbsolutePathString, SocialImageType } from '../common/types';
1111
import { assertIsDefined, removeTrailingSlash } from '../common/utils';
1212
import { info } from './logger';
1313

@@ -59,7 +59,7 @@ export function setGatsbyNodeHelpers(
5959
* @returns The metadata for the generated social image
6060
*/
6161
function createSocialImage(
62-
type: SocialImageTypes,
62+
type: SocialImageType,
6363
{ path, component, context }: CreateSocialImagesOptions,
6464
) {
6565
const pagePath = join(SOCIAL_IMAGE_PAGES_DIR, type, path);
@@ -83,8 +83,14 @@ function createSocialImage(
8383
*/
8484
function createSocialImages(options: CreateSocialImagesOptions) {
8585
return {
86-
og: createSocialImage('og', options),
87-
twitter: createSocialImage('twitter', options),
86+
[SocialImageType.OpenGraph]: createSocialImage(
87+
SocialImageType.OpenGraph,
88+
options,
89+
),
90+
[SocialImageType.Twitter]: createSocialImage(
91+
SocialImageType.Twitter,
92+
options,
93+
),
8894
};
8995
}
9096

0 commit comments

Comments
 (0)