MCPcopy
hub / github.com/facebook/docusaurus / buildAllRoutes

Function buildAllRoutes

packages/docusaurus-plugin-content-blog/src/routes.ts:53–365  ·  view source on GitHub ↗
({
  baseUrl,
  content,
  actions,
  options,
  aliasedSource,
}: CreateAllRoutesParam)

Source from the content-addressed store, hash-verified

51}
52
53export async function buildAllRoutes({
54 baseUrl,
55 content,
56 actions,
57 options,
58 aliasedSource,
59}: CreateAllRoutesParam): Promise<RouteConfig[]> {
60 const {
61 blogListComponent,
62 blogPostComponent,
63 blogTagsListComponent,
64 blogAuthorsListComponent,
65 blogAuthorsPostsComponent,
66 blogTagsPostsComponent,
67 blogArchiveComponent,
68 routeBasePath,
69 archiveBasePath,
70 authorsBasePath,
71 postsPerPage,
72 pageBasePath,
73 } = options;
74 const pluginId = options.id;
75 const {createData} = actions;
76 const {
77 blogTitle,
78 blogDescription,
79 blogSidebarTitle,
80 blogPosts,
81 blogTags,
82 blogTagsListPath,
83 authorsMap,
84 } = content;
85
86 const blogBasePath = normalizeUrl([baseUrl, routeBasePath]);
87 const authorsListPath = normalizeUrl([blogBasePath, authorsBasePath]);
88
89 const listedBlogPosts = blogPosts.filter(shouldBeListed);
90
91 const blogPostsById = _.keyBy(blogPosts, (post) => post.id);
92 function getBlogPostById(id: string): BlogPost {
93 const blogPost = blogPostsById[id];
94 if (!blogPost) {
95 throw new Error(`unexpected, can't find blog post id=${id}`);
96 }
97 return blogPost;
98 }
99
100 const sidebarBlogPosts =
101 options.blogSidebarCount === 'ALL'
102 ? blogPosts
103 : blogPosts.slice(0, options.blogSidebarCount);
104
105 async function createSidebarModule() {
106 const sidebarProp = toBlogSidebarProp({
107 blogSidebarTitle,
108 blogPosts: sidebarBlogPosts,
109 });
110 const modulePath = await createData(

Callers 2

testBuildAllRoutesFunction · 0.90
createAllRoutesFunction · 0.70

Calls 10

normalizeUrlFunction · 0.90
docuHashFunction · 0.90
createSidebarModuleFunction · 0.85
createBlogMetadataModuleFunction · 0.85
createDataFunction · 0.85
createBlogPostRoutesFunction · 0.85
createTagsRoutesFunction · 0.85
createArchiveRouteFunction · 0.85
createAuthorsRoutesFunction · 0.85

Tested by 1

testBuildAllRoutesFunction · 0.72

Used in the wild real call sites across dependent graphs

searching dependent graphs…