Skip to content

Commit

Permalink
No legacy links on sidebar (#9257)
Browse files Browse the repository at this point in the history
* remove legacy guides links from the sidebar
* add some missing types
* [getsentry/action-github-commit] Auto commit

---------

Co-authored-by: getsantry[bot] <66042841+getsantry[bot]@users.noreply.github.com>
  • Loading branch information
a-hariti and getsantry[bot] committed Mar 5, 2024
1 parent 929f352 commit da34bba
Show file tree
Hide file tree
Showing 3 changed files with 23 additions and 23 deletions.
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 @@ -27,7 +27,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 @@ -103,13 +103,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 @@ -159,13 +157,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 @@ -197,13 +193,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 @@ -212,7 +206,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

0 comments on commit da34bba

Please sign in to comment.