Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

95
Views
Get a list of all pages from `docs` directory?

I am trying to implement a "Get random page" link in Docusaurus. For that I would like to get a list of all available pages/page ids+path from the docs/ directory.

Does Docusaurus have a way to do this programmatically?

about 4 years ago · Juan Pablo Isaza
1 answers
Answer question

0

I did not find any native or plugin way to achieve this... Here is how I you do it:


PART 1

Once you built you docusaurus website, will be generated a sitemap.xml file. This file is locate at the root directory of your site and contains all of the url of the doc pages.

Create a js function that read this file and parse it. Then get a random url open it.

TIP 1: https://www.w3schools.com/xml/xml_parser.asp

TIP 2: https://www.w3schools.com/jsref/met_win_open.asp


PART 2

Then, you can embed your JavaScript using the mdx function of docusaurus.

TIP: How can I add custom scripts in index.html's head part in Docusaurus V2?

about 4 years ago · Juan Pablo Isaza Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!