Skip to content

Commit a2b8959

Browse files
committed
Rename and mark config exports as const
1 parent 32955a9 commit a2b8959

File tree

12 files changed

+40
-40
lines changed

12 files changed

+40
-40
lines changed

Diff for: src/config/color-mappings.ts

+3-3
Original file line numberDiff line numberDiff line change
@@ -3,9 +3,9 @@
33
---------------------------------------------------
44
*/
55

6-
import type { ColorMappingsConfig } from '../types/other';
6+
import type { ColorMappingsConfig } from '../types/other.ts';
77

8-
export const colorMappingsConfig: ColorMappingsConfig = {
8+
export const COLOR_MAPPINGS_CONFIG: ColorMappingsConfig = {
99
default: 'bg-rose-600',
1010
projectType: {
1111
'android app': 'bg-lime-600',
@@ -26,4 +26,4 @@ export const colorMappingsConfig: ColorMappingsConfig = {
2626
internship: 'bg-rose-600',
2727
'summer job': 'bg-rose-600',
2828
},
29-
};
29+
} as const;

Diff for: src/config/content/roles.ts

+2-2
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55

66
import { RoleType, type RolesConfig } from '../../types/content/roles.ts';
77

8-
export const rolesConfig: RolesConfig = {
8+
export const ROLES_CONFIG: RolesConfig = {
99
[RoleType.Employment]: [
1010
{
1111
type: 'internship',
@@ -136,4 +136,4 @@ export const rolesConfig: RolesConfig = {
136136
],
137137
},
138138
],
139-
};
139+
} as const;

Diff for: src/config/content/skills.ts

+2-2
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55

66
import { SkillType, type SkillsConfig } from '../../types/content/skills.ts';
77

8-
export const skillsConfig: SkillsConfig = {
8+
export const SKILLS_CONFIG: SkillsConfig = {
99
[SkillType.Languages]: [
1010
'Bash',
1111
'C/C++',
@@ -70,4 +70,4 @@ export const skillsConfig: SkillsConfig = {
7070
'OOP',
7171
'Unit Testing',
7272
],
73-
};
73+
} as const;

Diff for: src/config/external-services.ts

+3-3
Original file line numberDiff line numberDiff line change
@@ -3,11 +3,11 @@
33
-------------------------------------------
44
*/
55

6-
import type { ExternalServicesConfig } from '../types/other';
6+
import type { ExternalServicesConfig } from '../types/other.ts';
77

88
// TODO: Move these values to constants instead
99

10-
export const externalServicesConfig: ExternalServicesConfig = {
10+
export const EXTERNAL_SERVICES_CONFIG: ExternalServicesConfig = {
1111
botpoisonPublicKey: 'pk_eca5c4ea-ccb4-46da-beb0-15c581b6980e',
1212
contactFormPostUrl: 'https://submit-form.com/re6Xbd2gs',
13-
};
13+
} as const;

Diff for: src/config/metadata/pages.ts

+2-2
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ import {
1111
RESUME_PATH,
1212
} from '../constants.ts';
1313

14-
export const pagesMetadataConfig: PagesMetadataConfig = {
14+
export const PAGES_METADATA_CONFIG: PagesMetadataConfig = {
1515
[PRIVACY_POLICY_PATH]: {
1616
title: 'Privacy Policy',
1717
shortTitle: 'Privacy',
@@ -35,4 +35,4 @@ export const pagesMetadataConfig: PagesMetadataConfig = {
3535
shortTitle: '404',
3636
description: "Oof, there's nothing here.",
3737
},
38-
};
38+
} as const;

Diff for: src/config/metadata/site.ts

+2-2
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55

66
import type { SiteMetadataConfig } from '../../types/other.ts';
77

8-
export const siteMetadataConfig: SiteMetadataConfig = {
8+
export const SITE_METADATA_CONFIG: SiteMetadataConfig = {
99
iconPath: 'images/icon.svg',
1010
siteUrl: 'https://johng.io/',
1111
sourceUrl: 'https://github.com/jerboa88/jerboa88.github.io/',
@@ -29,4 +29,4 @@ export const siteMetadataConfig: SiteMetadataConfig = {
2929
country: 'Canada',
3030
},
3131
},
32-
};
32+
} as const;

Diff for: src/config/social-images-generation.ts

+2-2
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ import {
88
type SocialImagesGenerationConfig,
99
} from '../types/other.ts';
1010

11-
export const socialImagesGenerationConfig: SocialImagesGenerationConfig = {
11+
export const SOCIAL_IMAGES_GENERATION_CONFIG: SocialImagesGenerationConfig = {
1212
defaults: {
1313
type: 'webp',
1414
quality: 100,
@@ -28,4 +28,4 @@ export const socialImagesGenerationConfig: SocialImagesGenerationConfig = {
2828
},
2929
},
3030
},
31-
};
31+
} as const;

Diff for: src/config/themes.ts

+3-3
Original file line numberDiff line numberDiff line change
@@ -3,9 +3,9 @@
33
---------------------------
44
*/
55

6-
import { ThemeType, type ThemesConfig } from '../types/other';
6+
import { ThemeType, type ThemesConfig } from '../types/other.ts';
77

8-
export const themesConfig: ThemesConfig = {
8+
export const THEMES_CONFIG: ThemesConfig = {
99
[ThemeType.Light]: {
1010
primary: '#0F766E', // TW Teal 700
1111
secondary: '#E11D48', // TW Rose 600
@@ -36,4 +36,4 @@ export const themesConfig: ThemesConfig = {
3636
'base-content': '#FFF', // Pure white
3737
'neutral-content': '#E5E5E5', // TW Neutral 200
3838
},
39-
};
39+
} as const;

Diff for: src/managers/config.ts

+16-16
Original file line numberDiff line numberDiff line change
@@ -4,13 +4,13 @@
44
*/
55

66
import type { JobOptions } from 'gatsby-plugin-component-to-image/lib/types';
7-
import { colorMappingsConfig } from '../config/color-mappings.ts';
7+
import { COLOR_MAPPINGS_CONFIG } from '../config/color-mappings.ts';
88
import { PAGES_CONTENT_CONFIG } from '../config/content/pages.ts';
9-
import { externalServicesConfig } from '../config/external-services.ts';
10-
import { pagesMetadataConfig } from '../config/metadata/pages.ts';
11-
import { siteMetadataConfig } from '../config/metadata/site.ts';
12-
import { socialImagesGenerationConfig } from '../config/social-images-generation.ts';
13-
import { themesConfig } from '../config/themes.ts';
9+
import { EXTERNAL_SERVICES_CONFIG } from '../config/external-services.ts';
10+
import { PAGES_METADATA_CONFIG } from '../config/metadata/pages.ts';
11+
import { SITE_METADATA_CONFIG } from '../config/metadata/site.ts';
12+
import { SOCIAL_IMAGES_GENERATION_CONFIG } from '../config/social-images-generation.ts';
13+
import { THEMES_CONFIG } from '../config/themes.ts';
1414
import { warn } from '../node/logger.ts';
1515
import type { PageContentConfig } from '../types/content/content.ts';
1616
import type {
@@ -69,7 +69,7 @@ type SiteMetadata = {
6969

7070
// Returns metadata for the site
7171
export function getSiteMetadata(): SiteMetadata {
72-
const config = siteMetadataConfig;
72+
const config = SITE_METADATA_CONFIG;
7373
const authorFullName: Capitalize<string> =
7474
`${config.author.name.first} ${config.author.name.last}` as typeof config.author.name.first;
7575

@@ -115,7 +115,7 @@ export function getSiteMetadata(): SiteMetadata {
115115
// Returns the metadata for a given page
116116
export function getPageMetadata(pagePath: string): PageMetadata {
117117
const config =
118-
pagesMetadataConfig[pagePath as keyof typeof pagesMetadataConfig];
118+
PAGES_METADATA_CONFIG[pagePath as keyof typeof PAGES_METADATA_CONFIG];
119119

120120
if (!config) {
121121
warn(`Page metadata for ${pagePath} not found`);
@@ -138,14 +138,14 @@ export function getPageContentConfig(pagePath: string): PageContentConfig {
138138

139139
// Returns the social image generation config for a given type
140140
export function getSocialImageGenerationConfigDefaults(): SocialImagesGenerationConfig['defaults'] {
141-
return socialImagesGenerationConfig.defaults;
141+
return SOCIAL_IMAGES_GENERATION_CONFIG.defaults;
142142
}
143143

144144
// Returns the social image generation config for a given type
145145
export function getSocialImageGenerationConfigForType(
146146
type: SocialImageType,
147147
): Partial<JobOptions> {
148-
const config = socialImagesGenerationConfig.types[type];
148+
const config = SOCIAL_IMAGES_GENERATION_CONFIG.types[type];
149149

150150
if (!config) {
151151
warn(`Social image generation config for '${type}' not found`);
@@ -155,12 +155,12 @@ export function getSocialImageGenerationConfigForType(
155155
}
156156

157157
export function getExternalServices() {
158-
return externalServicesConfig;
158+
return EXTERNAL_SERVICES_CONFIG;
159159
}
160160

161161
// Returns a daisyUI theme given its name
162162
export function getTheme(themeName: keyof ThemesConfig): Theme {
163-
const config = themesConfig[themeName];
163+
const config = THEMES_CONFIG[themeName];
164164

165165
if (!config) {
166166
throw new Error(`Theme '${themeName}' not found`);
@@ -173,7 +173,7 @@ export function getTheme(themeName: keyof ThemesConfig): Theme {
173173
export function getProjectTypeColor(
174174
projectType: string | undefined | null,
175175
): BgColorString | '' {
176-
const colorMap = colorMappingsConfig.projectType;
176+
const colorMap = COLOR_MAPPINGS_CONFIG.projectType;
177177
const key = projectType?.toLowerCase();
178178

179179
if (isDefined(key)) {
@@ -184,14 +184,14 @@ export function getProjectTypeColor(
184184
warn(`Color for project type '${projectType}' not found`);
185185
}
186186

187-
return colorMappingsConfig.default;
187+
return COLOR_MAPPINGS_CONFIG.default;
188188
}
189189

190190
// Returns the color for a given role type
191191
export function getRoleTypeColor(
192192
roleType: string | undefined | null,
193193
): BgColorString | '' {
194-
const colorMap = colorMappingsConfig.roleType;
194+
const colorMap = COLOR_MAPPINGS_CONFIG.roleType;
195195
const key = roleType?.toLowerCase();
196196

197197
if (isDefined(key)) {
@@ -202,5 +202,5 @@ export function getRoleTypeColor(
202202
warn(`Color for role type '${roleType}' not found`);
203203
}
204204

205-
return colorMappingsConfig.default;
205+
return COLOR_MAPPINGS_CONFIG.default;
206206
}

Diff for: src/managers/content/roles.ts

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

6-
import { rolesConfig } from '../../config/content/roles.ts';
6+
import { ROLES_CONFIG } from '../../config/content/roles.ts';
77
import {
88
type EducationRole,
99
type EmploymentRole,
@@ -79,7 +79,7 @@ export function getRolesForPage(pagePath: string) {
7979
for (const roleType of roleTypes) {
8080
roleSubsets[roleType] = filterEntries(
8181
pagePath,
82-
rolesConfig[roleType].map(buildRole),
82+
ROLES_CONFIG[roleType].map(buildRole),
8383
pageRolesConfig[roleType],
8484
getRoleId,
8585
);

Diff for: src/managers/content/skills.ts

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

6-
import { skillsConfig } from '../../config/content/skills.ts';
6+
import { SKILLS_CONFIG } from '../../config/content/skills.ts';
77
import {
88
type Skill,
99
SkillType,
@@ -33,7 +33,7 @@ export function getSkillsForPage(pagePath: string) {
3333
for (const skillType of skillTypes) {
3434
skillSubsets[skillType] = filterEntries<Skill>(
3535
pagePath,
36-
skillsConfig[skillType],
36+
SKILLS_CONFIG[skillType],
3737
pageSkillsConfig[skillType],
3838
(skill: Skill) => skill,
3939
);

Diff for: src/managers/content/utils.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ export function getPageEntriesLimit<T>(
4141
*/
4242
export function filterEntries<T>(
4343
pagePath: string,
44-
allEntries: T[],
44+
allEntries: readonly T[],
4545
pageContentEntryConfig: PageContentEntryConfig<T>,
4646
getEntryId: (entry: T) => string,
4747
doPinEntry?: FilterFn<T>,

0 commit comments

Comments
 (0)