Menu

1 / 2

375 URLs in our sitemap come from seven sources, and the 132 biggest are found by reading a directory off disk

DEV Community: typescript·Daniel Pertu·about 23 hours ago
#zNYhhl8P
#devtotypescript#devto#dev#sitemap#fullscreen
Reading 0:00
15s threshold

CogniPrep's app/sitemap.ts returned 375 URLs this morning. Grouping them by where the code got them from:

Source URLs

readdirSync(app/employers) 132

blogPostMeta 99

ALL_PROVIDERS 56

CHEATING_GUIDES 56

AC_GUIDES 7

TEST_TYPES 5

INTERVIEW_GUIDES 5

typed out by hand 15

Six of those are TypeScript registries that other parts of the app also read, which is the arrangement you want: a provider that exists has a page, a search entry, a landing card and a sitemap row, all from one array, and the tests assert that parity. The 15 hand-written entries are the top-level pages.

The interesting one is the first row, because it is the only group the code discovers rather than reads:

const employersDir = join ( process . cwd (), ' app ' , ' employers ' ); const employerSlugs = readdirSync ( employersDir , { withFileTypes : true }) . filter (( entry ) => entry . isDirectory ()) . map (( entry ) => entry .…

Continue reading — create a free account

Join HashtagPLUS to read full articles, follow hashtags, vote, and join the conversation.