Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: add Use Case pages #81

Draft
wants to merge 40 commits into
base: main
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
40 commits
Select commit Hold shift + click to select a range
1a7b82b
feat: initial component preparation
andrewgolovanov Mar 27, 2023
bdfd293
chore: setup and initial integration with Sanity
andrewgolovanov Mar 28, 2023
8dd1136
chore: moving Sanity to a separate repository
andrewgolovanov Mar 30, 2023
e7b7fc9
feat: get data from Sanity
andrewgolovanov Mar 30, 2023
031b069
Merge branch 'main' of github.com:novuhq/website into notifications-d…
andrewgolovanov Mar 30, 2023
ebf77eb
feat: page refinement
andrewgolovanov Mar 30, 2023
9c5b143
feat: add responsive version for pages
andrewgolovanov Mar 30, 2023
9e89229
chore: add additional information for env variables
andrewgolovanov Mar 30, 2023
d90ca3c
fix: minor changes
andrewgolovanov Mar 30, 2023
723b775
fix: minor changes
andrewgolovanov Mar 30, 2023
54d9be1
Merge branch 'main' of github.com:novuhq/website into notifications-d…
andrewgolovanov Mar 30, 2023
db625a7
Merge branch 'main' of github.com:novuhq/website into notifications-d…
andrewgolovanov Mar 30, 2023
e5ba169
Merge branch 'main' of github.com:novuhq/website into notifications-d…
andrewgolovanov Mar 30, 2023
4352f96
Merge branch 'main' of github.com:novuhq/website into notifications-d…
andrewgolovanov Apr 7, 2023
5bc2748
feat: add a workflow
andrewgolovanov Apr 7, 2023
ba6f78d
refactor: page construction optimization
andrewgolovanov Apr 10, 2023
f07877c
feat: get providers
andrewgolovanov Apr 10, 2023
592d15c
chore: trigger build
andrewgolovanov Apr 18, 2023
17b95f3
fix: minor changes
andrewgolovanov Apr 26, 2023
ca59b69
Merge branch 'main' into notifications-directory-page
americano98 May 30, 2023
5ffbaef
chore: refactor after merge
americano98 May 30, 2023
d14e692
feat: add labels for providers and channels
americano98 May 31, 2023
7ea1f4b
feat: update icons
americano98 May 31, 2023
f1f0728
feat: add new tooltip theme
americano98 May 31, 2023
99b0572
refactor: resolve potential errors
americano98 May 31, 2023
06d4eb2
feat: add new color style
americano98 May 31, 2023
f6ed16d
feat: update use case hero providers and channels
americano98 May 31, 2023
8f0bf54
feat: create use case card component
americano98 May 31, 2023
9c954eb
feat: refactor read more component
americano98 May 31, 2023
401b3f3
chore: rounded style for providers
americano98 May 31, 2023
7daae02
Merge branch 'main' of github.com:novuhq/website into notifications-d…
andrewgolovanov May 31, 2023
0fd924f
fix: minor changes
andrewgolovanov May 31, 2023
11f4c26
chore: provider name instead of id
americano98 May 31, 2023
91f1788
refactor: resolve error
americano98 May 31, 2023
5ceb849
fix: duplicate hint
americano98 May 31, 2023
0e5ee6a
fix: aligns
americano98 Jun 1, 2023
d4f82e3
refactor: update gradients for channel label
americano98 Jun 2, 2023
f66acaf
Merge branch 'main' of https://github.com/novuhq/website into notific…
andrewgolovanov Jun 20, 2023
34db1e4
Merge branch 'main' of https://github.com/novuhq/website into notific…
andrewgolovanov Jun 20, 2023
22f5fa2
Merge branch 'main' of https://github.com/novuhq/website into notific…
andrewgolovanov Jun 20, 2023
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions .env.example
Original file line number Diff line number Diff line change
Expand Up @@ -14,9 +14,9 @@ GATSBY_CONTRIBUTORS_API_URL=
GITHUB_TOKEN=

GATSBY_SANITY_PROJECT_ID=
GATSBY_SANITY_DATASET=
GATSBY_SANITY_DATASET=production

