Skip to content

Commit 4e48dc0

Browse files
committed
Fix crawler skipping downloading components
1 parent 3fd4ff1 commit 4e48dc0

File tree

1 file changed

+7
-2
lines changed

1 file changed

+7
-2
lines changed

index.mjs

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -240,7 +240,10 @@ function replaceTokens(html) {
240240
async function processComponent(url, component) {
241241
const title = component.name
242242
const filename = cleanFilename(title)
243-
const path = `${url}/${filename}`
243+
244+
// Remove the rootUrl from the url to get the local path
245+
const localOutput = url.replace('https://tailwindui.com', '')
246+
const path = `${localOutput}/${filename}`
244247

245248
// output snippets by language
246249
component.snippets.forEach((snippet) => {
@@ -439,7 +442,9 @@ function debugLog(...args) {
439442
debugLog(`📣 ${i + 1}: ${url}`)
440443
if (!url || !url.match(/\/components\//)) continue
441444
// check if component is in list of components to save
442-
const component = url.split('/')[2]
445+
// Example URL: https://tailwindui.com/components/application-ui/navigation/navbars
446+
// Parse out "application-ui" | "marketing" | "ecommerce" from the URL to ensure we only download the components we want
447+
const component = url.split('/')[4]
443448
if (
444449
component &&
445450
components[0] !== 'all' &&

0 commit comments

Comments
 (0)