Skip to content

Commit

Permalink
convert to TS
Browse files Browse the repository at this point in the history
  • Loading branch information
gdams committed Oct 6, 2023
1 parent 6463562 commit 06d2987
Show file tree
Hide file tree
Showing 6 changed files with 252 additions and 87 deletions.
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
87 changes: 70 additions & 17 deletions gatsby-config.js → gatsby-config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,23 +4,76 @@
* See: https://www.gatsbyjs.org/docs/gatsby-config/
*/

const path = require('path')
const locales = require('./locales/i18n')
const adapter = require('gatsby-adapter-netlify')
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 = {
adapter: adapter({
excludeDatastoreFromEngineFunction: false,
}),
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 @@ -96,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 @@ -208,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 Down
Loading

0 comments on commit 06d2987

Please sign in to comment.