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

[Docs] Migrate error messages to MDX and App Router #52038

Merged
merged 32 commits into from
Jul 5, 2023
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
32 commits
Select commit Hold shift + click to select a range
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
Prev Previous commit
Next Next commit
debug
  • Loading branch information
Delba de Oliveira committed Jul 3, 2023
commit 7415377bb7aefbd48ea85bfa4348765dcfc689ca
2 changes: 1 addition & 1 deletion .github/actions/validate-docs-links/lib/index.js

Large diffs are not rendered by default.

26 changes: 14 additions & 12 deletions .github/actions/validate-docs-links/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -150,29 +150,30 @@ const markdownProcessor = unified()
}
})

// Github APIs returns `errors/*` and `docs/*` paths
function normalizePath(filePath: string): string {
if (filePath.startsWith('.' + ERRORS_PATH)) {
if (filePath.startsWith(ERRORS_PATH.substring(1))) {
return (
filePath
// Remap repository file path to the next-site url path
// e.g. `./errors/example.mdx` -> `/docs/messages/example`
.replace('.' + ERRORS_PATH, DOCS_PATH + 'messages/')
// e.g. `errors/example.mdx` -> `/docs/messages/example`
.replace(ERRORS_PATH.substring(1), DOCS_PATH + 'messages/')
.replace('.mdx', '')
)
}

return (
// Remap repository file path to the next-site url path without `./docs/`
// e.g. `./docs/01-api/getting-started/index.mdx` -> `api/getting-started`
path
// We remove `./docs/` to normalize paths between regular links
// Remap repository file path to the next-site url path without `/docs/`
// e.g. `docs/01-api/getting-started/index.mdx` -> `api/getting-started`
filePath
// We remove `/docs/` to normalize paths between regular links
// e.g. `/docs/api/example` and related/source links e.g `api/example`
// TODO:
// - Fix `next-site` to handle full paths for related/source links
// - Update doc files to use full paths for related/source links
// - Remove this workaround
.relative('.' + DOCS_PATH, filePath)
// Remove prefixed numbers used for ordering from the path
.replace(DOCS_PATH, '')
// Remove prefix numbers used for ordering
.replace(/(\d\d-)/g, '')
.replace('.mdx', '')
.replace('/index', '')
Expand Down Expand Up @@ -210,16 +211,17 @@ async function prepareDocumentMapEntry(
}

// Checks if the links point to existing documents

function validateInternalLink(errors: Errors, href: string): void {
// /docs/api/example#heading -> ["api/example", "heading""]
const [link, hash] = href.replace(DOCS_PATH, '').split('#')

let foundPage

if (link.startsWith('messages/')) {
// check if error page exists, key is the full url path
// e.g. `/docs/messages/example`
console.log('link', link)
foundPage = documentMap.get(DOCS_PATH + link)
// e.g. `docs/messages/example`
foundPage = documentMap.get(DOCS_PATH.substring(1) + link)
} else {
// check if doc page exists, key is the url path without `/docs/`
// e.g. `api/example`
Expand Down
Loading