GATSBY_NOVU_API_KEY=
GATSBY_NOTIFICATIONS_API_URL=

GITHUB_README_TOKEN=
GITHUB_README_TOKEN=
138 changes: 138 additions & 0 deletions gatsby-node.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ const fetch = require(`node-fetch`);
const slash = require('slash');

const redirects = require('./redirects.json');
const getUseCases = require('./src/utils/get-use-cases');
// const getSlugForPodcast = require('./src/utils/get-slug-for-podcast');

const createContributorsPage = async ({ actions, reporter }) => {
Expand Down Expand Up @@ -373,6 +374,142 @@ async function createPosts({ graphql, actions }) {
// });
// }

async function createUseCasePages({ graphql, actions, reporter }) {
const { createPage } = actions;

const result = await graphql(`
{
allSanityTechnicalUseCase {
nodes {
id
templateType: _type
title
description
slug {
current
}
body: _rawBody
templateIndetifiers
}
}
allSanityFeatureUseCase {
nodes {
id
templateType: _type
title
description
slug {
current
}
body: _rawBody
templateIndetifiers
}
}

allSanityProvider {
nodes {
name
channels {
channel {
name
value {
current
}
}
}
}
}
}
`);

if (result.errors) {
throw new Error(result.errors);
}

try {
const useCases = [
...result.data.allSanityTechnicalUseCase.nodes,
...result.data.allSanityFeatureUseCase.nodes,
];
const allProviders = result.data.allSanityProvider.nodes;

const useCasesWithFullData = await getUseCases(useCases, allProviders);
const useCaseTemplate = path.resolve('./src/templates/use-case.jsx');
const useCaseTemplateTypes = {
'technical-use-case': {
slug: '/technical-use-cases/',
},
'feature-use-case': {
slug: '/feature-use-cases/',
},
};

useCasesWithFullData.map((useCase) => {
const { templateType, slug } = useCase;

const parentPageUrl = useCaseTemplateTypes[templateType].slug;
const otherUseCases = useCasesWithFullData
.filter(
(otherUseCase) =>
otherUseCase.id !== useCase.id && otherUseCase.templateType === templateType
)
.map((otherUseCase) => ({
...otherUseCase,
slug: parentPageUrl + otherUseCase.slug.current,
}))
.slice(-2);

return createPage({
path: `${useCaseTemplateTypes[templateType].slug}${slug.current}/`,
component: slash(useCaseTemplate),
context: {
...useCase,
parentPageUrl,
otherUseCases,
},
});
});

const useCasesTemplate = path.resolve('./src/templates/use-cases.jsx');

createPage({
path: '/technical-use-cases/',
component: slash(useCasesTemplate),
context: {
title: 'Technical Use Cases',
description:
'Simple components and APIs for managing all communication channels in one place: Email, SMS, Direct, and Push',
useCases: useCasesWithFullData.filter(
(useCase) => useCase.templateType === 'technical-use-case'
),
pageMetadata: {
slug: '/technical-use-cases/',
title: 'Technical Use Cases - Novu',
},
},
});

createPage({
path: '/feature-use-cases/',
component: slash(useCasesTemplate),
context: {
title: 'Feature Use Cases',
description:
'Simple components and APIs for managing all communication channels in one place: Email, SMS, Direct, and Push',
useCases: useCasesWithFullData.filter(
(useCase) => useCase.templateType === 'feature-use-case'
),
pageMetadata: {
slug: '/feature-use-cases/',
title: 'Feature Use Cases - Novu',
},
},
});
} catch (error) {
reporter.panicOnBuild('Error in createUseCasePages:', error);
}
}

exports.createPages = async (args) => {
const { createRedirect } = args.actions;

Expand All @@ -392,6 +529,7 @@ exports.createPages = async (args) => {
await createPages(params);
await createBlogPages(params);
await createPosts(params);
await createUseCasePages(params);

// TODO: to uncomment the creation of podcast pages after this link works - https://feeds.transistor.fm/sourcelife
// await createPodcastPage(params);
Expand Down
Loading