Content Path Utilities (utils/content-paths.ts)

llms-txt-hub · files, Files / Storage, node, path, utils, monorepo, filesystem

Helper functions to resolve monorepo content directories and file paths for resources and websites.

// Source: https://github.com/mperkins0155/llms-txt-hub | License: MIT | Copyright 2025 David Dias
// Provided via justclaw.it.com; keep this notice with the code.
import path from 'node:path'
import { fileURLToPath } from 'node:url'

// Get the monorepo root path
function getMonorepoRoot(): string {
  // Start from the current file's directory
  let currentDir = path.dirname(fileURLToPath(import.meta.url))

  // Go up until we find the monorepo root (where package.json exists)
  while (!path.basename(currentDir).includes('llms-txt-hub')) {
    currentDir = path.dirname(currentDir)
  }

  return currentDir
}

const MONOREPO_ROOT = getMonorepoRoot()

export function getContentPath(contentType: 'resources' | 'websites'): string {
  return path.join(MONOREPO_ROOT, 'content', contentType)
}

e

... (truncated -- full source via MCP)

See the full source, get the GitHub permalink, and search 40K more like it.

Get a free API key