-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
serve robots.txt from yari (mdn#4186)
* serve robots.txt from yari * serve robots.txt from yari * feedbacked * eslint fix
- Loading branch information
Showing
11 changed files
with
94 additions
and
18 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
/** | ||
* This script generates a /robots.txt file that depends on | ||
* process.env.BUILD_ALWAYS_ALLOW_ROBOTS. | ||
* | ||
*/ | ||
const fs = require("fs"); | ||
|
||
const { VALID_LOCALES } = require("../libs/constants"); | ||
const { ALWAYS_ALLOW_ROBOTS } = require("../build/constants"); | ||
|
||
const ALLOW_TEXT = ` | ||
User-agent: * | ||
Sitemap: https://developer.mozilla.org/sitemap.xml | ||
Disallow: /api/ | ||
Disallow: /*/files/ | ||
Disallow: /media | ||
`; | ||
|
||
const DISALLOW_TEXT = ` | ||
User-Agent: * | ||
Disallow: / | ||
`; | ||
|
||
async function runBuildRobotsTxt(outfile) { | ||
let content = ALWAYS_ALLOW_ROBOTS ? ALLOW_TEXT : DISALLOW_TEXT; | ||
if (ALWAYS_ALLOW_ROBOTS) { | ||
// Append extra lines specifically when we do allow robots. | ||
for (const locale of VALID_LOCALES.values()) { | ||
content += `Disallow: /${locale}/search\n`; | ||
} | ||
} | ||
fs.writeFileSync(outfile, `${content.trim()}\n`, "utf-8"); | ||
} | ||
|
||
module.exports = { runBuildRobotsTxt }; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters