From 0467c98872fe41ae29cf7310cf0b5b02f2fc16f9 Mon Sep 17 00:00:00 2001 From: Noelia Date: Wed, 31 Jan 2024 20:36:19 +0100 Subject: [PATCH] fix: delete dead props (#54) --- .husky/commit-msg | 1 + docs/ciberseguridad/streamers.mdx | 2 -- docs/frontend/colors_palette.mdx | 2 -- docs/frontend/components_library.mdx | 4 +--- docs/frontend/icons.mdx | 12 ---------- docs/frontend/images.mdx | 24 +++++++------------ docs/frontend/streamers.mdx | 2 -- docs/vscode/extensions.mdx | 2 -- lib/date-utils.test.ts | 35 ---------------------------- lib/date-utils.ts | 19 --------------- lib/file-utils.ts | 12 ---------- lib/mdx/get-menu.tsx | 18 +------------- 12 files changed, 11 insertions(+), 122 deletions(-) create mode 100644 .husky/commit-msg delete mode 100644 lib/date-utils.test.ts delete mode 100644 lib/date-utils.ts diff --git a/.husky/commit-msg b/.husky/commit-msg new file mode 100644 index 0000000..0003522 --- /dev/null +++ b/.husky/commit-msg @@ -0,0 +1 @@ +npx --no -- commitlint --edit "${1}" \ No newline at end of file diff --git a/docs/ciberseguridad/streamers.mdx b/docs/ciberseguridad/streamers.mdx index 08f6c18..c5fa8ec 100644 --- a/docs/ciberseguridad/streamers.mdx +++ b/docs/ciberseguridad/streamers.mdx @@ -21,7 +21,5 @@ submenu: src: '/streamers/hack4u.jpg' height: 80 width: 90 - createdAt: '2024-01-29T00:00:00Z' - updatedAt: '2024-01-29T00:00:00Z' videos: [] --- diff --git a/docs/frontend/colors_palette.mdx b/docs/frontend/colors_palette.mdx index 0e35573..32b992b 100644 --- a/docs/frontend/colors_palette.mdx +++ b/docs/frontend/colors_palette.mdx @@ -40,8 +40,6 @@ submenu: src: '/frontend/uicolors.svg' height: 80 width: 190 - createdAt: '2024-01-25T00:00:00Z' - updatedAt: '2024-01-29T00:00:00Z' videos: [] - imgPlaceholder: 'Cool Contrast' diff --git a/docs/frontend/components_library.mdx b/docs/frontend/components_library.mdx index 3441b15..54e933a 100644 --- a/docs/frontend/components_library.mdx +++ b/docs/frontend/components_library.mdx @@ -184,7 +184,7 @@ submenu: height: 80 width: 190 videos: [] - + - imgPlaceholder: 'Buttons ibelick' titleCard: 'Buttons ibelick' links: @@ -194,7 +194,5 @@ submenu: src: '' height: 80 width: 190 - createdAt: '2024-01-30T00:00:00Z' - updatedAt: '2024-01-30T00:00:00Z' videos: [] --- diff --git a/docs/frontend/icons.mdx b/docs/frontend/icons.mdx index b83b2ec..198a953 100644 --- a/docs/frontend/icons.mdx +++ b/docs/frontend/icons.mdx @@ -104,8 +104,6 @@ submenu: src: '' height: 80 width: 190 - createdAt: '2024-01-27T00:00:00Z' - updatedAt: '2024-01-27T00:00:00Z' videos: [] - imgPlaceholder: svgl @@ -117,8 +115,6 @@ submenu: src: '' height: 80 width: 190 - createdAt: '2024-01-27T00:00:00Z' - updatedAt: '2024-01-27T00:00:00Z' videos: [] - imgPlaceholder: yesicon @@ -130,8 +126,6 @@ submenu: src: '' height: 80 width: 190 - createdAt: '2024-01-27T00:00:00Z' - updatedAt: '2024-01-27T00:00:00Z' videos: [] - imgPlaceholder: Remix Icon @@ -143,8 +137,6 @@ submenu: src: '' height: 80 width: 190 - createdAt: '2024-01-27T00:00:00Z' - updatedAt: '2024-01-27T00:00:00Z' videos: [] - imgPlaceholder: MingCute Icon @@ -156,8 +148,6 @@ submenu: src: '' height: 80 width: 190 - createdAt: '2024-01-27T00:00:00Z' - updatedAt: '2024-01-27T00:00:00Z' videos: [] - imgPlaceholder: Animated Icons @@ -169,7 +159,5 @@ submenu: src: '' height: 80 width: 190 - createdAt: '2024-01-27T00:00:00Z' - updatedAt: '2024-01-27T00:00:00Z' videos: [] --- diff --git a/docs/frontend/images.mdx b/docs/frontend/images.mdx index 82eb1a6..9a27c4e 100644 --- a/docs/frontend/images.mdx +++ b/docs/frontend/images.mdx @@ -14,10 +14,8 @@ submenu: url: 'https://www.pexels.com/es-es/' cover: src: '' - height: 80 - width: 190 - createdAt: '2024-01-29T00:00:00Z' - updatedAt: '2024-01-29T00:00:00Z' + height: 80 + width: 190 videos: [] - imgPlaceholder: 'Animated Backgrounds' @@ -27,10 +25,8 @@ submenu: url: 'https://animatedbackgrounds.me' cover: src: '' - height: 80 - width: 190 - createdAt: '2024-01-29T00:00:00Z' - updatedAt: '2024-01-29T00:00:00Z' + height: 80 + width: 190 videos: [] - imgPlaceholder: 'Undraw' @@ -40,10 +36,8 @@ submenu: url: 'https://undraw.co' cover: src: '' - height: 80 - width: 190 - createdAt: '2024-01-29T00:00:00Z' - updatedAt: '2024-01-29T00:00:00Z' + height: 80 + width: 190 videos: [] - imgPlaceholder: 'Humaaans' @@ -53,9 +47,7 @@ submenu: url: 'https://www.humaaans.com' cover: src: '' - height: 80 - width: 190 - createdAt: '2024-01-29T00:00:00Z' - updatedAt: '2024-01-29T00:00:00Z' + height: 80 + width: 190 videos: [] --- diff --git a/docs/frontend/streamers.mdx b/docs/frontend/streamers.mdx index 454b94d..ce56010 100644 --- a/docs/frontend/streamers.mdx +++ b/docs/frontend/streamers.mdx @@ -113,8 +113,6 @@ submenu: src: '/streamers/carlosazaustre.png' height: 80 width: 90 - createdAt: '2024-01-30T00:00:00Z' - updatedAt: '2024-01-30T00:00:00Z' videos: [] --- diff --git a/docs/vscode/extensions.mdx b/docs/vscode/extensions.mdx index c51724f..0d63183 100644 --- a/docs/vscode/extensions.mdx +++ b/docs/vscode/extensions.mdx @@ -15,8 +15,6 @@ submenu: src: '' height: 40 width: 40 - createdAt: '2024-01-14T00:00:00Z' - updatedAt: '2024-01-26T00:00:00Z' links: - type: 'Market' url: 'https://marketplace.visualstudio.com/items?itemName=inu1255.easy-snippet' diff --git a/lib/date-utils.test.ts b/lib/date-utils.test.ts deleted file mode 100644 index feafe13..0000000 --- a/lib/date-utils.test.ts +++ /dev/null @@ -1,35 +0,0 @@ -import { isToday, isUpdated } from './date-utils' - -describe('date-utils', () => { - const today = new Date() - - const yesterday = new Date(today) - yesterday.setDate(today.getDate() - 1) - - const lastWeek = new Date(today) - lastWeek.setDate(today.getDate() - 7) - - describe('isToday', () => { - test('returns true if createdAt is today', () => { - expect(isToday(today)).toBe(true) - }) - - test('returns false if createdAt is not today', () => { - expect(isToday(yesterday)).toBe(false) - }) - }) - - describe('isUpdated', () => { - test('returns true if updatedDate is today', () => { - expect(isUpdated(today)).toBe(true) - }) - - test('returns true if updatedDate is this week', () => { - expect(isUpdated(yesterday)).toBe(true) - }) - - test('returns false if date is not this week', () => { - expect(isUpdated(lastWeek)).toBe(false) - }) - }) -}) diff --git a/lib/date-utils.ts b/lib/date-utils.ts deleted file mode 100644 index b769aac..0000000 --- a/lib/date-utils.ts +++ /dev/null @@ -1,19 +0,0 @@ -export const isToday = (date: Date) => { - const today = new Date() - - return ( - today.getFullYear() === date.getFullYear() && - today.getMonth() === date.getMonth() && - today.getDate() === date.getDate() - ) -} - -// Show updated badge if updatedAt is within the last 2 days -export const isUpdated = (updatedAt: Date) => { - const today = new Date() - - const limitDate = new Date(today) - limitDate.setDate(today.getDate() - 2) - - return updatedAt >= limitDate && updatedAt <= today -} diff --git a/lib/file-utils.ts b/lib/file-utils.ts index 491ad26..eee7a00 100644 --- a/lib/file-utils.ts +++ b/lib/file-utils.ts @@ -1,18 +1,6 @@ import fs from 'fs/promises' import path from 'path' -import { isToday, isUpdated } from './date-utils' - export const readFile = (localPath: string) => { return fs.readFile(path.join(process.cwd(), localPath), 'utf8') } - -export const getCreationDate = async (localPath: string) => { - const stats = await fs.stat(path.join(process.cwd(), localPath + '.mdx')) - return isToday(stats.birthtime) -} - -export const getUpdatedDate = async (localPath: string) => { - const stats = await fs.stat(path.join(process.cwd(), localPath + '.mdx')) - return isUpdated(stats.mtime) -} diff --git a/lib/mdx/get-menu.tsx b/lib/mdx/get-menu.tsx index 8639afa..63fe8df 100644 --- a/lib/mdx/get-menu.tsx +++ b/lib/mdx/get-menu.tsx @@ -1,6 +1,5 @@ import { z } from 'zod' -import { getCreationDate, getUpdatedDate } from '../file-utils' import { getMdxData } from './mdx-utils' export const schema = z.array( @@ -10,8 +9,6 @@ export const schema = z.array( z.object({ name: z.string(), url: z.string(), - isCreated: z.optional(z.boolean()), - isUpdated: z.optional(z.boolean()), }) ), }) @@ -22,21 +19,8 @@ export async function getMenu() { const parsedData = schema.parse(mdxData.data) - const final = parsedData.map(menuItem => { - return { - name: menuItem.name, - items: menuItem.items.map(at => { - return { - ...at, - isCreated: getCreationDate(at.url), - isUpdated: getUpdatedDate(at.url), - } - }), - } - }) - return { ...mdxData, - data: final, + data: parsedData, } }