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

enable gatsby-adapter-netlify to speed up builds #2297

Merged
merged 3 commits into from
Oct 6, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ This assumes you already have Node.js and npm installed. Node.js version 18 or a

## Configuring the build

`gatsby-config.js` is effectively your build script and `gatsby-node.js` is where the Asciidoc rendering takes place.
`gatsby-config.ts` is effectively your build script and `gatsby-node.ts` is where the Asciidoc rendering takes place.

## How to contribute

Expand Down
84 changes: 70 additions & 14 deletions gatsby-config.js → gatsby-config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,19 +4,76 @@
* See: https://www.gatsbyjs.org/docs/gatsby-config/
*/

const path = require('path')
const locales = require('./locales/i18n')
import path from 'path'
import adapter from 'gatsby-adapter-netlify'
import locales from './locales/i18n'

interface SiteMetadata {
title: string;
description: string;
author: string;
siteUrl: string;
social: {
twitter: string
}
}

interface AsciidocNode {
id: string;
document: {
title: string;
};
fields: {
slug: string;
};
html: string;
}

interface LocalSearchNormalizerArgs {
data: {
allAsciidoc: {
edges: Array<{ node: AsciidocNode }>;
};
};
}

interface MdxNode {
excerpt: string;
fields: {
slug: string;
postPath: string;
};
frontmatter: {
date: string;
title: string;
};
}

interface AllMdxQueryResult {
allMdx: {
totalCount: number;
edges: {
node: MdxNode;
}[];
};
site: {
siteMetadata: SiteMetadata;
}
}

const metadata: SiteMetadata = {
title: 'Adoptium',
description: 'Eclipse Adoptium provides prebuilt OpenJDK binaries ...',
author: 'Eclipse Adoptium',
siteUrl: 'https://adoptium.net',
social: {
twitter: 'Adoptium'
}
};

module.exports = {
siteMetadata: {
title: 'Adoptium',
description: 'Eclipse Adoptium provides prebuilt OpenJDK binaries from a fully open source set of build scripts and infrastructure. Supported platforms include Linux, macOS, Windows, ARM, Solaris, and AIX.',
author: 'Eclipse Adoptium',
siteUrl: 'https://adoptium.net',
social: {
twitter: 'Adoptium'
}
},
adapter: adapter(),
siteMetadata: metadata,
plugins: [
'gatsby-plugin-sitemap',
{
Expand Down Expand Up @@ -92,7 +149,7 @@ module.exports = {
`,
feeds: [
{
serialize: ({ query: { site, allMdx } }) => {
serialize: ({ query: { site, allMdx } }: { query: AllMdxQueryResult }) => {
return allMdx.edges.map(edge => {
return Object.assign({}, edge.node.frontmatter, {
description: edge.node.excerpt,
Expand Down Expand Up @@ -204,7 +261,7 @@ module.exports = {
`,
index: ['title', 'body'],
store: ['id', 'path', 'title'],
normalizer: ({ data }) =>
normalizer: ({ data }: LocalSearchNormalizerArgs) =>
data.allAsciidoc.edges.map((result) => ({
id: result.node.id,
path: result.node.fields.slug,
Expand All @@ -222,7 +279,6 @@ module.exports = {
]
}
},
'gatsby-plugin-netlify',
'gatsby-plugin-image',
{
resolve: 'gatsby-plugin-react-svg',
Expand Down
Loading