diff --git a/gatsby-config.js b/gatsby-config.js index dc5cb3f4d..980b39ea2 100644 --- a/gatsby-config.js +++ b/gatsby-config.js @@ -146,30 +146,16 @@ module.exports = { path } } - questions: allSqueakQuestion { - nodes { - permalink - } - } }`, resolveSiteUrl: ({ site }) => { return site.siteMetadata.siteUrl }, - resolvePages: async ({ - allSitePage: { nodes: allPages }, - site, - questions: { nodes: allQuestions }, - }) => { + resolvePages: async ({ allSitePage: { nodes: allPages }, site }) => { const transformedPages = allPages.map(({ path }) => { return { path: `${site.siteMetadata.siteUrl}${path}`, } }) - const transformedQuestionPages = allQuestions.map(({ permalink }) => { - return { - path: `${site.siteMetadata.siteUrl}/questions/${permalink}`, - } - }) let plugins = [] try { @@ -185,7 +171,7 @@ module.exports = { path: `${site.siteMetadata.siteUrl}/plugins/` + plugin.name.toLowerCase().replace(/ /g, '-'), })) - return [...transformedPages, ...transformedQuestionPages, ...plugins] + return [...transformedPages, ...plugins] }, serialize: async ({ path }) => { let changefreq = 'monthly' diff --git a/gatsby/algoliaConfig.js b/gatsby/algoliaConfig.js index 985259f54..d56a619c9 100644 --- a/gatsby/algoliaConfig.js +++ b/gatsby/algoliaConfig.js @@ -101,39 +101,6 @@ module.exports = { }) }, }, - { - query: ` - { - questions: allSqueakQuestion(filter: {permalink: {ne: null}, archived: {ne: true}}) { - nodes { - id - title: subject - body - resolvedBy { - body - } - resolved - permalink - internal { - contentDigest - } - } - } - } - `, - transformer: ({ data }) => { - return data.questions.nodes.map(({ body, permalink, resolvedBy, ...question }) => { - return { - ...question, - excerpt: body, - slug: `questions/${permalink || ''}`, - type: 'question', - path_ranking: 5, - resolutionBody: resolvedBy?.body, - } - }) - }, - }, { query: `{ query: sitePage { id } }`, transformer: () => { diff --git a/gatsby/onCreateNode.ts b/gatsby/onCreateNode.ts index ee1ca9d9b..036eb69b2 100644 --- a/gatsby/onCreateNode.ts +++ b/gatsby/onCreateNode.ts @@ -100,12 +100,7 @@ export const onCreateNode: GatsbyNode['onCreateNode'] = async ({ if (node.internal.type === `MarkdownRemark` || node.internal.type === 'Mdx') { const parent = getNode(node.parent) - if ( - parent?.internal.type === 'SqueakReply' || - parent?.internal.type === 'PostHogPull' || - parent?.internal.type === 'PostHogIssue' - ) - return + if (parent?.internal.type === 'PostHogPull' || parent?.internal.type === 'PostHogIssue') return const imageFields = ['featuredImage', 'thumbnail', 'logo', 'logoDark', 'icon'] imageFields.forEach((field) => { diff --git a/plugins/gatsby-source-squeak/gatsby-node.ts b/plugins/gatsby-source-squeak/gatsby-node.ts index 8a8d05179..9823aeb4b 100644 --- a/plugins/gatsby-source-squeak/gatsby-node.ts +++ b/plugins/gatsby-source-squeak/gatsby-node.ts @@ -69,89 +69,6 @@ export const sourceNodes: GatsbyNode['sourceNodes'] = async ( page++ } - // Fetch all questions - page = 1 - while (true) { - let questionQuery = qs.stringify({ - pagination: { - page, - pageSize: 100, - }, - populate: { - profile: { - fields: ['id'], - }, - replies: { - populate: { - profile: { - fields: ['id'], - }, - }, - }, - topics: { - fields: ['id'], - }, - resolvedBy: { - fields: ['id'], - }, - }, - }) - - const questions = await fetch(`${apiHost}/api/questions?${questionQuery}`).then((res) => res.json()) - - for (let question of questions.data) { - const { topics, replies, profile, resolvedBy, ...rest } = question.attributes - - if (!profile.data?.id) { - console.warn(`Question ${question.id} has no profile`) - continue - } - - const filteredReplies = replies.data.filter((reply) => reply.attributes.profile.data?.id) - - createNode({ - type: `SqueakQuestion`, - id: createNodeId(`squeak-question-${question.id}`), - squeakId: question.id, - internal: { - contentDigest: createContentDigest(question), - type: `SqueakQuestion`, - }, - ...(profile.data && { profile: { id: createNodeId(`squeak-profile-${profile.data.id}`) } }), - replies: filteredReplies.map((reply) => ({ - id: createNodeId(`squeak-reply-${reply.id}`), - })), - topics: topics.data.map((topic) => ({ - id: createNodeId(`squeak-topic-${topic.id}`), - })), - ...rest, - resolvedBy: createNodeId(`squeak-reply-${resolvedBy?.data?.id}`), - }) - - for (let reply of filteredReplies) { - const { profile, ...replyData } = reply.attributes - - createNode({ - type: `SqueakReply`, - id: createNodeId(`squeak-reply-${reply.id}`), - squeakId: reply.id, - internal: { - contentDigest: createContentDigest(replyData.body), - type: `SqueakReply`, - content: replyData.body, - }, - ...(profile.data && { profile: { id: createNodeId(`squeak-profile-${profile.data.id}`) } }), - ...replyData, - }) - } - } - - if (questions.meta.pagination.page >= questions.meta.pagination.pageCount) { - break - } - page++ - } - // Fetch all topic groups let query = qs.stringify({ populate: { @@ -396,26 +313,6 @@ export const createSchemaCustomization: GatsbyNode['createSchemaCustomization'] color: String } - type SqueakQuestion implements Node { - id: ID! - squeakId: Int! - body: String! - createdAt: Date! @dateformat - profile: SqueakProfile! @link(by: "id", from: "profile.id") - replies: [SqueakReply!] @link(by: "id", from: "replies.id") - topics: [SqueakTopic!] @link(by: "id", from: "topics.id") - resolvedBy: SqueakReply @link(by: "id") - } - - type SqueakReply implements Node { - id: ID! - squeakId: Int! - body: String! - createdAt: Date! @dateformat - profile: SqueakProfile! @link(by: "id", from: "profile.id") - question: SqueakQuestion! @link(from: "id", to: "question") - } - type SqueakTopicGroup implements Node { id: ID! squeakId: Int!