diff --git a/Makefile b/Makefile index 91e8f68..762945f 100644 --- a/Makefile +++ b/Makefile @@ -7,6 +7,8 @@ SHELL := /bin/bash PROJECT_NAME := $(shell sed -n 's/^ "name": "\(.*\)",$$/\1/p' package.json) NODE_VERSION := $(shell cat .nvmrc) NODE_IMAGE := node:$(NODE_VERSION) +PNPM_VERSION := $(shell sed -n 's/^ "packageManager": "pnpm@\(.*\)",$$/\1/p' package.json) +PNPM := npx --yes pnpm@$(PNPM_VERSION) DEV_CONTAINER := $(PROJECT_NAME)-dev PORT := 4321 @@ -19,14 +21,13 @@ OPEN_CMD := $(shell command -v sensible-browser 2>/dev/null || command -v xdg NODE_ENV_VARS = \ -u $(HOST_USER) \ -e HOME=/tmp \ - -e COREPACK_HOME=/tmp/corepack \ - -e COREPACK_ENABLE_DOWNLOAD_PROMPT=0 \ + -e CI=true \ -e ASTRO_TELEMETRY_DISABLED=1 \ -e GITHUB_TOKEN \ -e npm_config_store_dir=/tmp/pnpm-store \ -v $(CURDIR):/app -w /app -APP_RUN = docker run $(INTERACTIVE) --rm $(NODE_ENV_VARS) $(NODE_IMAGE) corepack pnpm +APP_RUN = docker run $(INTERACTIVE) --rm $(NODE_ENV_VARS) $(NODE_IMAGE) $(PNPM) .PHONY: configure configure: ## @setup Install dependencies @@ -41,7 +42,7 @@ start: ## @setup Start the development server with live reload @docker rm -f $(DEV_CONTAINER) > /dev/null 2>&1 || true @docker run -d --rm --name $(DEV_CONTAINER) $(NODE_ENV_VARS) \ -p 127.0.0.1:$(PORT):$(PORT) \ - $(NODE_IMAGE) corepack pnpm dev --host 0.0.0.0 --port $(PORT) > /dev/null + $(NODE_IMAGE) $(PNPM) dev --host 0.0.0.0 --port $(PORT) > /dev/null @echo "Development server at $(SITE_URL)" .PHONY: stop @@ -61,7 +62,7 @@ preview: ## @setup Serve the built site, search included, on the development por @docker rm -f $(DEV_CONTAINER) > /dev/null 2>&1 || true @docker run -d --rm --name $(DEV_CONTAINER) $(NODE_ENV_VARS) \ -p 127.0.0.1:$(PORT):$(PORT) \ - $(NODE_IMAGE) corepack pnpm preview --host 0.0.0.0 --port $(PORT) > /dev/null + $(NODE_IMAGE) $(PNPM) preview --host 0.0.0.0 --port $(PORT) > /dev/null @echo "Built site at $(SITE_URL)" .PHONY: brand-images diff --git a/README.md b/README.md index 7bf4104..17b03b8 100644 --- a/README.md +++ b/README.md @@ -39,8 +39,11 @@ GitHub: | `/` | A descrição e as estrelas de cada repositório, pela API REST da organização. | | `/desafios` | O `README.md` de `desafios`, e o `PROBLEM.md` e o `SOLUTIONS.md` de cada desafio listado. | | `/vagas` | As issues abertas de `vagas` e a descrição de cada label, pela API REST. | +| `/talentos` | As issues abertas de `me-contrata` com os labels `verificado` e `divulgar-perfil`. | | `/projetos` | A tabela da seção `Projetos` do `README.md` de `opensource-br`. | | `/comunidade.json` | Os números do terminal da home: vagas abertas, desafios, projetos e estrelas. | +| `/vagas.json` | As vagas abertas, com nível, regime, modelo de trabalho e tecnologias. | +| `/talentos.json` | Os perfis divulgados, com os mesmos campos das vagas e os links de contato. | A leitura fica em `src/content/sources.ts`, e a interpretação de cada fonte fica em um módulo puro de `src/content/`, coberto por testes. Uma requisição que falha interrompe o build, então o site publicado continua diff --git a/src/components/SiteBar.astro b/src/components/SiteBar.astro index 20bf051..d5edd22 100644 --- a/src/components/SiteBar.astro +++ b/src/components/SiteBar.astro @@ -8,6 +8,7 @@ import ThemeToggle from './ThemeToggle.astro' const sections = [ { path: '/desafios/', label: 'Desafios' }, { path: '/vagas/', label: 'Vagas' }, + { path: '/talentos/', label: 'Talentos' }, { path: '/projetos/', label: 'Projetos' }, ] const here = Astro.url.pathname diff --git a/src/components/TalentItem.astro b/src/components/TalentItem.astro new file mode 100644 index 0000000..220c7cb --- /dev/null +++ b/src/components/TalentItem.astro @@ -0,0 +1,65 @@ +--- +import type { TalentEntry } from '../content' +import { day, excerpt, since, TEXT } from '../content/site' +import { anchor } from '../content/talents' +import Avatar from './Avatar.astro' + +interface Props { + talent: TalentEntry +} + +const { data } = Astro.props.talent +const labels = TEXT.talents +const terms = [...data.level, ...data.contract, ...data.modality] +const contacts: { url: string; label: string }[] = [ + { url: data.linkedin, label: labels.linkedin }, + { url: data.github, label: labels.github }, + { url: data.portfolio, label: labels.portfolio }, + { url: data.url, label: labels.profile }, +].flatMap((contact) => (contact.url === null ? [] : [{ url: contact.url, label: contact.label }])) +--- + +
  • +
    + +

    + {data.location} + + {labels.updated} + +

    +
    +

    {data.name}{data.role && ` · ${data.role}`}

    + {data.about &&

    {excerpt(data.about, 280)}

    } +
    + { + terms.length + data.stack.length > 0 && ( + + ) + } +

    + { + contacts.map((contact) => ( + + {contact.label} + + )) + } +

    +
    +
  • diff --git a/src/content.config.ts b/src/content.config.ts index e8b414c..64aa267 100644 --- a/src/content.config.ts +++ b/src/content.config.ts @@ -15,6 +15,7 @@ import { REPOSITORY as JOBS, openings } from './content/jobs' import { rehypeLineBreaks, rehypeOutline, rehypeUntrusted, SHIKI } from './content/markdown' import { byStars, githubHome, REPOSITORY as PROJECTS, projects as projectList } from './content/projects' import { catalogued } from './content/repositories' +import { REPOSITORY as TALENTS, talents as sharedTalents } from './content/talents' import { accountStars, file, labels, openIssues, organizationRepositories, repositoryStars } from './content/sources' const repositories = defineCollection({ @@ -137,6 +138,38 @@ const jobs = defineCollection({ }), }) +const talents = defineCollection({ + loader: { + name: 'backend-br-talents', + load: async ({ store, logger }) => { + const [issues, catalog] = await Promise.all([openIssues(TALENTS), labels(TALENTS)]) + const found = sharedTalents(issues, catalog) + store.clear() + for (const talent of found) { + store.set({ id: String(talent.number), data: { ...talent } }) + } + logger.info(`Read ${found.length} shared profiles.`) + }, + }, + schema: z.object({ + number: z.number(), + name: z.string(), + role: z.string(), + about: z.string(), + location: z.string(), + url: z.string(), + updated: z.string(), + modality: z.array(z.string()), + level: z.array(z.string()), + contract: z.array(z.string()), + stack: z.array(z.string()), + linkedin: z.string().nullable(), + github: z.string().nullable(), + portfolio: z.string().nullable(), + avatar: z.string(), + }), +}) + const STAR_BATCH = 10 const projects = defineCollection({ @@ -184,4 +217,4 @@ const projects = defineCollection({ }), }) -export const collections = { repositories, challenges, jobs, projects } +export const collections = { repositories, challenges, jobs, projects, talents } diff --git a/src/content/catalog.ts b/src/content/catalog.ts index e85f7fe..c03cd03 100644 --- a/src/content/catalog.ts +++ b/src/content/catalog.ts @@ -18,7 +18,7 @@ export const CATALOG: readonly CatalogEntry[] = [ { name: 'opensource-br', page: { path: '/projetos/', label: 'Ver os projetos' } }, { name: 'forum' }, { name: 'como-instalar-xyz' }, - { name: 'me-contrata' }, + { name: 'me-contrata', page: { path: '/talentos/', label: 'Ver os talentos' } }, { name: 'eventos' }, { name: 'poste-mais' }, ] diff --git a/src/content/index.ts b/src/content/index.ts index fd00186..b92aa12 100644 --- a/src/content/index.ts +++ b/src/content/index.ts @@ -4,6 +4,7 @@ export type RepositoryEntry = CollectionEntry<'repositories'> export type Challenge = CollectionEntry<'challenges'> export type JobEntry = CollectionEntry<'jobs'> export type ProjectEntry = CollectionEntry<'projects'> +export type TalentEntry = CollectionEntry<'talents'> export async function repositories(): Promise { return (await getCollection('repositories')).sort((a, b) => a.data.order - b.data.order) @@ -17,6 +18,12 @@ export async function jobs(): Promise { return (await getCollection('jobs')).sort((a, b) => b.data.opened.localeCompare(a.data.opened)) } +export async function talents(): Promise { + return (await getCollection('talents')).sort( + (a, b) => b.data.updated.localeCompare(a.data.updated) || a.data.number - b.data.number, + ) +} + export async function projects(): Promise { return (await getCollection('projects')).sort((a, b) => a.data.order - b.data.order) } diff --git a/src/content/jobs.ts b/src/content/jobs.ts index bfaa23f..62b6ed6 100644 --- a/src/content/jobs.ts +++ b/src/content/jobs.ts @@ -5,6 +5,7 @@ export interface Issue { readonly title: string readonly html_url: string readonly created_at: string + readonly updated_at?: string readonly locked: boolean readonly pull_request?: unknown readonly labels: readonly { readonly name: string }[] diff --git a/src/content/site.ts b/src/content/site.ts index 4b2cdd7..a1556ed 100644 --- a/src/content/site.ts +++ b/src/content/site.ts @@ -98,6 +98,28 @@ export const TEXT = { postUrl: `${repositoryUrl('vagas')}#como-cadastrar-uma-vaga`, all: 'Ver todas no GitHub', empty: 'Nenhuma vaga aberta agora. Acompanhe o repositório backend-br/vagas no GitHub para saber da próxima.', + feed: 'Vagas abertas em JSON', + feedPath: '/vagas.json', + }, + talents: { + title: 'Talentos', + headline: 'Talentos de backend', + lede: 'Pessoas desenvolvedoras backend que pediram para divulgar o perfil em backend-br/me-contrata, com nível, regime, modelo de trabalho e tecnologias.', + count: (count: number) => plural(count, 'perfil divulgado', 'perfis divulgados'), + listed: 'Atualizados mais recentemente primeiro', + updated: 'Atualizado', + post: 'Divulgar meu perfil', + postUrl: `${repositoryUrl('me-contrata')}/issues/new/choose`, + all: 'Ver todos os perfis no GitHub', + profile: 'Perfil no GitHub', + linkedin: 'LinkedIn', + github: 'GitHub', + portfolio: 'Portfólio', + contactOf: (name: string, channel: string) => `${channel} de ${name}`, + empty: + 'Nenhum perfil divulgado agora. Quem abre um perfil em backend-br/me-contrata pode marcar a opção de divulgação no formulário.', + feed: 'Perfis divulgados em JSON', + feedPath: '/talentos.json', }, projects: { title: 'Projetos open-source', diff --git a/src/content/talents.test.ts b/src/content/talents.test.ts new file mode 100644 index 0000000..a66214d --- /dev/null +++ b/src/content/talents.test.ts @@ -0,0 +1,91 @@ +import { describe, expect, it } from 'vitest' +import type { Issue, Label } from './jobs' +import { anchor, talents } from './talents' + +const LABELS: readonly Label[] = [ + { name: 'Remoto', description: 'Tipo de alocação.' }, + { name: 'Sênior', description: 'Nível de experiência.' }, + { name: 'PJ', description: 'Tipo de contratação.' }, + { name: 'Go', description: 'Linguagem de programação.' }, + { name: 'Stale', description: '[USO INTERNO] Candidatura que serão fechadas.' }, + { name: 'verificado', description: null }, +] + +function body(fields: Record): string { + return Object.entries({ + 'Nome completo': 'Maria Silva', + Cargo: 'Desenvolvedora Back-end', + Apresentação: 'Seis anos com APIs.', + Localização: 'Belo Horizonte - MG', + LinkedIn: 'https://www.linkedin.com/in/maria', + GitHub: 'https://github.com/maria', + Portfólio: '_No response_', + ...fields, + }) + .map(([heading, value]) => `### ${heading}\n\n${value}`) + .join('\n\n') +} + +function issue(number: number, labels: readonly string[], extra: Partial = {}): Issue { + return { + number, + title: 'Maria Silva - Back-end', + html_url: `https://github.com/backend-br/me-contrata/issues/${number}`, + created_at: '2026-11-01T00:00:00Z', + updated_at: `2026-11-0${number}T00:00:00Z`, + locked: false, + labels: labels.map((name) => ({ name })), + user: { login: 'maria', avatar_url: '' }, + body: body({}), + ...extra, + } +} + +const SHARED = ['verificado', 'divulgar-perfil'] + +describe('the shared talents', () => { + it('lists only verified profiles that opted in', () => { + const read = talents( + [issue(1, ['verificado']), issue(2, ['divulgar-perfil']), issue(3, [...SHARED, 'Sênior'])], + LABELS, + ) + + expect(read.map((talent) => talent.number)).toEqual([3]) + }) + + it('reads the facets from the labels and leaves the status labels out', () => { + const [talent] = talents([issue(1, [...SHARED, 'Sênior', 'PJ', 'Remoto', 'Go', 'Stale'])], LABELS) + + expect(talent?.level).toEqual(['Sênior']) + expect(talent?.contract).toEqual(['PJ']) + expect(talent?.modality).toEqual(['Remoto']) + expect(talent?.stack).toEqual(['Go']) + }) + + it('reads the form and keeps only profile links', () => { + const [talent] = talents( + [issue(1, SHARED, { body: body({ GitHub: 'javascript:alert(1)', Portfólio: 'https://maria.dev' }) })], + LABELS, + ) + + expect(talent).toMatchObject({ + name: 'Maria Silva', + role: 'Desenvolvedora Back-end', + location: 'Belo Horizonte - MG', + linkedin: 'https://www.linkedin.com/in/maria', + github: null, + portfolio: 'https://maria.dev', + url: 'https://github.com/backend-br/me-contrata/issues/1', + }) + }) + + it('puts the latest updated profiles first', () => { + const read = talents([issue(1, SHARED), issue(3, SHARED), issue(2, SHARED)], LABELS) + + expect(read.map((talent) => talent.number)).toEqual([3, 2, 1]) + }) + + it('anchors each profile by its issue number', () => { + expect(anchor(42)).toBe('perfil-42') + }) +}) diff --git a/src/content/talents.ts b/src/content/talents.ts new file mode 100644 index 0000000..3986172 --- /dev/null +++ b/src/content/talents.ts @@ -0,0 +1,105 @@ +import { avatarOf, repositoryUrl } from './catalog' +import { type Facet, facetOf, type Issue, type Label } from './jobs' + +export const REPOSITORY = 'me-contrata' + +export const SHARED: readonly string[] = ['verificado', 'divulgar-perfil'] + +const STATUS: ReadonlySet = new Set([ + 'verificado', + 'em-triagem', + 'triagem-recusada', + 'revisado', + 'divulgar-perfil', +]) + +const HEADINGS = { + name: 'Nome completo', + role: 'Cargo', + about: 'Apresentação', + location: 'Localização', + linkedin: 'LinkedIn', + github: 'GitHub', + portfolio: 'Portfólio', +} as const + +const LINKEDIN = /^https:\/\/(www\.)?linkedin\.com\/in\/[\w%-]+\/?$/i + +const GITHUB = /^https:\/\/github\.com\/([a-z\d](?:[a-z\d-]{0,38}))\/?$/i + +const PORTFOLIO = /^https:\/\/[^\s<>"']+$/i + +export interface Talent { + readonly number: number + readonly name: string + readonly role: string + readonly about: string + readonly location: string + readonly url: string + readonly updated: string + readonly modality: readonly string[] + readonly level: readonly string[] + readonly contract: readonly string[] + readonly stack: readonly string[] + readonly linkedin: string | null + readonly github: string | null + readonly portfolio: string | null + readonly avatar: string +} + +export function sections(body: string): Record { + const found: Record = {} + for (const section of body + .replace(/\r\n/g, '\n') + .split(/^###\s+/m) + .slice(1)) { + const end = section.indexOf('\n') + const heading = (end === -1 ? section : section.slice(0, end)).trim() + const value = end === -1 ? '' : section.slice(end + 1).trim() + found[heading] = value === '_No response_' ? '' : value + } + return found +} + +function link(value: string | undefined, pattern: RegExp): string | null { + const trimmed = (value ?? '').trim() + return pattern.test(trimmed) ? trimmed : null +} + +export function talents(issues: readonly Issue[], labels: readonly Label[]): Talent[] { + const facets = new Map(labels.map((label) => [label.name, facetOf(label.description)])) + for (const name of STATUS) { + facets.set(name, null) + } + return issues + .filter((issue) => issue.pull_request === undefined && !issue.locked) + .filter((issue) => SHARED.every((name) => issue.labels.some((label) => label.name === name))) + .map((issue) => { + const fields = sections(issue.body ?? '') + const names = (facet: Facet): string[] => + issue.labels.map((label) => label.name).filter((name) => (facets.has(name) ? facets.get(name) : null) === facet) + const github = link(fields[HEADINGS.github], GITHUB) + return { + number: issue.number, + name: (fields[HEADINGS.name] ?? '').trim() || issue.title.trim(), + role: (fields[HEADINGS.role] ?? '').trim(), + about: (fields[HEADINGS.about] ?? '').trim(), + location: (fields[HEADINGS.location] ?? '').trim(), + url: `${repositoryUrl(REPOSITORY)}/issues/${issue.number}`, + updated: issue.updated_at ?? issue.created_at, + modality: names('modality'), + level: names('level'), + contract: names('contract'), + stack: names('stack'), + linkedin: link(fields[HEADINGS.linkedin], LINKEDIN), + github, + portfolio: link(fields[HEADINGS.portfolio], PORTFOLIO), + avatar: avatarOf(github ? (GITHUB.exec(github)?.[1] ?? '') : (issue.user?.login ?? '')), + } + }) + .sort((a, b) => b.updated.localeCompare(a.updated) || a.number - b.number) +} + +export function anchor(number: number): string { + return `perfil-${number}` +} diff --git a/src/pages/llms.txt.ts b/src/pages/llms.txt.ts index 2858971..adb27e4 100644 --- a/src/pages/llms.txt.ts +++ b/src/pages/llms.txt.ts @@ -16,11 +16,14 @@ export const GET: APIRoute = async ({ site, url }) => { '', `- [${TEXT.challenges.headline}](${page('/desafios/')}): ${TEXT.challenges.lede}`, `- [${TEXT.jobs.headline}](${page('/vagas/')}): ${TEXT.jobs.lede}`, + `- [${TEXT.talents.headline}](${page('/talentos/')}): ${TEXT.talents.lede}`, `- [${TEXT.projects.headline}](${page('/projetos/')}): ${TEXT.projects.lede}`, '', '## Dados', '', `- [${TEXT.home.response.label}](${page(TEXT.home.response.path)}): JSON com ${Object.values(TEXT.home.response.keys).join(', ')}.`, + `- [${TEXT.jobs.feed}](${page(TEXT.jobs.feedPath)}): JSON com as vagas abertas.`, + `- [${TEXT.talents.feed}](${page(TEXT.talents.feedPath)}): JSON com os perfis divulgados.`, '', '## Repositórios', '', diff --git a/src/pages/sitemap.xml.ts b/src/pages/sitemap.xml.ts index 016f287..ea0d5b1 100644 --- a/src/pages/sitemap.xml.ts +++ b/src/pages/sitemap.xml.ts @@ -1,16 +1,18 @@ import type { APIRoute } from 'astro' -import { challenges, jobs } from '../content' +import { challenges, jobs, talents } from '../content' export const GET: APIRoute = async ({ site, url }) => { const origin = site ?? new URL(url.origin) const openings = await jobs() const [newest] = openings + const [latest] = await talents() const entries = [ { path: '/' }, { path: '/desafios/' }, ...(await challenges()).map((challenge) => ({ path: `/desafios/${challenge.data.slug}/` })), { path: '/vagas/', changed: newest?.data.opened.slice(0, 10) }, ...openings.map((job) => ({ path: `/vagas/${job.data.number}/`, changed: job.data.opened.slice(0, 10) })), + { path: '/talentos/', changed: latest?.data.updated.slice(0, 10) }, { path: '/projetos/' }, ] const document = [ diff --git a/src/pages/talentos.astro b/src/pages/talentos.astro new file mode 100644 index 0000000..496af09 --- /dev/null +++ b/src/pages/talentos.astro @@ -0,0 +1,76 @@ +--- +import Icon from '../components/Icon.astro' +import PageCover from '../components/PageCover.astro' +import TalentItem from '../components/TalentItem.astro' +import { talents as allTalents } from '../content' +import { repositoryUrl } from '../content/catalog' +import { MAIN_ID, TEXT } from '../content/site' +import { breadcrumbs, collection } from '../content/structured-data' +import { anchor, REPOSITORY } from '../content/talents' +import BaseLayout from '../layouts/BaseLayout.astro' + +const talents = await allTalents() +const labels = TEXT.talents +const origin = Astro.site ?? Astro.url.origin +const issues = `${repositoryUrl(REPOSITORY)}/issues` +const page = { path: '/talentos/', name: labels.headline, description: labels.lede } +--- + + 0 + ? [ + collection( + origin, + page, + talents.map((talent) => ({ + name: talent.data.name, + url: new URL(`${page.path}#${anchor(talent.data.number)}`, origin).href, + })), + ), + ] + : []), + ], + }} +> +
    + +
      +
    • {labels.count(talents.length)}
    • +
    + +
    +
    + { + talents.length > 0 ? ( +
    +

    + {labels.listed} +

    +
      + {talents.map((talent) => ( + + ))} +
    +
    + ) : ( +

    {labels.empty}

    + ) + } +
    +
    +
    diff --git a/src/pages/talentos.json.ts b/src/pages/talentos.json.ts new file mode 100644 index 0000000..c24b5cc --- /dev/null +++ b/src/pages/talentos.json.ts @@ -0,0 +1,26 @@ +import type { APIRoute } from 'astro' +import { talents } from '../content' +import { anchor } from '../content/talents' + +export const GET: APIRoute = async ({ site, url }) => { + const origin = site ?? new URL(url.origin) + const body = (await talents()).map(({ data }) => ({ + numero: data.number, + nome: data.name, + cargo: data.role, + localizacao: data.location, + nivel: data.level, + regime: data.contract, + modelo: data.modality, + tecnologias: data.stack, + linkedin: data.linkedin, + github: data.github, + portfolio: data.portfolio, + perfil: data.url, + pagina: new URL(`/talentos/#${anchor(data.number)}`, origin).href, + atualizado: data.updated, + })) + return new Response(`${JSON.stringify(body, null, 2)}\n`, { + headers: { 'content-type': 'application/json; charset=utf-8' }, + }) +} diff --git a/src/pages/vagas.json.ts b/src/pages/vagas.json.ts new file mode 100644 index 0000000..76023df --- /dev/null +++ b/src/pages/vagas.json.ts @@ -0,0 +1,21 @@ +import type { APIRoute } from 'astro' +import { jobs } from '../content' + +export const GET: APIRoute = async ({ site, url }) => { + const origin = site ?? new URL(url.origin) + const body = (await jobs()).map(({ data }) => ({ + numero: data.number, + titulo: data.title, + nivel: data.level, + regime: data.contract, + modelo: data.modality, + tecnologias: data.stack, + autor: data.author, + issue: data.url, + pagina: new URL(`/vagas/${data.number}/`, origin).href, + aberta: data.opened, + })) + return new Response(`${JSON.stringify(body, null, 2)}\n`, { + headers: { 'content-type': 'application/json; charset=utf-8' }, + }) +} diff --git a/src/styles/theme.css b/src/styles/theme.css index d18f384..cf29739 100644 --- a/src/styles/theme.css +++ b/src/styles/theme.css @@ -1163,6 +1163,13 @@ .bb-card[hidden] { display: none; } +.bb-card:target { + scroll-margin-block-start: 6rem; + border-color: var(--color-mark); + box-shadow: + inset 0 0 0 1px var(--color-mark), + var(--shadow-card); +} .bb-card__meta { display: flex; align-items: center;