Skip to content

Commit 1982b01

Browse files
authored
Merge pull request #546 from brazilian-utils/claude/docs7-site
docs(site): SEO and agent readiness for brazilian-utils.com.br
2 parents c20a485 + f8e2993 commit 1982b01

29 files changed

Lines changed: 3153 additions & 18 deletions

‎.github/workflows/check.yml‎

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -56,6 +56,10 @@ jobs:
5656
- name: Check llms.txt/llms-full.txt are up to date
5757
run: npm run build:llms && git diff --exit-code -- docs/llms.txt docs/llms-full.txt
5858

59+
- name: Check the docs site shells and sitemap are up to date
60+
# --intent-to-add makes a shell written for a new page show up in the diff as well.
61+
run: npm run build:site && git add --intent-to-add docs && git diff --exit-code -- docs/sitemap.xml 'docs/*.html' 'docs/pt-br/*.html'
62+
5963
- name: Check the VEX statements against the suppressed advisories
6064
run: npm run check:vex
6165

‎CONTRIBUTING.md‎

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,7 @@ and is invoked through the `npm` scripts below, so you don't need to install any
4343
| `npm run build` | Builds the library for publishing with `vp pack` (also runs attw and publint over the built output). |
4444
| `npm run build:data` | Regenerates the datasets under `src/_internals/constants` from the IBGE/CONCLA sources (`scripts/data.ts`); run by the scheduled `Update datasets` workflow. |
4545
| `npm run build:llms` | Regenerates `docs/llms.txt` and `docs/llms-full.txt` from the docs (`scripts/llms.ts`); CI fails if they're out of date. |
46+
| `npm run build:site` | Regenerates the per-page copies of `docs/index.html`, `docs/404.html` and `docs/sitemap.xml` from the sidebars (`scripts/site.ts`); CI fails if they're out of date. |
4647
| `npm run check:dependencies` | Fails if `package.json` declares any runtime `dependencies` (this package ships zero by design). |
4748
| `npm run check:tree-shaking` | Builds nothing; measures the single-import size of every export against `dist` (`scripts/tree-shaking.ts`). Run it after `npm run build` when you change a dataset, and update the bundle-size table in `docs/getting-started.md` / `docs/pt-br/getting-started.md`. |
4849
| `npm run check:duplication` | Runs [jscpd](https://jscpd.dev) over `src` and `scripts`; any copy-pasted block of 5+ lines / 50+ tokens fails. |
@@ -321,6 +322,33 @@ Every utility must keep working across all the runtimes this library targets:
321322
Avoid Node-specific APIs unless they are polyfilled/guarded, and prefer standard, widely available
322323
JavaScript/TypeScript features.
323324

325+
## Documentation site
326+
327+
`docs/` is the source of [brazilian-utils.com.br](https://brazilian-utils.com.br), served by GitHub
328+
Pages with [docsify](https://docsify.js.org): `docs/index.html` renders the Markdown in the
329+
browser, with `_sidebar.md`, `_navbar.md` and `_coverpage.md` as its navigation.
330+
331+
- docsify runs in history mode, so every page is a real URL (`/getting-started`,
332+
`/pt-br/utilities`) that search engines index on its own. GitHub Pages serves each one from a
333+
copy of `index.html` next to the page (`getting-started.html`) that carries the page's own
334+
title, description, canonical URL and hreflang pair, and `npm run build:site`
335+
(`scripts/site.ts`) writes those copies, `404.html` and `sitemap.xml` from the sidebars and the
336+
pages' front matter. The Check workflow fails when they are stale, so run it after editing
337+
`index.html`, a sidebar or a page's front matter. Links from the hash-router era
338+
(`/#/getting-started?id=usage`) are rewritten on load, so nothing out there breaks.
339+
- Every page starts with a front matter block with a quoted `title` and `description` (and
340+
`keywords`), and has no `#` heading of its own: the plugin in `docs/index.html` turns the title
341+
into the page's heading and the block feeds the page's metadata (a small wrapper there hands
342+
the search plugin the same view, so the block never shows up in search results). Scripts read
343+
the block through `scripts/front-matter.ts`.
344+
- `scripts/llms.ts` reads the title back out of the front matter, so `docs/llms.txt` and
345+
`docs/llms-full.txt` keep their headings; run `npm run build:llms` after editing a page.
346+
- Context7 indexes `docs/` as `/brazilian-utils/javascript`; `context7.json` says what it reads,
347+
and `.github/workflows/context7.yml` asks for a refresh when the docs change on `main`.
348+
349+
To preview the site, point a static file server that resolves `/page` to `page.html`, the way
350+
GitHub Pages does, at `docs/`.
351+
324352
## Commit messages
325353

326354
This project follows [Conventional Commits](https://www.conventionalcommits.org/). Examples:

‎README.md‎

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33

44
<p>Utils library for Brazilian-specific businesses.</p>
55

6-
[📖 Documentation](https://brazilian-utils.com.br/#/getting-started)
6+
[📖 Documentation](https://brazilian-utils.com.br/getting-started)
77

88
[![npm version](https://img.shields.io/npm/v/@brazilian-utils/brazilian-utils.svg)](https://www.npmjs.com/package/@brazilian-utils/brazilian-utils) [![Downloads per month](https://img.shields.io/npm/dm/@brazilian-utils/brazilian-utils.svg)](https://www.npmjs.com/package/@brazilian-utils/brazilian-utils) [![License: MIT](https://img.shields.io/github/license/brazilian-utils/javascript.svg)](https://github.com/brazilian-utils/javascript/blob/main/LICENSE)
99
[![Zero dependencies](https://img.shields.io/badge/dependencies-0-brightgreen)](https://github.com/brazilian-utils/javascript/blob/main/CONTRIBUTING.md#zero-runtime-dependencies) [![TypeScript](https://img.shields.io/npm/types/@brazilian-utils/brazilian-utils)](https://www.npmjs.com/package/@brazilian-utils/brazilian-utils)
@@ -95,9 +95,10 @@ import { isValidCpf } from "@brazilian-utils/brazilian-utils";
9595
isValidCpf("1232454233345"); // false
9696
```
9797

98-
You can check a list of utilities [by clicking here](https://brazilian-utils.com.br/#/utilities).
98+
You can check a list of utilities [by clicking here](https://brazilian-utils.com.br/utilities).
9999

100-
- The package is tree-shakeable. Every util is also available as its own subpath (e.g. `@brazilian-utils/brazilian-utils/get-cities`) so you can lazy-load the few heavy ones. See [Bundle size](https://brazilian-utils.com.br/#/getting-started?id=bundle-size).
100+
- Using an AI coding assistant? The docs are indexed on Context7 as [`/brazilian-utils/javascript`](https://context7.com/brazilian-utils/javascript), and [llms.txt](https://brazilian-utils.com.br/llms.txt) lists every util for other tools. See [AI assistants](https://brazilian-utils.com.br/getting-started?id=ai-assistants).
101+
- The package is tree-shakeable. Every util is also available as its own subpath (e.g. `@brazilian-utils/brazilian-utils/get-cities`) so you can lazy-load the few heavy ones. See [Bundle size](https://brazilian-utils.com.br/getting-started?id=bundle-size).
101102

102103
## Development
103104

@@ -112,7 +113,7 @@ npm test
112113
npm run build
113114
```
114115

115-
[CONTRIBUTING.md](CONTRIBUTING.md) lists every script and the checks a pull request goes through.
116+
[CONTRIBUTING.md](https://github.com/brazilian-utils/javascript/blob/main/CONTRIBUTING.md) lists every script and the checks a pull request goes through.
116117

117118
Release notes are published through [GitHub Releases](https://github.com/brazilian-utils/javascript/releases).
118119

‎SUPPORT.md‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
Thanks for using Brazilian Utils! Here's where to get help, depending on what you need:
44

55
- **Documentation**: the full list of utilities, usage examples and migration guides live at
6-
[brazilian-utils.com.br](https://brazilian-utils.com.br/#/getting-started).
6+
[brazilian-utils.com.br](https://brazilian-utils.com.br/getting-started).
77
- **Questions & usage help**: open a [GitHub Discussion](https://github.com/brazilian-utils/javascript/discussions).
88
This is the best place for "how do I...?" questions or to propose an idea before it becomes an issue.
99
- **Bugs & feature requests**: use our [issue templates](https://github.com/brazilian-utils/javascript/issues/new/choose)

‎context7.json‎

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,8 @@
1818
"_navbar.md",
1919
"_coverpage.md",
2020
"llms.txt",
21-
"llms-full.txt"
21+
"llms-full.txt",
22+
"robots.txt"
2223
],
2324
"previousVersions": [
2425
{

0 commit comments

Comments
 (0)