Skip to content

Commit

Permalink
Dirt fix for issue: gatsbyjs/gatsby#26520
Browse files Browse the repository at this point in the history
  • Loading branch information
RetiredWorld committed Feb 4, 2021
1 parent 0810cc0 commit b4c2d92
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 1 deletion.
8 changes: 8 additions & 0 deletions src/gatsby/page/create-archive.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,14 @@ import { rootDir } from "../config";
const archiveTemplate = path.join(rootDir, 'src/template/archive.tsx');

export default function createArchive(res: ArchiveQuery, actions: Actions) {
// TODO: remove fakeContext once issue https://github.com/gatsbyjs/gatsby/issues/26520 resolved
const fakeContext = 'fakeContext';
actions.createPage({
path: '/archive',
component: archiveTemplate,
context: fakeContext
});

actions.createPage({
path: '/archive',
component: archiveTemplate,
Expand Down
18 changes: 17 additions & 1 deletion src/gatsby/page/create-homepage.ts
Original file line number Diff line number Diff line change
Expand Up @@ -63,13 +63,22 @@ export default function createHomepage(res: PostQuery, actions: Actions) {
next = group[index + 1].yearMonth;
}

// TODO: remove fakeContext once issue https://github.com/gatsbyjs/gatsby/issues/26520 resolved
const fakeContext = 'fakeContext';
const context = {
data: posts,
prev,
next,
now: index + 1,
sum: group.length,
}
};

// fakeContext
actions.createPage({
path: `${year}\/${month}`,
component: homepageTemplate,
context: fakeContext,
});

actions.createPage({
path: `${year}\/${month}`,
Expand All @@ -78,6 +87,13 @@ export default function createHomepage(res: PostQuery, actions: Actions) {
});

if (index === 0) {
// fakeContext
actions.createPage({
path: `/`,
component: homepageTemplate,
context: fakeContext,
});

actions.createPage({
path: '/',
component: homepageTemplate,
Expand Down

0 comments on commit b4c2d92

Please sign in to comment.