Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

refactor: mdx to ts #107

Merged
merged 5 commits into from
Mar 24, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .github/ISSUE_TEMPLATE/agregar-nuevo-recurso.md
Original file line number Diff line number Diff line change
Expand Up @@ -25,4 +25,4 @@ Video (opcional):
> 🚨 Por el momento solo videos en español. Link al video de la persona explicando sobre el recurso, ej si es una extensión, como se usa.

**De ser necesario, sumar contexto adicional**
<!--Añade aquí cualquier otro contexto o capturas de pantalla sobre la solicitud de función.-->
<!--Añade aquí cualquier otro contexto o capturas de pantalla sobre la solicitud de función.-->
2 changes: 1 addition & 1 deletion .github/ISSUE_TEMPLATE/agregar-nuevo-video-para-recurso.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,4 +11,4 @@ assignees: nsdonato
Los videos realizados están a cargo de Noe - [vamoacodear](https:www.twitter.com/vamoacodear), son en español y pueden demorar. Si existe algún video en español que momentameante pueda suplir el pedido, se agregará.

**De ser necesario, agregar contexto adicional**
Añade aquí cualquier otro contexto o capturas de pantalla sobre la solicitud de función.
Añade aquí cualquier otro contexto o capturas de pantalla sobre la solicitud de función.
2 changes: 1 addition & 1 deletion .github/ISSUE_TEMPLATE/reporte-de-bug.md
Original file line number Diff line number Diff line change
Expand Up @@ -38,4 +38,4 @@ Si procede, añada capturas de pantalla para ayudar a explicar su problema.
- Versión [por ejemplo, 22]

\*\*Contexto adicional
Añade aquí cualquier otro contexto sobre el problema.
Añade aquí cualquier otro contexto sobre el problema.
2 changes: 1 addition & 1 deletion .github/pull_request_template.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,4 +15,4 @@
> Checklist a modo recordatorio. Tildar lo que corresponda

- [ ] Te agregaste como contribuidor/a, en el archivo mdx que tocaste?
- [ ] Si tocaste código (no mdx), agregaste test para cubrirlo?
- [ ] Si tocaste código (no archivos db), agregaste test para cubrirlo?
4 changes: 2 additions & 2 deletions .github/workflows/check-links.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,5 +12,5 @@ jobs:
id: lychee
uses: lycheeverse/[email protected]
with:
fail: true
args: --config './lychee.toml' .
fail: true
args: --config './lychee.toml' .
22 changes: 11 additions & 11 deletions app/[...slug]/page.tsx → app/[menu]/[submenu]/page.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,29 +3,29 @@ import { Card } from '@/components/card/card'
import { Contributors } from '@/components/contributors/contributors'
import { Divider } from '@/components/divider/divider'
import { Header } from '@/components/header/header'
import { getMenuItem } from '@/lib/mdx/get-menu-item'
import { Contributor } from '@/lib/mdx/mdx-utils'
import { getSubMenuData } from '@/lib/db-utils'

