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

Typescript migration #6307

Merged
merged 17 commits into from
May 19, 2022
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
7 changes: 6 additions & 1 deletion .github/workflows/docsearch-crawl.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,12 +11,17 @@ jobs:
steps:
- name: Checkout codebase
uses: actions/checkout@v2
- name: Install node and ts-node
uses: actions/setup-node@v2
with:
node-version: "14"
- run: npm install -g ts-node
- name: Crawl the site
env:
APPLICATION_ID: ${{ secrets.DOCSEARCH_APP_ID }}
API_KEY: ${{ secrets.DOCSEARCH_API_KEY }}
run: |
docker run \
-e APPLICATION_ID -e API_KEY \
-e CONFIG="$(node .github/workflows/docsearchConfigScript.js | cat .github/workflows/docsearchConfig.json)" \
-e CONFIG="$(ts-node -O '{\"module\": \"commonjs\"}' .github/workflows/docsearchConfigScript.js | cat .github/workflows/docsearchConfig.json)" \
nhsz marked this conversation as resolved.
Show resolved Hide resolved
algolia/docsearch-scraper:v1.6.0
2 changes: 1 addition & 1 deletion .github/workflows/docsearchConfigScript.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
const fs = require("fs")
const translations = require("../../src/data/translations.json")
const translations = require("../../src/utils/languages").default

var config = {
index_name: "prod-ethereum-org",
Expand Down
2 changes: 1 addition & 1 deletion .prettierignore
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
.cache
package.json
package-lock.json
public
public
6 changes: 3 additions & 3 deletions gatsby-browser.js → gatsby-browser.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,9 @@ import Prism from "prism-react-renderer/prism"
;(typeof global !== "undefined" ? global : window).Prism = Prism

// FormatJS Polyfill imports - Used for intl number formatting
require("@formatjs/intl-locale/polyfill")
require("@formatjs/intl-numberformat/polyfill")
require("@formatjs/intl-numberformat/locale-data/en")
import "@formatjs/intl-locale/polyfill"
import "@formatjs/intl-numberformat/polyfill"
import "@formatjs/intl-numberformat/locale-data/en"

// Default languages included:
// https://github.com/FormidableLabs/prism-react-renderer/blob/master/src/vendor/prism/includeLangs.js
Expand Down
34 changes: 20 additions & 14 deletions gatsby-config.js → gatsby-config.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,14 @@
require("dotenv").config()
import "dotenv/config"
import path from "path"

const { supportedLanguages, allLanguages } = require("./src/utils/translations")
import type { GatsbyConfig } from "gatsby"

import {
supportedLanguages,
defaultLanguage,
ignoreLanguages,
} from "./src/utils/languages"

const defaultLanguage = `en`
const siteUrl = `https://ethereum.org`

const ignoreContent = (process.env.IGNORE_CONTENT || "")
Expand All @@ -11,11 +17,11 @@ const ignoreContent = (process.env.IGNORE_CONTENT || "")

const isPreviewDeploy = process.env.IS_PREVIEW_DEPLOY === "true"

const ignoreTranslations = Object.keys(allLanguages)
.filter((lang) => !supportedLanguages.includes(lang))
.map((lang) => `**/translations\/${lang}`)
const ignoreTranslations = ignoreLanguages.map(
(lang) => `**/translations\/${lang}`
)

const config = {
const config: GatsbyConfig = {
siteMetadata: {
// `title` & `description` pulls from respective ${lang}.json files in PageMetadata.js
title: `ethereum.org`,
Expand All @@ -33,7 +39,7 @@ const config = {
resolve: `gatsby-plugin-intl`,
options: {
// language JSON resource path
path: `${__dirname}/src/intl`,
nhsz marked this conversation as resolved.
Show resolved Hide resolved
path: path.resolve(`src/intl`),
// supported language
languages: supportedLanguages,
// language file path
Expand Down Expand Up @@ -125,7 +131,7 @@ const config = {
gatsbyRemarkPlugins: [
{
// Local plugin to adjust the images urls of the translated md files
resolve: require.resolve(`./plugins/gatsby-remark-image-urls`),
resolve: path.resolve(`./plugins/gatsby-remark-image-urls`),
},
{
resolve: `gatsby-remark-autolink-headers`,
Expand Down Expand Up @@ -181,15 +187,15 @@ const config = {
resolve: `gatsby-source-filesystem`,
options: {
name: `assets`,
path: `${__dirname}/src/assets`,
path: path.resolve(`src/assets`),
},
},
// Process files from /src/content/ (used in gatsby-node.js)
{
resolve: `gatsby-source-filesystem`,
options: {
name: `content`,
path: `${__dirname}/src/content`,
path: path.resolve(`src/content`),
ignore: [...ignoreContent, ...ignoreTranslations],
},
},
Expand All @@ -198,13 +204,13 @@ const config = {
resolve: `gatsby-source-filesystem`,
options: {
name: `data`,
path: `${__dirname}/src/data`,
path: path.resolve(`src/data`),
},
},
{
resolve: `gatsby-source-filesystem`,
options: {
path: `${__dirname}/src/data/translation-reports`,
path: path.resolve(`src/data/translation-reports`),
},
},
// Process files within /src/data/
Expand Down Expand Up @@ -250,4 +256,4 @@ if (!isPreviewDeploy) {
]
}

module.exports = config
export default config
Loading