Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 7 additions & 1 deletion ingest/collection.ts
Original file line number Diff line number Diff line change
Expand Up @@ -24,9 +24,15 @@ const collectionMatter = (indexMd: string, slug: string, defaults: Partial<Colle
{ admins: isListOfStrings }
);

const DefaultCollectionContent = `# Notes`;

export const parseCollection = async (pathParts: string[], defaults: CollectedDefaults): Promise<RawCollectionDef> => {
const fullPath = pathParts.join("/");
const indexMd = fs.readFileSync(getMdFile(pathParts, "collection")!, "utf-8");
const mdFile = getMdFile(pathParts, "collection");
if (!mdFile && pathParts.length !== 0) {
throw new Error(`Collection ${fullPath} does not have an index.md(x) file`);
}
const indexMd = mdFile !== null ? fs.readFileSync(mdFile, "utf-8") : DefaultCollectionContent;
Comment thread
janezd marked this conversation as resolved.
const { frontmatter, content } = collectionMatter(indexMd, fullPath, defaultsFor(defaults, fullPath, "collection"));
const mdxContent = parseMd(content);

Expand Down
5 changes: 2 additions & 3 deletions ingest/updatePaths.ts
Original file line number Diff line number Diff line change
Expand Up @@ -746,9 +746,8 @@ export const updatePaths = async (
};

export const updateRoot = async (db: Database) => {
const rootCollection =
getMdFile([], "collection") ? await parseCollection([], []) : null;
if (rootCollection?.frontmatter.public) {
const rootCollection = await parseCollection([], []);
if (rootCollection.frontmatter.public) {
const buildId = (await db.get(
`INSERT INTO builds (path) VALUES (?) RETURNING id`,
[""])
Expand Down
Loading