Skip to content

Commit

Permalink
feat: catchup
Browse files Browse the repository at this point in the history
  • Loading branch information
nickfrosty committed Nov 30, 2023
1 parent c030e2c commit 0704014
Show file tree
Hide file tree
Showing 4 changed files with 18 additions and 124 deletions.
12 changes: 9 additions & 3 deletions src/pages/api/content/[[...slug]].ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ import {
allDeveloperResources,
allSolanaDocs,
allDeveloperWorkshops,
allSolanaRPCDocs,
DocumentTypes,
} from "contentlayer/generated";
import type { NextApiRequest, NextApiResponse } from "next";
Expand All @@ -32,8 +33,10 @@ export default function handler(
// retrieve the correct group's records by its simple group name
const records = ((group: SimpleRecordGroupName) => {
switch (group) {
case "docs":
case "docs": {
if (slug[1] == "rpc") return allSolanaRPCDocs;
return allSolanaDocs;
}
case "guides":
return allDeveloperGuides;
case "resources":
Expand All @@ -48,8 +51,11 @@ export default function handler(
// define the formatted href value to search for
// note: this effectively enforces that only href's that start with "/developers" are supported
const href = `${
slug[0].toLocaleLowerCase() == "docs" ? "" : "/developers"
}/${slug.join("/")}`;
slug[0].toLocaleLowerCase() == "docs" ||
slug[0].toLocaleLowerCase() == "rpc"
? ""
: "/developers"
}/${slug.join("/")}`.toLowerCase();

// create a flat listing of all the nav items in order to locate the next, current, and prev records
const flatNavItems = generateFlatNavItemListing(
Expand Down
44 changes: 0 additions & 44 deletions src/pages/api/nav/[group].ts

This file was deleted.

75 changes: 0 additions & 75 deletions src/pages/api/paths/[group].ts

This file was deleted.

11 changes: 9 additions & 2 deletions src/utils/navItem.ts
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,10 @@ export function generateNavItemListing(
grouping[record._raw.sourceFileDir] = { items: [] } as unknown as NavItem;

// process the index file as the root of the NavItem
if (record._raw.sourceFileName == "index.md") {
if (
record._raw.sourceFileName == "index.md" ||
record._raw.sourceFileName == "index.mdx"
) {
grouping[record._raw.sourceFileDir] = Object.assign(
grouping[record._raw.sourceFileDir],
// @ts-ignore
Expand Down Expand Up @@ -157,7 +160,7 @@ export function sortNavItems(navItems: NavItem[]) {
*/
export function shouldIgnoreRecord({
fileName,
allowedExtensions = ["md"],
allowedExtensions = ["md", "mdx"],
}: {
fileName: string;
allowedExtensions?: Array<string>;
Expand Down Expand Up @@ -212,6 +215,10 @@ export function computeNavItem(
);
}

// always lowercase certain specific values
record.href = record.href.toLowerCase();
record.id = record.id.toLowerCase();

/**
* when the record is only storing metadata, remove it as a linked item
* ---
Expand Down

0 comments on commit 0704014

Please sign in to comment.