Skip to content

Commit 6f20311

Browse files
authored
Merge pull request #149 from ethereum/refactorMd
Refactor out temporalAllowedPages in md.ts
2 parents ff4f754 + 36787ef commit 6f20311

File tree

2 files changed

+24
-256
lines changed

2 files changed

+24
-256
lines changed

.env.example

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,10 @@ NEXT_PUBLIC_GITHUB_TOKEN_READ_ONLY=insertValue
1313
# Folders or files to ignore from the `public/content` folder
1414
IGNORE_CONTENT=**/docs,**/tutorials
1515

16+
# Allowed markdown files. Use to limit the scope of the build. Leave empty to build all pages
17+
# e.g. `/developers/docs/dapps,/developers/docs/scaling` will build the dapps and scaling pages in the develeper docs, but not the rest of the markdown pages
18+
ALLOWED_PAGES=
19+
1620
# Used to avoid loading Matomo in our preview deploys
1721
IS_PREVIEW_DEPLOY=false
1822

src/lib/utils/md.ts

Lines changed: 20 additions & 256 deletions
Original file line numberDiff line numberDiff line change
@@ -13,253 +13,14 @@ import { toPosixPath } from "./relativePath"
1313

1414
const CURRENT_CONTENT_DIR = join(process.cwd(), CONTENT_DIR)
1515