export default async function Slug({ params }: { params: { slug: string[] } }) {
const { data } = await getMenuItem(params.slug)
type SubmenuPageProps = {
params: {
menu: string
submenu: string
}
}

if (!data) return null
export default async function SubmenuPage({ params }: SubmenuPageProps) {
const data = getSubMenuData(params.menu, params.submenu)

return (
<>
<Header title={data.title} description={data.description} />

<div className='grid gap-4 grid-cols-1 md:grid-cols-2 lg:grid-cols-4 mt-8'>
{data.submenu.map(item => (
{data.pageItems.map(item => (
<Card key={item.imgPlaceholder} item={item} />
))}
</div>
<Divider className='p-4' />

<Contributors
isIndex={false}
contributors={data?.contributors as Contributor[]}
/>
<Contributors isIndex={false} contributors={data.contributors} />
<ButtonUp />
</>
)
Expand Down
15 changes: 15 additions & 0 deletions app/[menu]/page.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
import { Header } from '@/components/header/header'

type MenuPageProps = {
params: {
menu: string
}
}

export default function MenuPage({ params }: MenuPageProps) {
return (
<>
<Header title={params.menu} description={['Proximamente...']} />
</>
)
}
9 changes: 0 additions & 9 deletions app/frontend/page.tsx

This file was deleted.

72 changes: 55 additions & 17 deletions app/page.tsx
Original file line number Diff line number Diff line change
@@ -1,29 +1,67 @@
import { MDXRemote } from 'next-mdx-remote/rsc'
import { noeSocialNetworks } from 'db/vamoacodear-socials'

import { Contributors } from '@/components/contributors/contributors'
import { Figure } from '@/components/figure/figure'
import { Header } from '@/components/header/header'
import { WebLink } from '@/components/web-link/web-link'
import { getIndex } from '@/lib/mdx/get-index'

export default async function Home() {
const { source } = await getIndex()

return (
<div>
<MDXRemote
source={source}
components={{
Figure,
li: props => <li className='' {...props} />,
ul: props => <ul className='list-disc pl-6' {...props} />,
p: props => <p className='py-4' {...props} />,
WebLink,
Header,
}}
<>
<Header
title='Inicio'
description={['En Internet siempre veo las mismas preguntas:']}
/>
<div className='divider'></div>
<ul className='list-disc list-inside my-6'>
<li>¿Tenes algún recurso de iconos?</li>
<li>¿Donde puedo deployar mi web?</li>
<li>¿Cómo configuro [inserte aquí extensión, herramienta, etc]?</li>
</ul>
<p>
💡 Crees que debería haber un recurso y no esta? Hace un PR y agregalo!
</p>
<p className='mb-4'>
😨 ¿No te animas?, hace el pedido mediante este{' '}
<WebLink
className='underline'
eventName='Click on New Issue - Link recurso'
href='https://github.com/nsdonato/recursostech/issues/new/choose'
target='_blank'>
Issue
</WebLink>
, opción <em>Agregar nuevo recurso</em> y lo agregamos!
</p>
<p>
📹 ¿Te gustaría que alguna herramienta tenga video, para saber como
instalarla/configurarla?
</p>
<p className='mb-4'>
🚀 Hace el pedido mediante un{' '}
<WebLink
className='underline'
eventName='Click on New Issue - Link video'
href='https://github.com/nsdonato/recursostech/issues/new/choose'
target='_blank'>
Issue
</WebLink>
, opción <em>Agregar nuevo video para recurso</em>e intentamos sumarlo!
</p>
<p className='mb-4'>
Espero te guste la idea y si crees que se puede agregar algo más, no
dudes en comentarlo! ☺️
</p>
Noe.-
<div className='flex gap-2 mt-4 items-center mb-4'>
{noeSocialNetworks.map(({ type, url, cover }) => (
<WebLink
key={type}
href={url}
eventName={`Click on vamoacodear - ${type}`}>
<Figure cover={cover} placeholder={type} />
</WebLink>
))}
</div>
<Contributors isIndex />
</div>
</>
)
}
21 changes: 14 additions & 7 deletions app/sitemap.ts
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
import { menu } from 'db/menu'
import { MetadataRoute } from 'next'

import { getUpdatedDate } from '@/lib/file-utils'
import { getDocs } from '@/lib/mdx/get-menu'

const WEBSITE_HOST_URL = process.env.SITE_URL || 'https://recursostech.dev'

// TODO
type changeFrequency =
| 'always'
| 'hourly'
Expand All @@ -15,15 +15,22 @@ type changeFrequency =
| 'never'

export default async function sitemap(): Promise<MetadataRoute.Sitemap> {
let { urls } = await getDocs()
const changeFrequency = 'daily' as changeFrequency
let { urls } = menu.reduce(
(acc, menu) => {
menu.items.forEach(item => {
acc.urls.push(item.url)
})
return acc
},
{ urls: [] as string[] }
)

const changeFrequency = 'daily' as changeFrequency
const routes = ['', ...urls].map(url => {
const path = url === '' ? '/docs/index' : url

const path = url === '' ? '' : url
return {
url: url === '' ? WEBSITE_HOST_URL : `${WEBSITE_HOST_URL}${path}`,
lastModified: getUpdatedDate(path),
lastModified: url === '' ? new Date() : getUpdatedDate(`/db${path}`),
changeFrequency,
}
})
Expand Down
3 changes: 3 additions & 0 deletions app/testing/interviews/page.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
export default function InterviewsPage() {
return <>InterviewsPage</>
}
10 changes: 10 additions & 0 deletions components/button/button-up.test.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
import { render } from '@/lib/test-utils'

import { ButtonUp } from './button-up'

describe('ButtonUp', () => {
test('renders correctly', () => {
const { container } = render(<ButtonUp />)
expect(container).toBeInTheDocument()
})
})
2 changes: 1 addition & 1 deletion components/button/button-up.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { WebLink } from '@/components/web-link/web-link'
import { EventNames } from '@/lib/metrics/event-name-types'
import { EventNames } from '@/lib/metrics/metrics-types'

export const ButtonUp = () => {
return (
Expand Down
4 changes: 2 additions & 2 deletions components/card/card-body.tsx
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
import { Figure as CoverType } from '@/lib/mdx/get-menu-item'
import { Cover } from '@/lib/db-types'

import { Figure } from '../figure/figure'

type CardBodyProps = {
cover: CoverType
cover: Cover
imgPlaceholder: string
}

Expand Down
4 changes: 2 additions & 2 deletions components/card/card-information.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { InfoExtra } from '@/lib/mdx/get-menu-item'
import { InfoExtra } from '@/lib/db-types'

import { getConferenceInfo } from './card-utils'
import { getConferenceInfo } from './utils/card-utils'

type CardTitleProps = {
title?: string
Expand Down
15 changes: 0 additions & 15 deletions components/card/card-types.ts

This file was deleted.

5 changes: 0 additions & 5 deletions components/card/card-utils.ts

This file was deleted.

9 changes: 4 additions & 5 deletions components/card/card.tsx
Original file line number Diff line number Diff line change
@@ -1,13 +1,12 @@
import { Video } from '@/components/video/video'
import { PageItem } from '@/lib/db-types'

import { Video } from '../video/video'
import { WebLink } from '../web-link/web-link'
import { CardBody } from './card-body'
import { CardInformation } from './card-information'
import { CardTitle } from './card-title'
import { CardItem } from './card-types'

type CardProps = {
item: CardItem
item: PageItem
}

export const Card = ({ item }: CardProps) => {
Expand All @@ -17,7 +16,7 @@ export const Card = ({ item }: CardProps) => {
<div className='card p-4 ring-1 bg-base-100 shadow-lg h-auto hover:scale-105 transition-transform'>
<CardBody cover={cover} imgPlaceholder={imgPlaceholder} />
<>
<CardTitle title={imgPlaceholder} />
<p className='py-1 truncate'>{imgPlaceholder}</p>
<div className='divider m-0 p-0'></div>
<CardInformation title={titleCard} infoExtra={infoExtra} />
<div className='flex flex-wrap gap-2 pt-1'>
Expand Down
Loading
Loading