Skip to content

Commit

Permalink
feat: adds ts support (#73)
Browse files Browse the repository at this point in the history
- adds typescript
- use yarn
- update deploy action
- refactor components and hooks
- updates packages to latest versions
  • Loading branch information
gabacode authored Sep 12, 2024
1 parent 51a4e4e commit 2d92d06
Show file tree
Hide file tree
Showing 68 changed files with 12,952 additions and 28,067 deletions.
1 change: 1 addition & 0 deletions .env.production
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
GATSBY_WP_GRAPH_API=https://opendatasicilia.it/graphql
34 changes: 19 additions & 15 deletions .github/workflows/deploy.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,9 @@ name: Gatsby Build & Deploy
on:
workflow_dispatch:
push:
branches:
- main
- dev
repository_dispatch:
types:
- deploy
Expand All @@ -11,28 +14,29 @@ jobs:
build:
runs-on: ubuntu-latest
steps:

- name: Checkout
uses: actions/checkout@v2
- name: Set Node 16

- name: Set Node 20
uses: actions/setup-node@v2
with:
node-version: 16
node-version: 20

- name: Check Npm Cache
id: cache-nodemodules
- name: Check Yarn Cache
id: cache-yarn
uses: actions/cache@v2
env:
cache-name: cache-node-modules
cache-name: cache-yarn
with:
path: node_modules
key: ${{ runner.os }}-build-${{ env.cache-name }}-${{ hashFiles('**/package-lock.json') }}
path: |
node_modules
.yarn/cache
key: ${{ runner.os }}-build-${{ env.cache-name }}-${{ hashFiles('**/yarn.lock') }}
restore-keys: |
${{ runner.os }}-build-${{ env.cache-name }}-
${{ runner.os }}-build-
${{ runner.os }}-
- name: Check Gatsby Cache
uses: actions/cache@v2
id: gatsby-cache-folder
Expand All @@ -52,12 +56,12 @@ jobs:
${{ runner.os }}-public-site
- name: Install dependencies
if: steps.cache-nodemodules.outputs.cache-hit != 'true'
run: npm ci
if: steps.cache-yarn.outputs.cache-hit != 'true'
run: yarn install --frozen-lockfile

- name: Install Gatsby CLI
run: npm install -g gatsby-cli
run: yarn global add gatsby-cli

- name: Build
run: gatsby build --log-pages
env:
Expand Down
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -2,3 +2,6 @@ node_modules
.cache
public
build
.idea
.vscode
.DS_Store
6 changes: 3 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,12 +12,12 @@
## Sviluppo locale
- Clonare il repository
- Installare Node, e gatsby-cli come illustrato [qui](https://github.com/opendatasicilia/opendatasicilia.it/discussions/29)
- Lanciare il comando `npm install` per scaricare le dipendenze
- Lanciamo il comando `gatsby develop`
- Lanciare il comando `yarn` per scaricare le dipendenze
- Lanciamo il comando `yarn start`

## GitHub Pages
- Lanciare `cp .env.development .env.production`
- Lanciare `npm run deploy`
- Lanciare `yarn deploy`

## URL
https://dev.opendatasicilia.it
2 changes: 0 additions & 2 deletions gatsby-browser.js

This file was deleted.

2 changes: 2 additions & 0 deletions gatsby-browser.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
import "bootstrap/dist/css/bootstrap.min.css";
import "./src/styles/main.scss";
63 changes: 35 additions & 28 deletions gatsby-config.js → gatsby-config.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
require("dotenv").config({path: `.env.${process.env.NODE_ENV}`})

import { AllWpPostData } from "./src/types";

require("dotenv").config({ path: `.env.${process.env.NODE_ENV}` });

module.exports = {
flags: {
PRESERVE_FILE_DOWNLOAD_CACHE: true,
Expand All @@ -16,40 +18,41 @@ module.exports = {
previewRequestConcurrency: 2, // default is 5
},
html: {
useGatsbyImage: false
}
useGatsbyImage: false,
},
},
type: {
MediaItem: {
localFile: {
requestConcurrency: 50
}
}
}
requestConcurrency: 50,
},
},
},
},
{
resolve: `gatsby-plugin-manifest`,
resolve: "gatsby-plugin-manifest",
options: {
name: `OpenDataSicilia`,
short_name: `ODS`,
start_url: `/`,
background_color: `#f7f0eb`,
theme_color: `#006d77`,
display: `standalone`,
icon: `src/assets/images/opendatasicilia-logo.png`,
name: "OpenDataSicilia",
short_name: "ODS",
start_url: "/",
background_color: "#f7f0eb",
theme_color: "#006d77",
display: "standalone",
icon: "src/assets/images/opendatasicilia-logo.png",
},
},
"gatsby-plugin-react-helmet",
"gatsby-transformer-sharp",
"gatsby-plugin-sharp",
"gatsby-plugin-no-sourcemaps",
"gatsby-plugin-sass",
{
resolve: 'gatsby-plugin-local-search',
resolve: "gatsby-plugin-local-search",
options: {
name: 'posts',
engine: 'flexsearch',
engineOptions: {
tokenize: 'forward'
name: "posts",
engine: "flexsearch",
engineOptions: {
tokenize: "forward",
},
query: `
{
Expand All @@ -68,19 +71,23 @@ module.exports = {
}
}
`,
ref: 'slug',
index: ['title', 'author', 'content'],
store: ['slug', 'uri', 'title', 'content', 'author'],
normalizer: ({ data }) =>
ref: "slug",
index: ["title", "author", "content"],
store: ["slug", "uri", "title", "content", "author"],
normalizer: ({ data }: { data: AllWpPostData }) =>
data.allWpPost.nodes.map((node) => ({
slug: node.slug,
title: node.title,
uri: node.uri,
content: node.content.replace(/<script\b[^<]*(?:(?!<\/script>)<[^<]*)*<\/script>/gi, '').replace(/<[^>]+>/g, ''),
author: node.author.node.name
content: node.content
.replace(
/<script\b[^<]*(?:(?!<\/script>)<[^<]*)*<\/script>/gi,
""
)
.replace(/<[^>]+>/g, ""),
author: node.author.node.name,
})),
},
},
],
};

103 changes: 0 additions & 103 deletions gatsby-node.js

This file was deleted.

Loading

0 comments on commit 2d92d06

Please sign in to comment.