fern icon indicating copy to clipboard operation
fern copied to clipboard

fix(docs): interpret slash docs slugs as parent path

Open shubhamsinnh opened this issue 6 months ago • 1 comments

Summary

  • Interpret exact slug: / in docs.yml as an empty child segment so nested pages resolve to the parent path.
  • Preserve all other explicit docs.yml slugs unchanged.
  • Add resolver/unit coverage and a CLI changelog entry for slash-only docs.yml slugs.

Root Cause

Configured slugs from docs.yml were passed directly into SlugGenerator.apply, so a nested page with slug: / could be interpreted as a literal slash segment instead of the parent path. This could produce incorrect preview routing behavior for pages intended to live at the section root.

Validation

  • pnpm turbo run compile --filter @fern-api/docs-resolver
  • node_modules\.bin\vitest.cmd --run packages/cli/docs-resolver/src/__test__/absolute-slug-validation.test.ts packages/cli/docs-resolver/src/utils/__test__/getDocsYmlSlug.test.ts --config packages/cli/docs-resolver/vitest.config.ts
  • node_modules\.bin\tsc.cmd --noEmit -p packages/cli/docs-resolver/tsconfig.json
  • git diff --check

Fixes #5634

shubhamsinnh avatar May 23 '26 17:05 shubhamsinnh

This PR normalizes configured docs.yml slugs before composing navigation paths, so slug: / is treated as an empty child segment and nested pages resolve to their parent path. The reported case is covered by a resolver regression fixture under the Learn section, plus a small unit test for the slug normalizer.

Validated locally with:

  • pnpm turbo run compile --filter @fern-api/docs-resolver
  • pnpm exec vitest --run packages/cli/docs-resolver/src/__test__/absolute-slug-validation.test.ts packages/cli/docs-resolver/src/utils/__test__/getDocsYmlSlug.test.ts --config packages/cli/docs-resolver/vitest.config.ts

Small GitHub workflow note: the PR was created from shubhamsinnh:codex/docs-slash-slug, but setting shubhamsinnh as assignee failed because this token/account does not have permission to update assignees on fern-api/fern.

shubhamsinnh avatar May 23 '26 17:05 shubhamsinnh

This PR is stale because it has been open 25 days with no activity. Remove stale label or comment or this will be closed in 5 days.

github-actions[bot] avatar Jun 21 '26 02:06 github-actions[bot]

This PR was closed because it has been inactive for 5 days after being marked stale.

github-actions[bot] avatar Jun 27 '26 02:06 github-actions[bot]