Skip to content

Commit

Permalink
add active locales (#3201)
Browse files Browse the repository at this point in the history
only show "onGithub" for active locales
  • Loading branch information
fiji-flo authored Mar 12, 2021
1 parent 83cf627 commit 9710df3
Show file tree
Hide file tree
Showing 5 changed files with 10 additions and 2 deletions.
1 change: 1 addition & 0 deletions build/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -225,6 +225,7 @@ async function buildDocument(document, documentOptions = {}) {
const doc = {
isArchive: document.isArchive,
isTranslated: document.isTranslated,
isActive: document.isActive,
};

doc.flaws = {};
Expand Down
2 changes: 1 addition & 1 deletion client/src/document/organisms/metadata/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ export function Metadata({ doc, locale }) {
return (
<aside className="metadata">
<div className="metadata-content-container">
{!doc.isArchive && !doc.isTranslated && <OnGitHubLink doc={doc} />}
{doc.isActive && <OnGitHubLink doc={doc} />}
<p className="last-modified-date">
<LastModified value={doc.modified} locale={locale} />,{" "}
<a href={`${doc.mdn_url}/contributors.txt`}>by MDN contributors</a>
Expand Down
3 changes: 2 additions & 1 deletion content/constants.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
const fs = require("fs");
const path = require("path");
const { VALID_LOCALES } = require("../libs/constants");
const { ACTIVE_LOCALES, VALID_LOCALES } = require("../libs/constants");

require("dotenv").config({
path: path.join(__dirname, "..", process.env.ENV_FILE || ".env"),
Expand Down Expand Up @@ -59,4 +59,5 @@ module.exports = {
REPOSITORY_URLS,
ROOTS,
VALID_LOCALES,
ACTIVE_LOCALES,
};
4 changes: 4 additions & 0 deletions content/document.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ const {
CONTENT_ARCHIVED_ROOT,
CONTENT_TRANSLATED_ROOT,
CONTENT_ROOT,
ACTIVE_LOCALES,
VALID_LOCALES,
ROOTS,
} = require("./constants");
Expand Down Expand Up @@ -242,6 +243,8 @@ const read = memoize((folder) => {
const locale = extractLocale(folder);
const url = `/${locale}/docs/${metadata.slug}`;

const isActive = !isArchive && ACTIVE_LOCALES.has(locale.toLowerCase());

// The last-modified is always coming from the git logs. Independent of
// which root it is.
const gitHistory = getGitHistories(root, locale).get(
Expand Down Expand Up @@ -271,6 +274,7 @@ const read = memoize((folder) => {
...{ rawHTML, rawContent },
isArchive,
isTranslated,
isActive,
fileInfo: {
folder,
path: filePath,
Expand Down
2 changes: 2 additions & 0 deletions libs/constants/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -51,8 +51,10 @@ const LOCALE_ALIASES = new Map([
// This must match what we do in `language-menu/index.tsx` where the cookie
// gets set in the client!
const PREFERRED_LOCALE_COOKIE_NAME = "preferredlocale";
const ACTIVE_LOCALES = new Set(["en-us", "fr", "ja", "zh-cn", "zh-tw"]);

module.exports = {
ACTIVE_LOCALES,
VALID_LOCALES,
DEFAULT_LOCALE,
LOCALE_ALIASES,
Expand Down

0 comments on commit 9710df3

Please sign in to comment.