Skip to content

Commit

Permalink
website: modernify webiste
Browse files Browse the repository at this point in the history
- rename file to ts
- separate config from root
- upgrade deps
- use new built methods
  • Loading branch information
juliencrn committed Sep 19, 2022
1 parent d4b0526 commit 195e97f
Show file tree
Hide file tree
Showing 23 changed files with 13,392 additions and 15,688 deletions.
35 changes: 35 additions & 0 deletions site/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
node_modules

# Logs
logs
*.log
npm-debug.log*
yarn-debug.log*
yarn-error.log*
npm-debug.log*
*.tsbuildinfo

# Cache
.npm
.cache
.eslintcache

# Compiled stuff
public
generated

# Coverage
coverage

# dotenv environment variable files
.env*
!.env.example

# Output of 'npm pack'
*.tgz

# Mac files
.DS_Store

# Local Netlify folder
.netlify
38 changes: 0 additions & 38 deletions site/feedSerializer.js

This file was deleted.

File renamed without changes.
56 changes: 25 additions & 31 deletions site/gatsby-config.js → site/gatsby-config.ts
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
/* eslint-disable @typescript-eslint/no-var-requires */
const path = require('path')
import dotenv from 'dotenv'
import type { GatsbyConfig } from 'gatsby'
import path from 'path'

const feed = require('./feedSerializer')
import * as algolia from './src/libs/algolia'
import * as feed from './src/libs/feedSerializer'

require('dotenv').config({
path: `.env.${process.env.NODE_ENV}`,
})
dotenv.config({ path: `.env.${process.env.NODE_ENV}` })

const siteMetadata = {
title: `usehooks-ts`,
Expand All @@ -14,12 +14,10 @@ const siteMetadata = {
author: `juliencrn`, // Github username
}

module.exports = {
const config: GatsbyConfig = {
siteMetadata,
plugins: [
`gatsby-plugin-typescript`,
`gatsby-plugin-typescript-checker`,
`gatsby-plugin-react-helmet`,
`gatsby-plugin-catch-links`,
`gatsby-plugin-material-ui`,
`gatsby-plugin-sitemap`,
Expand All @@ -29,26 +27,10 @@ module.exports = {
'~': path.join(__dirname, 'src'),
},
},
// TODO: merge all gatsby-source-filesystem into only one ?
{
resolve: `gatsby-source-filesystem`,
options: {
path: `${__dirname}/generated`,
name: `generated`,
},
},
{
resolve: `gatsby-source-filesystem`,
options: {
path: `${__dirname}/src/hooks-doc`,
name: `hooks`,
},
},
{
resolve: `gatsby-plugin-mdx`,
options: {
extensions: [`.md`, `.mdx`],
plugins: [],
gatsbyRemarkPlugins: [
{
resolve: 'remark-codesandbox/gatsby',
Expand All @@ -59,12 +41,26 @@ module.exports = {
],
},
},
{
resolve: `gatsby-source-filesystem`,
options: {
path: `${__dirname}/generated`,
name: `generated`,
},
},
{
resolve: `gatsby-source-filesystem`,
options: {
path: `${__dirname}/src/content`,
name: `hooks`,
},
},
{
resolve: `gatsby-plugin-algolia`,
options: {
appId: process.env.GATSBY_ALGOLIA_APP_ID,
apiKey: process.env.GATSBY_ALGOLIA_ADMIN_KEY,
queries: require('./algolia'),
queries: algolia.queries,
},
},
{
Expand All @@ -76,8 +72,7 @@ module.exports = {
output: '/rss.xml',
title: `RSS Feed - ${siteMetadata.title}`,
description: `${siteMetadata.description}`,
serialize: ({ query }) =>
feed.serializer(query.posts, siteMetadata),
serialize: ({ query }) => feed.serializer({ query, siteMetadata }),
},
],
},
Expand Down Expand Up @@ -109,8 +104,7 @@ module.exports = {
icon: `src/images/typescript.png`, // This path is relative to the root of the site.
},
},
// TODO: enables Progressive Web App + Offline functionality
// To learn more, visit: https://gatsby.dev/offline
// `gatsby-plugin-offline`,
],
}

export default config
13 changes: 0 additions & 13 deletions site/gatsby-node.js

This file was deleted.

8 changes: 8 additions & 0 deletions site/gatsby-node.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
/**
* Implement Gatsby's Node APIs in this file.
*
* See: https://www.gatsbyjs.org/docs/node-apis/
*/

export { createPages } from './src/gatsby/createPages'
export { onCreateNode } from './src/gatsby/onCreateNode'
4 changes: 4 additions & 0 deletions site/gatsby-ssr.js → site/gatsby-ssr.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,4 +4,8 @@
* See: https://www.gatsbyjs.org/docs/ssr-apis/
*/

export const onRenderBody = ({ setHtmlAttributes }) => {
setHtmlAttributes({ lang: 'en' })
}

export { default as wrapPageElement } from './src/libs/wrapPageElement'
Loading

0 comments on commit 195e97f

Please sign in to comment.