Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

No legacy links on sidebar #9257

Merged
merged 3 commits into from
Mar 5, 2024
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
3 changes: 3 additions & 0 deletions src/components/serverSidebar.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -97,6 +97,9 @@ export function ServerSidebar() {
// eslint-disable-next-line no-inner-declarations
function addChildren(docNodes: DocNode[]) {
docNodes.forEach(n => {
if (n.frontmatter.draft) {
return;
}
nodes.push({
context: {
platform: {
Expand Down
3 changes: 3 additions & 0 deletions src/files.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,9 @@ const walkDir = fullPath => {

const pathJoinPrefix = prefix => extraPath => path.join(prefix, extraPath);

//
// @returns {string[]} - Array of file paths
//
const getAllFilesRecursively = folder =>
pipe(fs.readdirSync, map(pipe(pathJoinPrefix(folder), walkDir)), flattenArray)(folder);

Expand Down
40 changes: 17 additions & 23 deletions src/mdx.ts
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ import remarkVariables from './remark-variables';

const root = process.cwd();

function formatSlug(slug) {
function formatSlug(slug: string) {
return slug.replace(/\.(mdx|md)/, '');
}
const isSupported = (
Expand Down Expand Up @@ -102,13 +102,11 @@ export function getAllFilesFrontMatter(folder: string = 'docs'): FrontMatter[] {

const source = fs.readFileSync(file, 'utf8');
const {data: frontmatter} = matter(source);
if (!frontmatter.draft) {
allFrontMatter.push({
...frontmatter,
slug: formatSlug(fileName),
sourcePath: path.join(folder, fileName),
});
}
allFrontMatter.push({
...frontmatter,
slug: formatSlug(fileName),
sourcePath: path.join(folder, fileName),
});
});

if (folder !== 'docs') {
Expand Down Expand Up @@ -158,13 +156,11 @@ export function getAllFilesFrontMatter(folder: string = 'docs'): FrontMatter[] {
if (subpath === 'index.mdx') {
frontmatter = {...frontmatter, ...platformFrontmatter};
}
if (!frontmatter.draft) {
allFrontMatter.push({
...frontmatter,
slug: formatSlug(slug),
sourcePath: 'docs/' + f.commonFileName.slice(docsPath.length + 1),
});
}
allFrontMatter.push({
...frontmatter,
slug: formatSlug(slug),
sourcePath: 'docs/' + f.commonFileName.slice(docsPath.length + 1),
});
}
});

Expand Down Expand Up @@ -196,13 +192,11 @@ export function getAllFilesFrontMatter(folder: string = 'docs'): FrontMatter[] {
if (subpath === 'index.mdx') {
frontmatter = {...frontmatter, ...guideFrontmatter};
}
if (!frontmatter.draft) {
allFrontMatter.push({
...frontmatter,
slug: formatSlug(slug),
sourcePath: 'docs/' + f.commonFileName.slice(docsPath.length + 1),
});
}
allFrontMatter.push({
...frontmatter,
slug: formatSlug(slug),
sourcePath: 'docs/' + f.commonFileName.slice(docsPath.length + 1),
});
}
});
});
Expand All @@ -211,7 +205,7 @@ export function getAllFilesFrontMatter(folder: string = 'docs'): FrontMatter[] {
return allFrontMatter;
}

export async function getFileBySlug(slug) {
export async function getFileBySlug(slug: string) {
const configPath = path.join(root, slug, 'config.yml');
let configFrontmatter: {[key: string]: any} | undefined;
if (fs.existsSync(configPath)) {
Expand Down
Loading