16+
const cleanPath = (path: string, CURRENT_CONTENT_DIR: string) => {
17+
return path.replace(CURRENT_CONTENT_DIR, "")
18+
.replace("/translations", "")
19+
.replace("/index.md", "")
20+
}
21+
1622
const getPostSlugs = (dir: string, files: string[] = []) => {
1723
const contentDir = join(CURRENT_CONTENT_DIR, dir)
18-
// Temporal list of content pages allowed to be compiled
19-
// When a content page is migrated (and he components being used), should be added to this list
20-
const temporalAllowedPages = [
21-
// Use cases (7/7) ✅
22-
"/dao",
23-
"/decentralized-identity",
24-
"/defi",
25-
"/desci",
26-
"/nft",
27-
"/refi",
28-
"/social-networks",
29-
// Staking (4/4) ✅
30-
"/staking/pools",
31-
"/staking/saas",
32-
"/staking/solo",
33-
"/staking/withdrawals",
34-
// Roadmap (5/5) ✅
35-
"/roadmap",
36-
"/roadmap/future-proofing",
37-
"/roadmap/scaling",
38-
"/roadmap/security",
39-
"/roadmap/user-experience",
40-
// Upgrade (2/2) ✅
41-
"/roadmap/beacon-chain",
42-
"/roadmap/merge",
43-
// Developer docs (0/95)
44-
"/developers/docs/",
45-
"/developers/docs/accounts",
46-
"/developers/docs/apis/backend",
47-
"/developers/docs/apis/javascript",
48-
"/developers/docs/apis/json-rpc",
49-
"/developers/docs/blocks",
50-
"/developers/docs/bridges",
51-
"/developers/docs/consensus-mechanisms",
52-
"/developers/docs/consensus-mechanisms/pos",
53-
"/developers/docs/consensus-mechanisms/pos/attack-and-defense",
54-
"/developers/docs/consensus-mechanisms/pos/attestations",
55-
"/developers/docs/consensus-mechanisms/pos/block-proposal",
56-
"/developers/docs/consensus-mechanisms/pos/faqs",
57-
"/developers/docs/consensus-mechanisms/pos/gasper",
58-
"/developers/docs/consensus-mechanisms/pos/keys",
59-
"/developers/docs/consensus-mechanisms/pos/pos-vs-pow",
60-
"/developers/docs/consensus-mechanisms/pos/rewards-and-penalties",
61-
"/developers/docs/consensus-mechanisms/pos/weak-subjectivity",
62-
"/developers/docs/consensus-mechanisms/pow/",
63-
"/developers/docs/consensus-mechanisms/pow/mining",
64-
"/developers/docs/consensus-mechanisms/pow/mining-algorithms",
65-
"/developers/docs/consensus-mechanisms/pow/mining-algorithms/dagger-hashimoto",
66-
"/developers/docs/consensus-mechanisms/pow/mining-algorithms/ethash",
67-
"/developers/docs/dapps",
68-
"/developers/docs/data-and-analytics",
69-
"/developers/docs/data-and-analytics/block-explorers",
70-
"/developers/docs/data-availability",
71-
"/developers/docs/data-structures-and-encoding",
72-
"/developers/docs/data-structures-and-encoding/patricia-merkle-trie",
73-
"/developers/docs/data-structures-and-encoding/rlp",
74-
"/developers/docs/data-structures-and-encoding/ssz",
75-
"/developers/docs/data-structures-and-encoding/web3-secret-storage",
76-
"/developers/docs/design-and-ux",
77-
"/developers/docs/development-networks",
78-
"/developers/docs/ethereum-stack",
79-
"/developers/docs/evm",
80-
"/developers/docs/evm/opcodes",
81-
"/developers/docs/frameworks",
82-
"/developers/docs/gas",
83-
"/developers/docs/ides",
84-
"/developers/docs/intro-to-ether",
85-
"/developers/docs/intro-to-ethereum",
86-
"/developers/docs/mev",
87-
"/developers/docs/networking-layer",
88-
"/developers/docs/networking-layer/network-addresses",
89-
"/developers/docs/networking-layer/portal-network",
90-
"/developers/docs/networks",
91-
"/developers/docs/nodes-and-clients",
92-
"/developers/docs/nodes-and-clients/archive-nodes",
93-
"/developers/docs/nodes-and-clients/bootnodes",
94-
"/developers/docs/nodes-and-clients/client-diversity",
95-
"/developers/docs/nodes-and-clients/light-clients",
96-
"/developers/docs/nodes-and-clients/node-architecture",
97-
"/developers/docs/nodes-and-clients/nodes-as-a-service",
98-
"/developers/docs/nodes-and-clients/run-a-node",
99-
"/developers/docs/oracles",
100-
"/developers/docs/programming-languages",
101-
"/developers/docs/programming-languages/dart",
102-
"/developers/docs/programming-languages/delphi",
103-
"/developers/docs/programming-languages/dot-net",
104-
"/developers/docs/programming-languages/golang",
105-
"/developers/docs/programming-languages/java",
106-
"/developers/docs/programming-languages/javascript",
107-
"/developers/docs/programming-languages/python",
108-
"/developers/docs/programming-languages/ruby",
109-
"/developers/docs/programming-languages/rust",
110-
"/developers/docs/scaling",
111-
"/developers/docs/scaling/optimistic-rollups",
112-
"/developers/docs/scaling/plasma",
113-
"/developers/docs/scaling/sidechains",
114-
"/developers/docs/scaling/state-channels",
115-
"/developers/docs/scaling/validium",
116-
"/developers/docs/scaling/zk-rollups",
117-
"/developers/docs/smart-contracts",
118-
"/developers/docs/smart-contracts/anatomy",
119-
"/developers/docs/smart-contracts/compiling",
120-
"/developers/docs/smart-contracts/composability",
121-
"/developers/docs/smart-contracts/deploying",
122-
"/developers/docs/smart-contracts/formal-verification",
123-
"/developers/docs/smart-contracts/languages",
124-
"/developers/docs/smart-contracts/libraries",
125-
"/developers/docs/smart-contracts/security",
126-
"/developers/docs/smart-contracts/testing",
127-
"/developers/docs/smart-contracts/upgrading",
128-
"/developers/docs/smart-contracts/verifying",
129-
"/developers/docs/standards",
130-
"/developers/docs/standards/tokens",
131-
"/developers/docs/standards/tokens/erc-20",
132-
"/developers/docs/standards/tokens/erc-721",
133-
"/developers/docs/standards/tokens/erc-777",
134-
"/developers/docs/standards/tokens/erc-1155",
135-
"/developers/docs/standards/tokens/erc-4626",
136-
"/developers/docs/storage",
137-
"/developers/docs/transactions",
138-
"/developers/docs/web2-vs-web3",
139-
// Developer tutorials (53/53) ✅
140-
"/developers/tutorials/a-developers-guide-to-ethereum-part-one",
141-
"/developers/tutorials/all-you-can-cache",
142-
"/developers/tutorials/calling-a-smart-contract-from-javascript",
143-
"/developers/tutorials/create-and-deploy-a-defi-app",
144-
"/developers/tutorials/deploying-your-first-smart-contract",
145-
"/developers/tutorials/develop-and-test-dapps-with-a-multi-client-local-eth-testnet",
146-
"/developers/tutorials/downsizing-contracts-to-fight-the-contract-size-limit",
147-
"/developers/tutorials/eip-1271-smart-contract-signatures",
148-
"/developers/tutorials/erc-721-vyper-annotated-code",
149-
"/developers/tutorials/erc20-annotated-code",
150-
"/developers/tutorials/erc20-with-safety-rails",
151-
"/developers/tutorials/getting-started-with-ethereum-development-using-alchemy",
152-
"/developers/tutorials/guide-to-smart-contract-security-tools",
153-
"/developers/tutorials/hello-world-smart-contract",
154-
"/developers/tutorials/hello-world-smart-contract-fullstack",
155-
"/developers/tutorials/how-to-implement-an-erc721-market",
156-
"/developers/tutorials/how-to-mint-an-nft",
157-
"/developers/tutorials/how-to-mock-solidity-contracts-for-testing",
158-
"/developers/tutorials/how-to-use-echidna-to-test-smart-contracts",
159-
"/developers/tutorials/how-to-use-manticore-to-find-smart-contract-bugs",
160-
"/developers/tutorials/how-to-use-slither-to-find-smart-contract-bugs",
161-
"/developers/tutorials/how-to-use-tellor-as-your-oracle",
162-
"/developers/tutorials/how-to-view-nft-in-metamask",
163-
"/developers/tutorials/how-to-write-and-deploy-an-nft",
164-
"/developers/tutorials/interact-with-other-contracts-from-solidity",
165-
"/developers/tutorials/kickstart-your-dapp-frontend-development-with-create-eth-app",
166-
"/developers/tutorials/learn-foundational-ethereum-topics-with-sql",
167-
"/developers/tutorials/logging-events-smart-contracts",
168-
"/developers/tutorials/merkle-proofs-for-offline-data-integrity",
169-
"/developers/tutorials/monitoring-geth-with-influxdb-and-grafana",
170-
"/developers/tutorials/nft-minter",
171-
"/developers/tutorials/optimism-std-bridge-annotated-code",
172-
"/developers/tutorials/reverse-engineering-a-contract",
173-
"/developers/tutorials/run-node-raspberry-pi",
174-
"/developers/tutorials/scam-token-tricks",
175-
"/developers/tutorials/secure-development-workflow",
176-
"/developers/tutorials/send-token-ethersjs",
177-
"/developers/tutorials/sending-transactions-using-web3-and-alchemy",
178-
"/developers/tutorials/set-up-web3js-to-use-ethereum-in-javascript",
179-
"/developers/tutorials/short-abi",
180-
"/developers/tutorials/smart-contract-security-guidelines",
181-
"/developers/tutorials/solidity-and-truffle-continuous-integration-setup",
182-
"/developers/tutorials/testing-erc-20-tokens-with-waffle",
183-
"/developers/tutorials/the-graph-fixing-web3-data-querying",
184-
"/developers/tutorials/token-integration-checklist",
185-
"/developers/tutorials/transfers-and-approval-of-erc-20-tokens-from-a-solidity-smart-contract",
186-
"/developers/tutorials/understand-the-erc-20-token-smart-contract",
187-
"/developers/tutorials/uniswap-v2-annotated-code",
188-
"/developers/tutorials/using-websockets",
189-
"/developers/tutorials/waffle-dynamic-mocking-and-testing-calls",
190-
"/developers/tutorials/waffle-say-hello-world-with-hardhat-and-ethers",
191-
"/developers/tutorials/waffle-test-simple-smart-contract",
192-
"/developers/tutorials/yellow-paper-evm",
193-
// Static (68/68) ✅
194-
"/about",
195-
"/bridges",
196-
"/community/code-of-conduct",
197-
"/community/events",
198-
"/community/get-involved",
199-
"/community/grants",
200-
"/community/language-resources",
201-
"/community/online",
202-
"/community/research",
203-
"/community/support",
204-
"/contributing",
205-
"/contributing/adding-desci-projects",
206-
"/contributing/adding-developer-tools",
207-
"/contributing/adding-exchanges",
208-
"/contributing/adding-glossary-terms",
209-
"/contributing/adding-layer-2s",
210-
"/contributing/adding-products",
211-
"/contributing/adding-staking-products",
212-
"/contributing/adding-wallets",
213-
"/contributing/content-resources",
214-
"/contributing/design",
215-
"/contributing/design/adding-design-resources",
216-
"/contributing/design-principles",
217-
"/contributing/quizzes",
218-
"/contributing/style-guide",
219-
"/contributing/style-guide/content-standardization",
220-
"/contributing/translation-program",
221-
"/contributing/translation-program/content-buckets",
222-
"/contributing/translation-program/faq",
223-
"/contributing/translation-program/how-to-translate",
224-
"/contributing/translation-program/mission-and-vision",
225-
"/contributing/translation-program/playbook",
226-
"/contributing/translation-program/resources",
227-
"/contributing/translation-program/translatathon",
228-
"/contributing/translation-program/translators-guide",
229-
"/cookie-policy",
230-
"/deprecated-software",
231-
"/eips",
232-
"/energy-consumption",
233-
"/enterprise",
234-
"/enterprise/private-ethereum",
235-
"/foundation",
236-
"/glossary",
237-
"/governance",
238-
"/guides",
239-
"/guides/how-to-create-an-ethereum-account",
240-
"/guides/how-to-id-scam-tokens",
241-
"/guides/how-to-revoke-token-access",
242-
"/guides/how-to-swap-tokens",
243-
"/guides/how-to-use-a-bridge",
244-
"/guides/how-to-use-a-wallet",
245-
"/history/",
246-
"/privacy-policy",
247-
"/roadmap/account-abstraction",
248-
"/roadmap/danksharding",
249-
"/roadmap/merge/issuance",
250-
"/roadmap/pbs",
251-
"/roadmap/secret-leader-election",
252-
"/roadmap/single-slot-finality",
253-
"/roadmap/statelessness",
254-
"/roadmap/verkle-trees",
255-
"/security",
256-
"/smart-contracts",
257-
"/staking/dvt",
258-
"/terms-of-use",
259-
"/web3",
260-
"/whitepaper",
261-
"/zero-knowledge-proofs",
262-
]
26324

26425
// Get an array of all files and directories in the passed directory using `fs.readdirSync`
26526
const fileList = fs.readdirSync(contentDir)
@@ -279,19 +40,22 @@ const getPostSlugs = (dir: string, files: string[] = []) => {
27940
const fileExtension = extname(name)
28041

28142
if (fileExtension === ".md") {
282-
// If it is a .md file (allowed content page), push the path to the files array
283-
for (const page of temporalAllowedPages) {
284-
const fullPagePath = join(CURRENT_CONTENT_DIR, page)
285-
286-
if (name.includes(fullPagePath)) {
287-
files.push(
288-
toPosixPath(
289-
fullPagePath
290-
.replace(CURRENT_CONTENT_DIR, "")
291-
.replace("/index.md", "")
43+
if (process.env.ALLOWED_PAGES) {
44+
process.env.ALLOWED_PAGES.split(",").forEach((page) => {
45+
if (name.includes(page)) {
46+
files.push(
47+
toPosixPath(
48+
cleanPath(name, CURRENT_CONTENT_DIR)
49+
)
29250
)
51+
}
52+
})
53+
} else {
54+
files.push(
55+
toPosixPath(
56+
cleanPath(name, CURRENT_CONTENT_DIR)
29357
)
294-
}
58+
)
29559
}
29660
}
29761
}

0 commit comments

Comments
 (0)