MCPcopy
hub / github.com/QwikDev/qwik / createFileId

Function createFileId

packages/qwik-city/src/utils/fs.ts:100–133  ·  view source on GitHub ↗
(
  routesDir: string,
  fsPath: string,
  explicitFileType?: 'Route' | 'Plugin' | 'ServiceWorker'
)

Source from the content-addressed store, hash-verified

98 * `Layout` files are named based on their path (eg. /routes/about/menu.md => AboutMenu)
99 */
100export function createFileId(
101 routesDir: string,
102 fsPath: string,
103 explicitFileType?: 'Route' | 'Plugin' | 'ServiceWorker'
104) {
105 const ids: string[] = [];
106
107 for (let i = 0; i < 25; i++) {
108 let baseName = removeExtension(basename(fsPath));
109
110 baseName = baseName.replace(/[\W_]+/g, '');
111 if (baseName === '') {
112 baseName = 'Q' + i;
113 } else if (!isNaN(baseName.charAt(0) as any)) {
114 baseName = 'Q' + baseName;
115 }
116 ids.push(toTitleCase(baseName));
117
118 fsPath = normalizePath(dirname(fsPath));
119
120 if (fsPath === routesDir) {
121 break;
122 }
123 }
124
125 if (ids.length > 1 && ids[0] === 'Index') {
126 ids.shift();
127 }
128
129 return ids
130 .reverse()
131 .join('')
132 .concat(explicitFileType || '');
133}
134
135const PAGE_MODULE_EXTS: { [type: string]: boolean } = {
136 '.tsx': true,

Callers 10

fs.unit.tsFile · 0.90
transformMenuFunction · 0.90
createMenusFunction · 0.90
resolveLayoutFunction · 0.90
resolveRouteFunction · 0.90
resolveServerPluginFunction · 0.90
resolveEntryFunction · 0.90
walkServerPluginsFunction · 0.90
routeFunction · 0.90

Calls 6

toTitleCaseFunction · 0.90
removeExtensionFunction · 0.85
dirnameFunction · 0.85
normalizePathFunction · 0.70
joinMethod · 0.65
basenameFunction · 0.50

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…