Skip to content

Commit

Permalink
feat: add index.html for better preview
Browse files Browse the repository at this point in the history
  • Loading branch information
ChefJerry committed Sep 13, 2023
1 parent 0324efb commit 4026111
Show file tree
Hide file tree
Showing 6 changed files with 72 additions and 2 deletions.
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,6 @@ $ bun makelist pancakeswap-top-100

## Deploying

Token lists will be auto-deployed via netlify when PR is merged to master. Be sure to build the list with `bun makelist list-name` before submitting/merging the PR since it doesn't make much sense building lists within Netlify (because most errors are related to wrong token information and should be fixed prior to landing into master)
Token lists will be auto-deployed via Cloudflare Pages when PR is merged to master. Be sure to build the list with `bun makelist list-name` before submitting/merging the PR since it doesn't make much sense building lists within Pages (because most errors are related to wrong token information and should be fixed prior to landing into master)

Netlify simply takes the json files under `lists` directory and hosts them on `tokens.pancakeswap.finance/list-name.json`
Pages simply takes the json files under `lists` directory and hosts them on `tokens.pancakeswap.finance/list-name.json`
4 changes: 4 additions & 0 deletions index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import topTokens from "./src/top-100.js";
import fetchThirdPartyList from "./src/fetchThirdPartyList.js";
import { LISTS } from "./src/constants.js";
import { exec } from "child_process";
import { buildIndex } from "./src/buildIndex.js";

const command = process.argv[2];
const listName = process.argv[3];
Expand Down Expand Up @@ -38,6 +39,9 @@ switch (command) {
throw new Error(`Failed to generate list ${listName}`);
}
break;
case 'makeindex':
await buildIndex(LISTS);
break;
case "fetch":
checkListName();
if (listName === "pcs-top-100") {
Expand Down
29 changes: 29 additions & 0 deletions lists/index.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
<!DOCTYPE html>
<html lang="en">

<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>PancakeSwap Token Lists</title>
</head>

<body>

<script type="module">
const LISTS = {"pancakeswap-aptos":{"name":"PancakeSwap Aptos","keywords":["pancakeswap","aptos"],"logoURI":"https://pancakeswap.finance/logo.png","sort":true,"schema":"aptos","test":{"skipLogo":true,"aptos":true}},"pancakeswap-zksync-default":{"name":"PancakeSwap Zksync Default","keywords":["pancakeswap","default","zksync"],"logoURI":"https://pancakeswap.finance/logo.png","sort":false},"pancakeswap-linea-default":{"name":"PancakeSwap Linea Default","keywords":["pancakeswap","default","linea"],"logoURI":"https://pancakeswap.finance/logo.png","sort":false},"pancakeswap-base-default":{"name":"PancakeSwap Base Default","keywords":["pancakeswap","default","base"],"logoURI":"https://pancakeswap.finance/logo.png","sort":false},"pancakeswap-polygon-zkevm-default":{"name":"PancakeSwap Zkevm Default","keywords":["pancakeswap","default","polygon","zkevm"],"logoURI":"https://pancakeswap.finance/logo.png","sort":false},"pancakeswap-arbitrum-default":{"name":"PancakeSwap Arbitrum Default","keywords":["pancakeswap","default","arbitrum"],"logoURI":"https://pancakeswap.finance/logo.png","sort":false},"pancakeswap-eth-default":{"name":"PancakeSwap Ethereum Default","keywords":["pancakeswap","default","ethereum"],"logoURI":"https://pancakeswap.finance/logo.png","sort":false},"pancakeswap-eth-mm":{"name":"PancakeSwap Ethereum MM","keywords":["pancakeswap","mm","ethereum"],"logoURI":"https://pancakeswap.finance/logo.png","sort":false},"pancakeswap-bnb-mm":{"name":"PancakeSwap BNB Chain MM","keywords":["pancakeswap","mm","bnb"],"logoURI":"https://pancakeswap.finance/logo.png","sort":false},"pancakeswap-default":{"name":"PancakeSwap Default","keywords":["pancakeswap","default"],"logoURI":"https://pancakeswap.finance/logo.png","sort":false},"pancakeswap-extended":{"name":"PancakeSwap Extended","keywords":["pancakeswap","extended"],"logoURI":"https://pancakeswap.finance/logo.png","sort":true},"pancakeswap-top-100":{"name":"PancakeSwap Top 100","keywords":["pancakeswap","top 100"],"logoURI":"https://pancakeswap.finance/logo.png","sort":true},"pancakeswap-top-15":{"name":"PancakeSwap Top 15","keywords":["pancakeswap","top 15"],"logoURI":"https://pancakeswap.finance/logo.png","sort":true},"coingecko":{"name":"CoinGecko","keywords":["defi"],"logoURI":"https://tokens.pancakeswap.finance/images/projects/coingecko.png","sort":true,"test":{"skipLogo":true,"aptos":false}},"cmc":{"name":"CoinMarketCap","keywords":["defi"],"logoURI":"https://ipfs.io/ipfs/QmQAGtNJ2rSGpnP6dh6PPKNSmZL8RTZXmgFwgTdy5Nz5mx","sort":true,"test":{"skipLogo":true,"aptos":false}},"pancakeswap-mini":{"name":"PancakeSwap Mini","keywords":["pancakeswap","binance","mini program","mini"],"logoURI":"https://pancakeswap.finance/logo.png","sort":true},"pancakeswap-mini-extended":{"name":"PancakeSwap Mini Ext","keywords":["pancakeswap","binance","mini program","mini","extended"],"logoURI":"https://pancakeswap.finance/logo.png","sort":true},"pancakeswap-onramp":{"name":"PancakeSwap Onramp","keywords":["pancakeswap","onramp"],"logoURI":"https://pancakeswap.finance/logo.png","sort":true}};

const lis = Object.keys(LISTS).map((list) => {
return `
<li>
<a href="/${list}.json">${list}</a>
</li>
<br />
`
});
const ul = document.createElement('ul');
ul.innerHTML = lis.join('');
document.body.appendChild(ul);
</script>
</body>

</html>
1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
"checksum": "bun run index.ts checksum",
"generate": "bun run index.ts generate",
"makelist": "bun run index.ts makelist",
"makeindex": "bun run index.ts makeindex",
"lint": "eslint 'src/**/*.{js,jsx,ts,tsx}'",
"fetch": "bun run index.ts fetch",
"test": "bun test",
Expand Down
7 changes: 7 additions & 0 deletions src/buildIndex.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@

export const buildIndex = async (lists: Record<string, unknown>) => {
const html = await Bun.file(`src/index.html`).text()

const newContent = html.replace('`<!--LISTS-->`', JSON.stringify(lists));
await Bun.write('lists/index.html', newContent)
}
29 changes: 29 additions & 0 deletions src/index.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
<!DOCTYPE html>
<html lang="en">

<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>PancakeSwap Token Lists</title>
</head>

<body>

<script type="module">
const LISTS = `<!--LISTS-->`;

const lis = Object.keys(LISTS).map((list) => {
return `
<li>
<a href="/${list}.json">${list}</a>
</li>
<br />
`
});
const ul = document.createElement('ul');
ul.innerHTML = lis.join('');
document.body.appendChild(ul);
</script>
</body>

</html>

0 comments on commit 4026111

Please sign in to comment.