Commit 12088540 authored by Igor Stuev's avatar Igor Stuev Committed by GitHub

Merge pull request #239 from blockscout/redirects

Redirects
parents fab13d4a bff2dbbb
const BASE_PATH = require('../../lib/link/basePath.js');
const PATHS = require('../../lib/link/paths.js');
const oldUrls = [
{
oldPath: '/account/tag_address',
newPath: `${ PATHS.private_tags }?tab=address`,
},
{
oldPath: '/account/tag_transaction',
newPath: `${ PATHS.private_tags }?tab=tx`,
},
{
oldPath: '/pending-transactions',
newPath: `${ PATHS.txs }?tab=pending`,
},
{
oldPath: '/tx/:id/internal-transactions',
newPath: `${ PATHS.tx }?tab=internal`,
},
{
oldPath: '/tx/:id/logs',
newPath: `${ PATHS.tx }?tab=logs`,
},
{
oldPath: '/tx/:id/raw-trace',
newPath: `${ PATHS.tx }?tab=raw_trace`,
},
{
oldPath: '/tx/:id/state',
newPath: `${ PATHS.tx }?tab=state`,
},
{
oldPath: '/uncles',
newPath: `${ PATHS.blocks }?tab=uncles`,
},
{
oldPath: '/reorgs',
newPath: `${ PATHS.blocks }?tab=reorgs`,
},
{
oldPath: '/block/:id/transactions',
newPath: `${ PATHS.block }?tab=txs`,
},
];
async function redirects() {
const homePagePath = '/' + [ process.env.NEXT_PUBLIC_NETWORK_TYPE, process.env.NEXT_PUBLIC_NETWORK_SUBTYPE ].filter(Boolean).join('/');
return [
{
source: '/',
destination: homePagePath,
permanent: false,
},
...oldUrls.map(item => {
const source = BASE_PATH.replaceAll('[', ':').replaceAll(']', '') + item.oldPath;
const destination = item.newPath.replaceAll('[', ':').replaceAll(']', '');
return { source, destination, permanent: false };
}),
];
}
......
const BASE_PATH = '/[network_type]/[network_sub_type]';
module.exports = BASE_PATH;
const BASE_PATH = require('./basePath');
const paths = {
network_index: `${ BASE_PATH }`,
watchlist: `${ BASE_PATH }/account/watchlist`,
private_tags: `${ BASE_PATH }/account/tag_address`,
public_tags: `${ BASE_PATH }/account/public_tags_request`,
api_keys: `${ BASE_PATH }/account/api_key`,
custom_abi: `${ BASE_PATH }/account/custom_abi`,
profile: `${ BASE_PATH }/auth/profile`,
txs: `${ BASE_PATH }/txs`,
tx: `${ BASE_PATH }/tx/[id]`,
blocks: `${ BASE_PATH }/blocks`,
block: `${ BASE_PATH }/block/[id]`,
tokens: `${ BASE_PATH }/tokens`,
token_index: `${ BASE_PATH }/token/[id]`,
address_index: `${ BASE_PATH }/address/[id]`,
address_contract_verification: `${ BASE_PATH }/address/[id]/contract_verifications/new`,
apps: `${ BASE_PATH }/apps`,
app_index: `${ BASE_PATH }/apps/[id]`,
search_results: `${ BASE_PATH }/search-results`,
other: `${ BASE_PATH }/search-results`,
// no slash required, it is correct
auth: `${ BASE_PATH }auth/auth0`,
};
module.exports = paths;
import appConfig from 'configs/app/config';
import PATHS from './paths.js';
export interface Route {
pattern: string;
crossNetworkNavigation?: boolean; // route will not change when switching networks
}
import appConfig from 'configs/app/config';
export type RouteName = keyof typeof ROUTES;
const BASE_PATH = '/[network_type]/[network_sub_type]';
export const ROUTES = {
// NETWORK MAIN PAGE
network_index: {
pattern: `${ BASE_PATH }`,
pattern: PATHS.network_index,
crossNetworkNavigation: true,
},
// ACCOUNT
watchlist: {
pattern: `${ BASE_PATH }/account/watchlist`,
pattern: PATHS.watchlist,
},
private_tags: {
pattern: `${ BASE_PATH }/account/tag_address`,
pattern: PATHS.private_tags,
},
public_tags: {
pattern: `${ BASE_PATH }/account/public_tags_request`,
pattern: PATHS.public_tags,
},
api_keys: {
pattern: `${ BASE_PATH }/account/api_key`,
pattern: PATHS.api_keys,
},
custom_abi: {
pattern: `${ BASE_PATH }/account/custom_abi`,
pattern: PATHS.custom_abi,
},
profile: {
pattern: `${ BASE_PATH }/auth/profile`,
pattern: PATHS.profile,
},
// TRANSACTIONS
txs: {
pattern: `${ BASE_PATH }/txs`,
pattern: PATHS.txs,
crossNetworkNavigation: true,
},
tx: {
pattern: `${ BASE_PATH }/tx/[id]`,
pattern: PATHS.tx,
},
// BLOCKS
blocks: {
pattern: `${ BASE_PATH }/blocks`,
pattern: PATHS.blocks,
crossNetworkNavigation: true,
},
block: {
pattern: `${ BASE_PATH }/block/[id]`,
pattern: PATHS.block,
},
// TOKENS
tokens: {
pattern: `${ BASE_PATH }/tokens`,
pattern: PATHS.tokens,
crossNetworkNavigation: true,
},
token_index: {
pattern: `${ BASE_PATH }/token/[id]`,
pattern: PATHS.token_index,
crossNetworkNavigation: true,
},
// ADDRESSES
address_index: {
pattern: `${ BASE_PATH }/address/[id]`,
pattern: PATHS.address_index,
crossNetworkNavigation: true,
},
address_contract_verification: {
pattern: `${ BASE_PATH }/address/[id]/contract_verifications/new`,
pattern: PATHS.address_contract_verification,
crossNetworkNavigation: true,
},
// APPS
apps: {
pattern: `${ BASE_PATH }/apps`,
pattern: PATHS.apps,
},
app_index: {
pattern: `${ BASE_PATH }/apps/[id]`,
pattern: PATHS.app_index,
},
// SEARCH
search_results: {
pattern: `${ BASE_PATH }/apps`,
pattern: PATHS.search_results,
},
// ??? what URL will be here
other: {
pattern: `${ BASE_PATH }/search-results`,
pattern: PATHS.other,
},
// AUTH
auth: {
// no slash required, it is correct
pattern: `${ BASE_PATH }auth/auth0`,
pattern: PATHS.auth,
},
};
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment