feat(ast): strip /index suffix from path when index files are used#756
Closed
avivkeller wants to merge 2 commits intomainfrom
Closed
feat(ast): strip /index suffix from path when index files are used#756avivkeller wants to merge 2 commits intomainfrom
avivkeller wants to merge 2 commits intomainfrom
Conversation
Index files (e.g. index.md) should resolve to their parent directory path rather than /index. For example: - /index.md -> path: / - /api/index.md -> path: /api - /api/fs.md -> path: /api/fs (unchanged)
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #756 +/- ##
==========================================
- Coverage 78.42% 78.40% -0.03%
==========================================
Files 157 158 +1
Lines 13959 14035 +76
Branches 1152 1167 +15
==========================================
+ Hits 10948 11004 +56
- Misses 3006 3026 +20
Partials 5 5 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
|
| File | Base | Head | Diff |
|---|---|---|---|
index.html |
17.98 KB | 17.86 KB | -125.00 B (-0.68%) |
llms-txt Generator
| File | Base | Head | Diff |
|---|---|---|---|
llms.txt |
13.75 KB | 13.75 KB | -5.00 B (-0.04%) |
orama-db Generator
| File | Base | Head | Diff |
|---|---|---|---|
orama-db.json |
8.28 MB | 8.28 MB | -10.00 B (-0.00%) |
web Generator
| File | Base | Head | Diff |
|---|---|---|---|
addons.html |
262.56 KB | 262.55 KB | -8.00 B (-0.00%) |
assert.html |
330.00 KB | 329.99 KB | -8.00 B (-0.00%) |
async_context.html |
187.57 KB | 187.57 KB | -8.00 B (-0.00%) |
async_hooks.html |
159.71 KB | 159.70 KB | -8.00 B (-0.00%) |
buffer.html |
905.72 KB | 905.71 KB | -8.00 B (-0.00%) |
child_process.html |
381.70 KB | 381.69 KB | -8.00 B (-0.00%) |
cli.html |
495.11 KB | 495.10 KB | -8.00 B (-0.00%) |
cluster.html |
196.30 KB | 196.29 KB | -8.00 B (-0.00%) |
console.html |
146.77 KB | 146.76 KB | -8.00 B (-0.01%) |
crypto.html |
1.09 MB | 1.09 MB | -8.00 B (-0.00%) |
debugger.html |
54.22 KB | 54.21 KB | -8.00 B (-0.01%) |
deprecations.html |
505.31 KB | 505.30 KB | -8.00 B (-0.00%) |
dgram.html |
194.37 KB | 194.36 KB | -8.00 B (-0.00%) |
diagnostics_channel.html |
303.42 KB | 303.41 KB | -8.00 B (-0.00%) |
dns.html |
295.81 KB | 295.80 KB | -8.00 B (-0.00%) |
documentation.html |
38.04 KB | 38.03 KB | -8.00 B (-0.02%) |
domain.html |
105.10 KB | 105.09 KB | -8.00 B (-0.01%) |
embedding.html |
59.42 KB | 59.42 KB | -8.00 B (-0.01%) |
environment_variables.html |
44.04 KB | 44.03 KB | -8.00 B (-0.02%) |
errors.html |
461.17 KB | 461.17 KB | -8.00 B (-0.00%) |
esm.html |
155.33 KB | 155.32 KB | -8.00 B (-0.01%) |
events.html |
455.27 KB | 455.26 KB | -8.00 B (-0.00%) |
fs.html |
1.43 MB | 1.43 MB | -8.00 B (-0.00%) |
globals.html |
230.37 KB | 230.36 KB | -8.00 B (-0.00%) |
http.html |
746.16 KB | 746.16 KB | -8.00 B (-0.00%) |
http2.html |
768.59 KB | 768.58 KB | -8.00 B (-0.00%) |
https.html |
150.35 KB | 150.34 KB | -8.00 B (-0.01%) |
inspector.html |
171.38 KB | 171.37 KB | -8.00 B (-0.00%) |
intl.html |
58.14 KB | 58.13 KB | -8.00 B (-0.01%) |
module.html |
326.66 KB | 326.65 KB | -8.00 B (-0.00%) |
modules.html |
178.73 KB | 178.72 KB | -8.00 B (-0.00%) |
n-api.html |
807.25 KB | 807.24 KB | -8.00 B (-0.00%) |
net.html |
382.29 KB | 382.28 KB | -8.00 B (-0.00%) |
os.html |
142.73 KB | 142.72 KB | -8.00 B (-0.01%) |
packages.html |
154.65 KB | 154.64 KB | -8.00 B (-0.01%) |
path.html |
139.26 KB | 139.25 KB | -8.00 B (-0.01%) |
perf_hooks.html |
381.49 KB | 381.48 KB | -8.00 B (-0.00%) |
permissions.html |
55.14 KB | 55.13 KB | -8.00 B (-0.01%) |
process.html |
676.15 KB | 676.14 KB | -8.00 B (-0.00%) |
punycode.html |
63.19 KB | 63.18 KB | -8.00 B (-0.01%) |
querystring.html |
63.85 KB | 63.84 KB | -8.00 B (-0.01%) |
quic.html |
358.97 KB | 358.97 KB | -8.00 B (-0.00%) |
readline.html |
252.17 KB | 252.17 KB | -8.00 B (-0.00%) |
repl.html |
183.30 KB | 183.29 KB | -8.00 B (-0.00%) |
report.html |
175.92 KB | 175.91 KB | -8.00 B (-0.00%) |
single-executable-applications.html |
106.94 KB | 106.94 KB | -8.00 B (-0.01%) |
sqlite.html |
268.08 KB | 268.07 KB | -8.00 B (-0.00%) |
stream.html |
855.30 KB | 855.30 KB | -8.00 B (-0.00%) |
stream_iter.html |
309.03 KB | 309.02 KB | -8.00 B (-0.00%) |
string_decoder.html |
55.39 KB | 55.38 KB | -8.00 B (-0.01%) |
synopsis.html |
42.67 KB | 42.66 KB | -8.00 B (-0.02%) |
test.html |
766.71 KB | 766.71 KB | -8.00 B (-0.00%) |
timers.html |
133.50 KB | 133.50 KB | -8.00 B (-0.01%) |
tls.html |
373.79 KB | 373.78 KB | -8.00 B (-0.00%) |
tracing.html |
84.16 KB | 84.15 KB | -8.00 B (-0.01%) |
tty.html |
95.29 KB | 95.28 KB | -8.00 B (-0.01%) |
typescript.html |
53.47 KB | 53.46 KB | -8.00 B (-0.01%) |
url.html |
347.67 KB | 347.67 KB | -8.00 B (-0.00%) |
util.html |
691.89 KB | 691.88 KB | -8.00 B (-0.00%) |
v8.html |
321.09 KB | 321.08 KB | -8.00 B (-0.00%) |
vm.html |
370.80 KB | 370.79 KB | -8.00 B (-0.00%) |
wasi.html |
69.37 KB | 69.36 KB | -8.00 B (-0.01%) |
webcrypto.html |
522.00 KB | 521.99 KB | -8.00 B (-0.00%) |
webstreams.html |
357.21 KB | 357.20 KB | -8.00 B (-0.00%) |
worker_threads.html |
365.47 KB | 365.46 KB | -8.00 B (-0.00%) |
zlib.html |
290.24 KB | 290.23 KB | -8.00 B (-0.00%) |
zlib_iter.html |
88.06 KB | 88.05 KB | -8.00 B (-0.01%) |
index.js |
5.73 KB | 5.73 KB | -5.00 B (-0.09%) |
When path is '/' (set by the ast generator for index.md files), the derived api and basename values were empty strings. This broke all downstream generators that rely on api/basename as file identifiers (e.g. legacy-json writing index.json, legacy-json-all skipping the index section, legacy-html writing index.html, etc.). Add an 'index' fallback so that path='/' correctly maps to api='index' and basename='index', matching the pre-existing behavior for those identifiers.
Member
Author
|
(This was a test of a Cloud Agent) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Description
When parsing markdown files, the
pathproperty on the resulting AST node was including/indexfor index files (e.g.index.md→/index,api/index.md→/api/index). This changes the behavior so index files resolve to their parent directory path:index.md→path: /api/index.md→path: /apiapi/fs.md→path: /api/fs(unchanged)The fix is in
src/generators/ast/generate.mjsin theprocessChunkfunction, where therelativePathis computed from the file path relative to the glob parent.Additionally,
src/generators/metadata/utils/parse.mjsis updated so that theapiandbasenameidentifiers (derived frompath) fall back to'index'whenpath === '/'. This preserves correct behavior for all downstream generators that useapi/basenameas file identifiers (e.g.legacy-jsonwritingindex.json,legacy-json-allskipping the index section,legacy-htmlwritingindex.html,webgenerator usingbasename.htmlfor navigation).Validation
A new test file
src/generators/ast/__tests__/generate.test.mjswas added with 5 test cases covering:/index.md→/)sub/index.md→/sub)indexes.md, unchanged)All 408 tests in the test suite pass.
Related Issues
Check List
node --run testand all tests passed.node --run format&node --run lint.