|
1 |
| -import type { |
2 |
| - ChapterSchema, |
3 |
| - FilesRefList, |
4 |
| - Lesson, |
5 |
| - LessonSchema, |
6 |
| - PartSchema, |
7 |
| - Tutorial, |
8 |
| - TutorialSchema, |
9 |
| -} from '@tutorialkit/types'; |
10 |
| -import { folderPathToFilesRef, interpolateString } from '@tutorialkit/types'; |
| 1 | +import type { ChapterSchema, Lesson, LessonSchema, PartSchema, Tutorial, TutorialSchema } from '@tutorialkit/types'; |
| 2 | +import { interpolateString } from '@tutorialkit/types'; |
11 | 3 | import { getCollection } from 'astro:content';
|
12 |
| -import glob from 'fast-glob'; |
13 | 4 | import path from 'node:path';
|
14 |
| -import { IGNORED_FILES } from './constants'; |
15 | 5 | import { DEFAULT_LOCALIZATION } from './content/default-localization';
|
16 | 6 | import { squash } from './content/squash.js';
|
17 | 7 | import { logger } from './logger';
|
18 | 8 | import { joinPaths } from './url';
|
19 |
| - |
20 |
| -const CONTENT_DIR = path.join(process.cwd(), 'src/content/tutorial'); |
| 9 | +import { getFilesRefList } from './content/files-ref'; |
21 | 10 |
|
22 | 11 | export async function getTutorial(): Promise<Tutorial> {
|
23 | 12 | const collection = sortCollection(await getCollection('tutorial'));
|
@@ -331,24 +320,6 @@ function getSlug(entry: CollectionEntryTutorial) {
|
331 | 320 | return slug;
|
332 | 321 | }
|
333 | 322 |
|
334 |
| -async function getFilesRefList(pathToFolder: string): Promise<FilesRefList> { |
335 |
| - const root = path.join(CONTENT_DIR, pathToFolder); |
336 |
| - |
337 |
| - const filePaths = ( |
338 |
| - await glob(`${glob.convertPathToPattern(root)}/**/*`, { |
339 |
| - onlyFiles: true, |
340 |
| - ignore: IGNORED_FILES, |
341 |
| - dot: true, |
342 |
| - }) |
343 |
| - ).map((filePath) => `/${path.relative(root, filePath)}`); |
344 |
| - |
345 |
| - filePaths.sort(); |
346 |
| - |
347 |
| - const filesRef = folderPathToFilesRef(pathToFolder); |
348 |
| - |
349 |
| - return [filesRef, filePaths]; |
350 |
| -} |
351 |
| - |
352 | 323 | interface CollectionEntryTutorial {
|
353 | 324 | id: string;
|
354 | 325 | slug: string;
|
|
0 commit comments