-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
refactor: add CI and refactor the unused variables
- Loading branch information
1 parent
6476ee1
commit 387d028
Showing
13 changed files
with
157 additions
and
134 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
name: build | ||
|
||
on: | ||
pull_request: | ||
push: | ||
branches: | ||
- main | ||
|
||
jobs: | ||
lint: | ||
runs-on: ubuntu-20.04 | ||
steps: | ||
- uses: actions/checkout@v3 | ||
with: | ||
fetch-depth: 0 | ||
- uses: actions/setup-node@v3 | ||
with: | ||
cache: 'npm' | ||
node-version: '16' | ||
- name: Install dependencies | ||
run: npm ci | ||
- name: Lint | ||
run: npm run lint | ||
|
||
build: | ||
runs-on: ubuntu-20.04 | ||
steps: | ||
- uses: actions/checkout@v3 | ||
with: | ||
fetch-depth: 0 | ||
- uses: actions/setup-node@v3 | ||
with: | ||
cache: 'npm' | ||
node-version: '16' | ||
- name: Install dependencies | ||
run: npm ci | ||
- name: Build | ||
env: | ||
NOTION_ACCESS_TOKEN: ${{ secrets.NOTION_ACCESS_TOKEN }} | ||
NOTION_NOTES_DATABASE_ID_ES: ${{ secrets.NOTION_NOTES_DATABASE_ID_ES }} | ||
NOTION_NOTES_DATABASE_ID_EN: ${{ secrets.NOTION_NOTES_DATABASE_ID_EN }} | ||
NOTION_PROJECTS_DATABASE_ID: ${{ secrets.NOTION_PROJECTS_DATABASE_ID }} | ||
run: npm run build |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,6 @@ | ||
export default { | ||
plugins: { | ||
tailwindcss: {}, | ||
autoprefixer: {}, | ||
}, | ||
} | ||
plugins: { | ||
tailwindcss: {}, | ||
autoprefixer: {} | ||
} | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,12 +1,10 @@ | ||
import type { FormattersInitializer } from 'typesafe-i18n'; | ||
import type { Locales, Formatters } from './i18n-types'; | ||
|
||
export const initFormatters: FormattersInitializer<Locales, Formatters> = ( | ||
locale: Locales, | ||
) => { | ||
const formatters: Formatters = { | ||
// add your formatter functions here | ||
}; | ||
export const initFormatters: FormattersInitializer<Locales, Formatters> = (locale: Locales) => { | ||
const formatters: Formatters = { | ||
// add your formatter functions here | ||
}; | ||
|
||
return formatters; | ||
return formatters; | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,98 +1,100 @@ | ||
// This file was auto-generated by 'typesafe-i18n'. Any manual changes will be overwritten. | ||
/* eslint-disable */ | ||
import type { BaseTranslation as BaseTranslationType, LocalizedString, RequiredParams } from 'typesafe-i18n' | ||
import type { | ||
BaseTranslation as BaseTranslationType, | ||
LocalizedString, | ||
RequiredParams | ||
} from 'typesafe-i18n'; | ||
|
||
export type BaseTranslation = BaseTranslationType | ||
export type BaseLocale = 'en' | ||
export type BaseTranslation = BaseTranslationType; | ||
export type BaseLocale = 'en'; | ||
|
||
export type Locales = | ||
| 'en' | ||
| 'es' | ||
export type Locales = 'en' | 'es'; | ||
|
||
export type Translation = RootTranslation | ||
export type Translation = RootTranslation; | ||
|
||
export type Translations = RootTranslation | ||
export type Translations = RootTranslation; | ||
|
||
type RootTranslation = { | ||
LAYOUT: { | ||
NAV: { | ||
/** | ||
* Home | ||
*/ | ||
HOME: string | ||
HOME: string; | ||
/** | ||
* Notes | ||
*/ | ||
NOTES: string | ||
} | ||
NOTES: string; | ||
}; | ||
FOOTER: { | ||
/** | ||
* Made by Michael Liendo © {start} - {end} | ||
* @param {number} end | ||
* @param {number} start | ||
*/ | ||
COPYRGHT: RequiredParams<'end' | 'start'> | ||
COPYRGHT: RequiredParams<'end' | 'start'>; | ||
/** | ||
* Source Code | ||
*/ | ||
SOURCE_CODE: string | ||
} | ||
} | ||
SOURCE_CODE: string; | ||
}; | ||
}; | ||
HOMEPAGE: { | ||
/** | ||
* Hi I'm {name} {surname}, | ||
* @param {string} name | ||
* @param {string} surname | ||
*/ | ||
HI: RequiredParams<'name' | 'surname'> | ||
HI: RequiredParams<'name' | 'surname'>; | ||
/** | ||
* I'm a Software Developer focused on React and TypeScript with a passion for Web Development. I enjoy working on challenging projects and value collaboration and problem-solving. | ||
*/ | ||
ABOUT: string | ||
ABOUT: string; | ||
/** | ||
* Latest Notes | ||
*/ | ||
LATEST_NOTES: string | ||
} | ||
} | ||
LATEST_NOTES: string; | ||
}; | ||
}; | ||
|
||
export type TranslationFunctions = { | ||
LAYOUT: { | ||
NAV: { | ||
/** | ||
* Home | ||
*/ | ||
HOME: () => LocalizedString | ||
HOME: () => LocalizedString; | ||
/** | ||
* Notes | ||
*/ | ||
NOTES: () => LocalizedString | ||
} | ||
NOTES: () => LocalizedString; | ||
}; | ||
FOOTER: { | ||
/** | ||
* Made by Michael Liendo © {start} - {end} | ||
*/ | ||
COPYRGHT: (arg: { end: number, start: number }) => LocalizedString | ||
COPYRGHT: (arg: { end: number; start: number }) => LocalizedString; | ||
/** | ||
* Source Code | ||
*/ | ||
SOURCE_CODE: () => LocalizedString | ||
} | ||
} | ||
SOURCE_CODE: () => LocalizedString; | ||
}; | ||
}; | ||
HOMEPAGE: { | ||
/** | ||
* Hi I'm {name} {surname}, | ||
*/ | ||
HI: (arg: { name: string, surname: string }) => LocalizedString | ||
HI: (arg: { name: string; surname: string }) => LocalizedString; | ||
/** | ||
* I'm a Software Developer focused on React and TypeScript with a passion for Web Development. I enjoy working on challenging projects and value collaboration and problem-solving. | ||
*/ | ||
ABOUT: () => LocalizedString | ||
ABOUT: () => LocalizedString; | ||
/** | ||
* Latest Notes | ||
*/ | ||
LATEST_NOTES: () => LocalizedString | ||
} | ||
} | ||
LATEST_NOTES: () => LocalizedString; | ||
}; | ||
}; | ||
|
||
export type Formatters = {} | ||
export type Formatters = {}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,27 +1,27 @@ | ||
// This file was auto-generated by 'typesafe-i18n'. Any manual changes will be overwritten. | ||
/* eslint-disable */ | ||
|
||
import { initFormatters } from './formatters' | ||
import type { Locales, Translations } from './i18n-types' | ||
import { loadedFormatters, loadedLocales, locales } from './i18n-util' | ||
import { initFormatters } from './formatters'; | ||
import type { Locales, Translations } from './i18n-types'; | ||
import { loadedFormatters, loadedLocales, locales } from './i18n-util'; | ||
|
||
const localeTranslationLoaders = { | ||
en: () => import('./en'), | ||
es: () => import('./es'), | ||
} | ||
es: () => import('./es') | ||
}; | ||
|
||
const updateDictionary = (locale: Locales, dictionary: Partial<Translations>): Translations => | ||
loadedLocales[locale] = { ...loadedLocales[locale], ...dictionary } | ||
(loadedLocales[locale] = { ...loadedLocales[locale], ...dictionary }); | ||
|
||
export const importLocaleAsync = async (locale: Locales): Promise<Translations> => | ||
(await localeTranslationLoaders[locale]()).default as unknown as Translations | ||
(await localeTranslationLoaders[locale]()).default as unknown as Translations; | ||
|
||
export const loadLocaleAsync = async (locale: Locales): Promise<void> => { | ||
updateDictionary(locale, await importLocaleAsync(locale)) | ||
loadFormatters(locale) | ||
} | ||
updateDictionary(locale, await importLocaleAsync(locale)); | ||
loadFormatters(locale); | ||
}; | ||
|
||
export const loadAllLocalesAsync = (): Promise<void[]> => Promise.all(locales.map(loadLocaleAsync)) | ||
export const loadAllLocalesAsync = (): Promise<void[]> => Promise.all(locales.map(loadLocaleAsync)); | ||
|
||
export const loadFormatters = (locale: Locales): void => | ||
void (loadedFormatters[locale] = initFormatters(locale)) | ||
void (loadedFormatters[locale] = initFormatters(locale)); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,26 +1,26 @@ | ||
// This file was auto-generated by 'typesafe-i18n'. Any manual changes will be overwritten. | ||
/* eslint-disable */ | ||
|
||
import { initFormatters } from './formatters' | ||
import type { Locales, Translations } from './i18n-types' | ||
import { loadedFormatters, loadedLocales, locales } from './i18n-util' | ||
import { initFormatters } from './formatters'; | ||
import type { Locales, Translations } from './i18n-types'; | ||
import { loadedFormatters, loadedLocales, locales } from './i18n-util'; | ||
|
||
import en from './en' | ||
import es from './es' | ||
import en from './en'; | ||
import es from './es'; | ||
|
||
const localeTranslations = { | ||
en, | ||
es, | ||
} | ||
es | ||
}; | ||
|
||
export const loadLocale = (locale: Locales): void => { | ||
if (loadedLocales[locale]) return | ||
if (loadedLocales[locale]) return; | ||
|
||
loadedLocales[locale] = localeTranslations[locale] as unknown as Translations | ||
loadFormatters(locale) | ||
} | ||
loadedLocales[locale] = localeTranslations[locale] as unknown as Translations; | ||
loadFormatters(locale); | ||
}; | ||
|
||
export const loadAllLocales = (): void => locales.forEach(loadLocale) | ||
export const loadAllLocales = (): void => locales.forEach(loadLocale); | ||
|
||
export const loadFormatters = (locale: Locales): void => | ||
void (loadedFormatters[locale] = initFormatters(locale)) | ||
void (loadedFormatters[locale] = initFormatters(locale)); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,38 +1,44 @@ | ||
// This file was auto-generated by 'typesafe-i18n'. Any manual changes will be overwritten. | ||
/* eslint-disable */ | ||
|
||
import { i18n as initI18n, i18nObject as initI18nObject, i18nString as initI18nString } from 'typesafe-i18n' | ||
import type { LocaleDetector } from 'typesafe-i18n/detectors' | ||
import type { LocaleTranslationFunctions, TranslateByString } from 'typesafe-i18n' | ||
import { detectLocale as detectLocaleFn } from 'typesafe-i18n/detectors' | ||
import { initExtendDictionary } from 'typesafe-i18n/utils' | ||
import type { Formatters, Locales, Translations, TranslationFunctions } from './i18n-types' | ||
import { | ||
i18n as initI18n, | ||
i18nObject as initI18nObject, | ||
i18nString as initI18nString | ||
} from 'typesafe-i18n'; | ||
import type { LocaleDetector } from 'typesafe-i18n/detectors'; | ||
import type { LocaleTranslationFunctions, TranslateByString } from 'typesafe-i18n'; | ||
import { detectLocale as detectLocaleFn } from 'typesafe-i18n/detectors'; | ||
import { initExtendDictionary } from 'typesafe-i18n/utils'; | ||
import type { Formatters, Locales, Translations, TranslationFunctions } from './i18n-types'; | ||
|
||
export const baseLocale: Locales = 'en' | ||
export const baseLocale: Locales = 'en'; | ||
|
||
export const locales: Locales[] = [ | ||
'en', | ||
'es' | ||
] | ||
export const locales: Locales[] = ['en', 'es']; | ||
|
||
export const isLocale = (locale: string): locale is Locales => locales.includes(locale as Locales) | ||
export const isLocale = (locale: string): locale is Locales => locales.includes(locale as Locales); | ||
|
||
export const loadedLocales: Record<Locales, Translations> = {} as Record<Locales, Translations> | ||
export const loadedLocales: Record<Locales, Translations> = {} as Record<Locales, Translations>; | ||
|
||
export const loadedFormatters: Record<Locales, Formatters> = {} as Record<Locales, Formatters> | ||
export const loadedFormatters: Record<Locales, Formatters> = {} as Record<Locales, Formatters>; | ||
|
||
export const extendDictionary = initExtendDictionary<Translations>() | ||
export const extendDictionary = initExtendDictionary<Translations>(); | ||
|
||
export const i18nString = (locale: Locales): TranslateByString => initI18nString<Locales, Formatters>(locale, loadedFormatters[locale]) | ||
export const i18nString = (locale: Locales): TranslateByString => | ||
initI18nString<Locales, Formatters>(locale, loadedFormatters[locale]); | ||
|
||
export const i18nObject = (locale: Locales): TranslationFunctions => | ||
initI18nObject<Locales, Translations, TranslationFunctions, Formatters>( | ||
locale, | ||
loadedLocales[locale], | ||
loadedFormatters[locale] | ||
) | ||
); | ||
|
||
export const i18n = (): LocaleTranslationFunctions<Locales, Translations, TranslationFunctions> => | ||
initI18n<Locales, Translations, TranslationFunctions, Formatters>(loadedLocales, loadedFormatters) | ||
initI18n<Locales, Translations, TranslationFunctions, Formatters>( | ||
loadedLocales, | ||
loadedFormatters | ||
); | ||
|
||
export const detectLocale = (...detectors: LocaleDetector[]): Locales => detectLocaleFn<Locales>(baseLocale, locales, ...detectors) | ||
export const detectLocale = (...detectors: LocaleDetector[]): Locales => | ||
detectLocaleFn<Locales>(baseLocale, locales, ...detectors); |
Oops, something went wrong.