Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

add active locales #3201

Merged
merged 1 commit into from
Mar 12, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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