
Security News
Attackers Are Hunting High-Impact Node.js Maintainers in a Coordinated Social Engineering Campaign
Multiple high-impact npm maintainers confirm they have been targeted in the same social engineering campaign that compromised Axios.
zenn-next-sidebar
Advanced tools
getSidebarRoutes() akan secara otomatis mendeteksi:
/pages atau /app/src atau root directory.js, .ts, .jsx, .tsx, .mdxFungsi getSidebarRoutes hanya boleh dipanggil di sisi server pada aplikasi Next.js, seperti di dalam getStaticProps, getServerSideProps, atau API route. Jangan memanggil fungsi ini secara langsung di komponen React karena menggunakan modul fs yang hanya tersedia di lingkungan Node.js (server-side).
// pages/sidebar.tsx
import { GetStaticProps } from 'next';
import { getSidebarRoutes } from 'zenn-next-sidebar';
export const getStaticProps: GetStaticProps = async () => {
const routes = getSidebarRoutes();
return {
props: { routes },
};
};
export default function SidebarPage({ routes }) {
return (
<nav>
<ul>
{routes.map(route => (
<li key={route.path}>
<a href={route.path}>{route.name}</a>
</li>
))}
</ul>
</nav>
);
}
// pages/api/sidebar-routes.ts
import type { NextApiRequest, NextApiResponse } from 'next';
import { getSidebarRoutes } from 'zenn-next-sidebar';
export default function handler(req: NextApiRequest, res: NextApiResponse) {
const routes = getSidebarRoutes();
res.status(200).json(routes);
}
Fungsi getSidebarRoutes menggunakan modul fs dari Node.js untuk membaca struktur file. Jika dipanggil di komponen React (client-side), akan terjadi error seperti Module not found: Can't resolve 'fs' karena modul tersebut tidak tersedia di browser.
Error: Module not found: Can't resolve 'fs'
getSidebarRoutes hanya dipanggil di server-side (misal: getStaticProps, getServerSideProps, atau API route).Integrasi ke Komponen Sidebar/Navigasi
getSidebarRoutes di server-side, lalu kirimkan ke komponen React melalui props.baseDir pada getSidebarRoutes(baseDir)..js, .ts, .jsx, .tsx, .mdx dan mengabaikan file/folder yang diawali _, ., atau folder api.FAQs
Did you know?

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Security News
Multiple high-impact npm maintainers confirm they have been targeted in the same social engineering campaign that compromised Axios.

Security News
Axios compromise traced to social engineering, showing how attacks on maintainers can bypass controls and expose the broader software supply chain.

Security News
Node.js has paused its bug bounty program after funding ended, removing payouts for vulnerability reports but keeping its security process unchanged.