Fix search and indexing

This commit is contained in:
fabioberger
2019-08-26 17:51:38 +02:00
parent dcede832c8
commit b975ac7c31
8 changed files with 538 additions and 17 deletions

View File

@@ -70,7 +70,7 @@ export ALGOLIA_ADMIN_API_KEY={YOUR_ADMIN_API_KEY}
yarn index_docs
```
The above script will index all the docs found in the `/mdx` folder on [Algolia](https://www.algolia.com/). It's possible to pass in arguments that match the directory names to index only those document types, i.e. `yarn index_docs tools coreConcepts` will index tools and core concepts.
The above script will index all the docs found in the `/mdx` folder on [Algolia](https://www.algolia.com/). It's possible to pass in arguments that match the directory names to index only those document types, i.e. `yarn index_docs tools core-concepts` will index tools and core concepts.
Running the script updates some of the meta information about the files (relative paths to files and versions of the doc). For other types of information (i.e. title, subtitle, tags...) you will have to update it yourself.

View File

@@ -40,8 +40,8 @@ const sharedSettings = {
};
const settings: ObjectMap<IAlgoliaSettings> = {
apiExplorer: sharedSettings,
coreConcepts: sharedSettings,
'api-explorer': sharedSettings,
'core-concepts': sharedSettings,
guides: {
...sharedSettings,
attributesForFaceting: ['topics', 'difficulty'],
@@ -84,7 +84,7 @@ export async function indexFilesAsync(indexName: string, environment: string): P
}
function getNameToFile(dirName: string): ObjectMap<File> {
const dirPath = path.join(__dirname, `../../mdx/${dirName}`);
const dirPath = path.join(__dirname, `../mdx/${dirName}`);
const paths = glob.sync(`${dirPath}/**/*.mdx`);
const nameToFile: ObjectMap<File> = {};
@@ -114,7 +114,7 @@ function getNameToFile(dirName: string): ObjectMap<File> {
nameToFile[name] = { name, path: p, url };
}
if (dirName === 'coreConcepts' || dirName === 'apiExplorer') {
if (dirName === 'core-concepts' || dirName === 'api-explorer') {
const url = `/docs/${dirName}`;
nameToFile[dirName] = { name: dirName, path: p, url };
}

View File

@@ -29,7 +29,7 @@ function processIndices(indices: string[], environment: string): void {
}
}
if (args.index !== undefined) {
if (args.indexes !== undefined) {
processIndices(args.indexes.split(','), args.environment); // Use args given to process and push to algolia
} else {
processIndices(Object.keys(getNameToSearchIndex(args.environment)), args.environment); // Process and push all indices

View File

@@ -0,0 +1,519 @@
{
"api-explorer": {
"api-explorer": {
"title": "API Explorer",
"path": "api-explorer/index.mdx"
}
},
"core-concepts": {
"core-concepts": {
"title": "Core Concepts",
"subtitle": "Learn all the core concepts you'll need to build effectively on 0x",
"path": "core-concepts/index.mdx"
}
},
"guides": {
"build-a-relayer": {
"title": "Build a relayer",
"description": "A relayer is any party or entity which hosts an off-chain orderbook.",
"tags": ["Relayer", "Trader", "Protocol Developer"],
"topics": ["Coordinator Model", "Mesh"],
"difficulty": "Advanced",
"path": "guides/build-a-relayer.mdx"
},
"contract-fillable-liquidity": {
"title": "Contract-fillable Liquidity",
"subtitle": "Swap tokens by tapping into 0x's networked liquidity",
"description": "Use Asset-Swapper to programmatically exchange assets with a single line of code or build custom integrations for more advanced token trades.",
"tags": [""],
"topics": [""],
"difficulty": "Intermediate",
"path": "guides/contract-fillable-liquidity.mdx"
},
"develop-on-ethereum": {
"title": "Develop on Ethereum",
"description": "Welcome to the exciting world of building applications on the Ethereum Blockchain",
"tags": ["Relayer", "Trader"],
"topics": ["Mesh", "Protocol Developer"],
"difficulty": "Beginner",
"path": "guides/develop-on-ethereum.mdx"
},
"deployed-addresses": {
"title": "Deployed Addresses",
"description": "",
"tags": [""],
"topics": [""],
"difficulty": "Beginner",
"path": "guides/deployed-addresses.mdx"
},
"ganache-setup": {
"title": "How to Set Up Ganache",
"description": "",
"topics": ["Ganache"],
"difficulty": "Intermediate",
"isCommunity": false,
"isFeatured": false,
"tags": ["Protocol developer"],
"path": "guides/ganache-setup.mdx"
},
"integrate-instant": {
"title": "Integrate 0x Instant",
"subtitle": "A free and flexible way to offer simple crypto purchasing in any app or website",
"description": "A convenient way to offer your users access to a wide variety of tokens and other crypto-assets in just a few clicks",
"topics": ["Instant"],
"difficulty": "Beginner",
"isCommunity": false,
"isFeatured": false,
"tags": ["Instant"],
"path": "guides/integrate-instant.mdx"
},
"relayer-strategies": {
"title": "Relayer Strategies",
"description": "",
"topics": ["Relayers"],
"difficulty": "Beginner",
"isCommunity": false,
"isFeatured": false,
"tags": ["Relayers"],
"path": "guides/relayer-strategies.mdx"
},
"legal-guide": {
"title": "0x Legal Guide",
"description": "",
"topics": ["Legal"],
"difficulty": "Beginner",
"isCommunity": false,
"isFeatured": true,
"tags": ["Legal"],
"path": "guides/legal-guide.mdx"
},
"page-template": {
"title": "Page template",
"description": "A relayer is any party or entity which hosts an off-chain orderbook.",
"tags": ["Relayer", "Trader", "Protocol Developer"],
"topics": ["Coordinator Model", "Mesh"],
"difficulty": "Advanced",
"path": "guides/page-template.mdx"
},
"use-networked-liquidity": {
"title": "Use networked liquidity",
"description": "In this tutorial, we will show you how you can use the @0x/connect package in conjunction with 0x.js in order to",
"tags": ["Protocol Developer"],
"topics": ["Mesh"],
"difficulty": "Intermediate",
"path": "guides/use-networked-liquidity.mdx"
},
"v2-coordinatior-specification": {
"title": "0x 2.0.0 Coordinator Specification",
"description": "",
"tags": [""],
"topics": [""],
"difficulty": "Advanced",
"path": "guides/v2-coordinatior-specification.mdx"
},
"v2-forwarder-specification": {
"title": "0x 2.0.0 Forwarder Specification",
"description": "",
"tags": [""],
"topics": [""],
"difficulty": "Advanced",
"path": "guides/v2-forwarder-specification.mdx"
},
"v2-specification": {
"title": "0x Protocol 2.0.0 Specification",
"description": "",
"tags": [""],
"topics": [""],
"difficulty": "Advanced",
"path": "guides/v2-specification.mdx"
},
"web3-provider-explained": {
"title": "Web3 Provider Explained",
"subtitle": "Allow your application to communicate with an Ethereum Node",
"description": "Allow your application to request signatures, estimate gas and gas price, and submit transactions to an Ethereum node.",
"tags": [""],
"topics": [""],
"difficulty": "Intermediate",
"path": "guides/web3-provider-explained.mdx"
}
},
"tools": {
"asset-swapper": {
"title": "@0x/asset-swapper",
"description": "Convenience package for discovering and performing swaps for any ERC20 Assets",
"difficulty": "Intermediate",
"isCommunity": false,
"isFeatured": false,
"tags": ["Trader", "Protocol Developer"],
"type": "Typescript Libraries",
"path": "tools/@0x/asset-swapper/v1.0.2/reference.mdx",
"versions": ["v1.0.2"]
},
"0x-js": {
"title": "0x.js",
"description": "An umbrella package that exports all the 0x tools you need to start building on 0x. Includes: @0x/order-utils, @0x/contract-wrappers and @0x/contract-addresses.",
"difficulty": "Beginner",
"isCommunity": false,
"isFeatured": false,
"tags": ["Trader", "Relayer", "Protocol Developer"],
"type": "Typescript Libraries",
"externalUrl": "https://www.npmjs.com/package/0x.js"
},
"connect": {
"title": "@0x/connect",
"description": "An HTTP/WS client for interacting with the Standard Relayer API",
"difficulty": "Beginner",
"isCommunity": false,
"isFeatured": false,
"tags": ["Trader", "Relayer"],
"type": "Typescript Libraries",
"path": "tools/@0x/connect/v5.0.17/reference.mdx",
"versions": ["v5.0.17"]
},
"subproviders": {
"title": "@0x/subproviders",
"description": "Web3 provider middlewares (e.g. LedgerSubprovider)",
"difficulty": "Intermediate",
"isCommunity": false,
"isFeatured": false,
"tags": ["Relayer", "Trader"],
"type": "Typescript Libraries",
"path": "tools/@0x/subproviders/v5.0.2/reference.mdx",
"versions": ["v5.0.2"]
},
"asset-buyer": {
"title": "@0x/asset-buyer",
"description": "Convenience package for discovering and buying assets with Ether",
"difficulty": "Intermediate",
"isCommunity": false,
"isFeatured": false,
"tags": ["Trader", "Protocol Developer"],
"type": "Typescript Libraries",
"path": "tools/@0x/asset-buyer/v6.1.12/reference.mdx",
"versions": ["v6.1.12"],
"isHidden": true
},
"ethereum-types": {
"title": "ethereum-types",
"description": "Typescript types shared across Ethereum-related packages/libraries/tools",
"difficulty": "Beginner",
"isCommunity": false,
"isFeatured": false,
"tags": [],
"type": "Typescript Libraries",
"path": "tools/ethereum-types/v2.1.4/reference.mdx",
"versions": ["v2.1.4"],
"isHidden": true
},
"contract-wrappers": {
"title": "@0x/contract-wrappers",
"description": "0x smart contract wrappers",
"difficulty": "Beginner",
"isCommunity": false,
"isFeatured": false,
"tags": ["Trader", "Relayer"],
"type": "Typescript Libraries",
"isHidden": true,
"path": "tools/@0x/contract-wrappers/v11.1.0/reference.mdx",
"versions": ["v11.1.0"]
},
"json-schemas": {
"title": "@0x/json-schemas",
"description": "0x-related JSON schemas",
"difficulty": "Intermediate",
"isCommunity": false,
"isFeatured": false,
"tags": ["Trader", "Relayer"],
"type": "Typescript Libraries",
"isHidden": true,
"path": "tools/@0x/json-schemas/v4.0.0/reference.mdx",
"versions": ["v4.0.0"]
},
"order-utils": {
"title": "@0x/order-utils",
"description": "A set of utilities for generating, parsing, signing and validating 0x orders",
"difficulty": "Beginner",
"isCommunity": false,
"isFeatured": false,
"tags": ["Trader", "Relayer"],
"type": "Typescript Libraries",
"isHidden": true,
"path": "tools/@0x/order-utils/v8.3.0/reference.mdx",
"versions": ["v8.3.0"]
},
"sol-compiler": {
"title": "@0x/sol-compiler",
"description": "A wrapper around solc-js that adds smart re-compilation, ability to compile an entire project, Solidity version specific compilation, standard input description support and much more.",
"difficulty": "Advanced",
"isCommunity": false,
"isFeatured": false,
"tags": ["Protocol Developer"],
"type": "Typescript Libraries",
"isHidden": true,
"path": "tools/@0x/sol-compiler/v3.1.13/reference.mdx",
"versions": ["v3.1.13"]
},
"sol-coverage": {
"title": "@0x/sol-coverage",
"description": "A solidity test coverage tool",
"difficulty": "Advanced",
"topics": [],
"isCommunity": false,
"isFeatured": false,
"tags": ["Protocol Developer"],
"type": "Typescript Libraries",
"isHidden": true,
"path": "tools/@0x/sol-coverage/v3.0.10/reference.mdx",
"versions": ["v3.0.10"]
},
"sol-profiler": {
"title": "@0x/sol-profiler",
"description": "A solidity gas cost profiler",
"difficulty": "Advanced",
"topics": [],
"isCommunity": false,
"isFeatured": false,
"tags": ["Protocol Developer"],
"type": "Typescript Libraries",
"isHidden": true,
"path": "tools/@0x/sol-profiler/v3.1.12/reference.mdx",
"versions": ["v3.1.12"]
},
"sol-trace": {
"title": "@0x/sol-trace",
"description": "A solidity stack trace tool",
"difficulty": "Advanced",
"topics": [],
"isCommunity": false,
"isFeatured": false,
"tags": ["Protocol Developer"],
"type": "Typescript Libraries",
"isHidden": true,
"path": "tools/@0x/sol-trace/v2.0.18/reference.mdx",
"versions": ["v2.0.18"]
},
"web3-wrapper": {
"title": "@0x/web3-wrapper",
"description": "An Ethereum JSON RPC client",
"difficulty": "Intermediate",
"isCommunity": false,
"isFeatured": false,
"tags": ["Relayer", "Trader"],
"type": "Typescript Libraries",
"isHidden": true,
"path": "tools/@0x/web3-wrapper/v6.0.11/reference.mdx",
"versions": ["v6.0.11"]
},
"mesh-ts-client": {
"description": "A Typescript/Javascript library for interacting with the Mesh JSON-RPC API over WebSockets",
"difficulty": "Intermediate",
"externalUrl": "https://0x-org.gitbook.io/mesh/json-rpc-clients/typescript",
"isCommunity": false,
"isFeatured": false,
"tags": ["Relayer", "Trader"],
"title": "@0x/ts-mesh-client",
"type": "Typescript Libraries"
},
"radar-relay-sdk": {
"title": "RadarRelay SDK",
"description": "The Radar Relay SDK is a software development kit that simplifies the interactions with Radar Relays APIs",
"difficulty": "Beginner",
"externalUrl": "https://developers.radarrelay.com/libraries/sdk",
"isCommunity": true,
"isFeatured": false,
"tags": ["Trader"],
"type": "Typescript Libraries"
},
"tokenlon-sdk": {
"title": "Tokenlon SDK",
"description": "Tokenlon SDK provides APIs for developers to trade of imToken's relayer",
"difficulty": "Beginner",
"externalUrl": "https://www.npmjs.com/package/tokenlon-sdk",
"isCommunity": true,
"isFeatured": false,
"tags": ["Trader"],
"type": "Typescript Libraries"
},
"ganache-cli": {
"title": "0xorg/ganache-cli",
"description": "Spin up a Ganache test Ethereum node with the 0x smart contracts pre-deployed",
"difficulty": "Beginner",
"isCommunity": false,
"isFeatured": false,
"tags": ["Relayer", "Trader", "Protocol Developer"],
"type": "Docker Images",
"externalUrl": "https://hub.docker.com/r/0xorg/ganache-cli"
},
"launch-kit-backend-docker": {
"title": "0xorg/launch-kit-backend",
"description": "A pre-built Standard Relayer API backend server",
"difficulty": "Beginner",
"isCommunity": false,
"isFeatured": false,
"tags": ["Relayer"],
"type": "Docker Images",
"externalUrl": "https://hub.docker.com/r/0xorg/launch-kit-backend"
},
"launch-kit-frontend-docker": {
"title": "0xorg/launch-kit-frontend",
"description": "An ERC20 exchange and ERC721 marketplace React front-end to use with any SRA API backend",
"difficulty": "Beginner",
"isCommunity": false,
"isFeatured": false,
"tags": ["Relayer"],
"type": "Docker Images",
"externalUrl": "https://hub.docker.com/r/0xorg/launch-kit-frontend"
},
"launch-kit-demo": {
"title": "0xorg/launch-kit-demo",
"description": "A demo of the front-end and backend Launch Kits running together",
"difficulty": "Beginner",
"isCommunity": false,
"isFeatured": false,
"tags": ["Relayer"],
"type": "Docker Images",
"externalUrl": "https://hub.docker.com/r/0xorg/launch-kit-demo"
},
"mesh": {
"title": "0xorg/mesh",
"description": "A peer-to-peer network for sharing 0x orders",
"difficulty": "Beginner",
"isCommunity": false,
"isFeatured": false,
"tags": ["Relayer", "trader", "Protocol Developer"],
"type": "Docker Images",
"externalUrl": "https://hub.docker.com/r/0xorg/mesh"
},
"contract-wrappers-py": {
"title": "contract-wrappers-py",
"description": "0x smart contract Python wrappers",
"difficulty": "Beginner",
"isCommunity": false,
"isFeatured": false,
"tags": ["Relayer", "Trader", "Protocol Developer"],
"type": "Python Libraries",
"externalUrl": "https://pypi.org/project/0x-contract-wrappers/"
},
"0x-order-utils": {
"title": "0x-order-utils",
"description": "A set of utilities for generating, parsing, signing and validating 0x orders in Python",
"difficulty": "Beginner",
"isCommunity": false,
"isFeatured": false,
"tags": ["Relayer", "Trader", "Protocol Developer"],
"type": "Python Libraries",
"externalUrl": "https://pypi.org/project/0x-order-utils/"
},
"0x-sra-client": {
"title": "0x-sra-client",
"description": "A Python client for interacting with servers conforming to the Standard Relayer API specification",
"difficulty": "Beginner",
"isCommunity": false,
"isFeatured": false,
"tags": ["Relayer", "Trader"],
"type": "Python Libraries",
"externalUrl": "https://pypi.org/project/0x-sra-client"
},
"open-relay": {
"title": "OpenRelay",
"description": "OpenRelay is an open source relay for the 0x protocol. OpenRelay provides an open, scalable orderbook. Users can post offers for any ERC20 or ERC721 token, or search for trades with other users.",
"difficulty": "Intermediate",
"isCommunity": true,
"isFeatured": false,
"tags": ["Relayer"],
"type": "Golang Libraries",
"externalUrl": "https://github.com/NoteGio/openrelay"
},
"go-mesh-client": {
"title": "Golang Mesh RPC Client",
"description": "A Golang library for interacting with the Mesh JSON-RPC API over WebSockets",
"difficulty": "Beginner",
"isCommunity": false,
"isFeatured": false,
"tags": ["Relayer", "Trader"],
"type": "Golang Libraries",
"externalUrl": "https://godoc.org/github.com/0xProject/0x-mesh/rpc#Client"
},
"launch-kit-frontend": {
"title": "0x Launch Kit Frontend",
"description": "An ERC20 exchange and ERC721 marketplace react frontend UI for any SRA relayer",
"difficulty": "Beginner",
"isCommunity": false,
"isFeatured": false,
"tags": ["Relayer"],
"type": "Starter projects",
"externalUrl": "https://github.com/0xProject/0x-launch-kit-frontend/"
},
"launch-kit-backend": {
"title": "0x Launch Kit Backend",
"description": "An open-source relayer backend that implements the Standard Relayer API",
"difficulty": "Beginner",
"isCommunity": false,
"isFeatured": false,
"tags": ["Relayer"],
"type": "Starter projects",
"externalUrl": "https://github.com/0xProject/0x-launch-kit-backend/"
},
"starter-project": {
"title": "0x Starter Project",
"description": "A project showcasing how to get started with 0x.js. This project will take you through a number of scenarios using the 0x v2 protocol.",
"difficulty": "Beginner",
"isCommunity": false,
"isFeatured": false,
"tags": ["Relayer", "Trader", "Protocol Developer"],
"type": "Starter projects",
"externalUrl": "https://github.com/0xProject/0x-starter-project"
},
"code-sandbox": {
"title": "0x Code Sandbox",
"description": "An online code sandbox for playing around with 0x protocol. Mint test tokens, create, fill, cancel 0x orders and much more.",
"difficulty": "Beginner",
"isCommunity": false,
"isFeatured": true,
"tags": ["Relayer", "Trader", "Protocol Developer"],
"type": "Starter projects",
"externalUrl": "https://codesandbox.io/s/github/0xproject/0x-codesandbox"
},
"migrations": {
"title": "@0x/migrations",
"description": "A package to deploy the 0x protocol's system of smart contracts to the testnet of your choice",
"difficulty": "Advanced",
"isCommunity": false,
"isFeatured": false,
"tags": ["Protocol Developer", "Relayer"],
"type": "Command-line tool",
"path": "tools/@0x/migrations/v4.3.0/reference.mdx",
"versions": ["v4.3.0"]
},
"launch-kit-wizard": {
"title": "@0x/launch-kit-wizard",
"description": "A “create-react-app”-style CLI for spinning up a 0x Relayer",
"difficulty": "Beginner",
"isCommunity": false,
"isFeatured": true,
"tags": ["Relayer"],
"type": "Command-line tool",
"externalUrl": "https://github.com/0xProject/0x-launch-kit"
},
"massive": {
"title": "Massive CLI",
"description": "A set of command-line tools for creating command-line scripts for interacting with the Ethereum blockchain in general, and 0x in particular",
"difficulty": "Intermediate",
"isCommunity": true,
"isFeatured": false,
"tags": ["Relayer", "Trader"],
"type": "Command-line tool",
"externalUrl": "https://github.com/NoteGio/massive"
},
"coordinator-server": {
"title": "Coordinator Server",
"description": "A reference implementation of a 0x coordinator server (soft-cancel variant)",
"difficulty": "Advanced",
"isCommunity": false,
"isFeatured": false,
"tags": ["Relayer"],
"type": "Starter projects",
"externalUrl": "https://github.com/0xProject/0x-coordinator-server"
}
}
}

View File

@@ -109,8 +109,10 @@ const CustomAutoComplete: React.FC<IAutoCompleteProps> = ({
};
const renderSectionTitle = (section: any): React.ReactNode => {
// TODO(fabio): Add `apiExplorer` below once the API Explore page is ready (ditto in search_input.tsx)
const { tools, guides, coreConcepts } = getNameToSearchIndex(environments.getEnvironment());
// TODO(fabio): Add `api-explorer` below once the API Explore page is ready (ditto in search_input.tsx)
const nameToSearchIndex = getNameToSearchIndex(environments.getEnvironment());
const { tools, guides } = nameToSearchIndex;
const coreConcepts = nameToSearchIndex['core-concepts'];
const titles: { [key: string]: string } = {
// TODO: Add this back in when api - explorer page is ready

View File

@@ -19,11 +19,11 @@ export const SearchInput: React.FC<ISearchInputProps> = ({ isHome }) => {
{/* We could map these when we decide to show api explorer in search results */}
<Index indexName={nameToSearchIndex.tools} />
<Index indexName={nameToSearchIndex.guides} />
<Index indexName={nameToSearchIndex.coreConcepts} />
<Index indexName={nameToSearchIndex['core-concepts']} />
{/*
TODO: Add this back in when apiExplorer page is ready
TODO: Add this back in when api-explorer page is ready
to be indexed and included in the search results (ditto in autocomplete.tsx)
<Index indexName={nameToSearchIndex.apiExplorer} />
<Index indexName={nameToSearchIndex.api-explorer} />
*/}
</InstantSearch>
);

View File

@@ -18,8 +18,8 @@ export const hitsPerPage = {
export function getNameToSearchIndex(environment: string): ObjectMap<string> {
const lowercaseEnv = environment.toLowerCase();
const nameToSearchIndex: ObjectMap<string> = {
apiExplorer: `${lowercaseEnv}_api_explorer`,
coreConcepts: `${lowercaseEnv}_core_concepts`,
'api-explorer': `${lowercaseEnv}_api_explorer`,
'core-concepts': `${lowercaseEnv}_core_concepts`,
guides: `${lowercaseEnv}_guides`,
tools: `${lowercaseEnv}_tools`,
};

View File

@@ -1,12 +1,12 @@
{
"apiExplorer": {
"apiExplorer": {
"api-explorer": {
"api-explorer": {
"title": "API Explorer",
"path": "api-explorer/index.mdx"
}
},
"coreConcepts": {
"coreConcepts": {
"core-concepts": {
"core-concepts": {
"title": "Core Concepts",
"subtitle": "Learn all the core concepts you'll need to build effectively on 0x",
"path": "core-concepts/index.mdx"