Skip to content

Commit

Permalink
Merge remote-tracking branch 'origin/main' into playground-lit-console
Browse files Browse the repository at this point in the history
  • Loading branch information
LeoMcA committed Dec 12, 2024
2 parents 3abea39 + 275eab7 commit 55e0881
Show file tree
Hide file tree
Showing 83 changed files with 2,389 additions and 2,264 deletions.
1 change: 1 addition & 0 deletions .env-dist
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
CONTENT_ROOT=../content/files
#CONTENT_TRANSLATED_ROOT=../translated-content/files
#CONTRIBUTOR_SPOTLIGHT_ROOT=../mdn-contributor-spotlight/contributors
#GENERIC_CONTENT_ROOT=../generic-content/files

REACT_APP_DEV_MODE=true

Expand Down
9 changes: 8 additions & 1 deletion .github/workflows/prod-build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -89,6 +89,12 @@ jobs:
lfs: true
token: ${{ secrets.MDN_STUDIO_PAT }}

- uses: actions/checkout@v4
if: ${{ ! vars.SKIP_BUILD }}
with:
repository: mdn/generic-content
path: mdn/generic-content

- uses: actions/checkout@v4
if: ${{ ! vars.SKIP_BUILD }}
with:
Expand Down Expand Up @@ -189,6 +195,7 @@ jobs:
CONTRIBUTOR_SPOTLIGHT_ROOT: ${{ github.workspace }}/mdn/mdn-contributor-spotlight/contributors
BLOG_ROOT: ${{ github.workspace }}/mdn/mdn-studio/content/posts
CURRICULUM_ROOT: ${{ github.workspace }}/mdn/curriculum
GENERIC_CONTENT_ROOT: ${{ github.workspace }}/mdn/generic-content/files
BASE_URL: "https://developer.mozilla.org"

# The default for this environment variable is geared for writers
Expand Down Expand Up @@ -239,7 +246,7 @@ jobs:

# Surveys.
REACT_APP_SURVEY_START_HOMEPAGE_FEEDBACK_2024: 1731369600000 # new Date("2024-11-12Z").getTime()
REACT_APP_SURVEY_END_HOMEPAGE_FEEDBACK_2024: 1733184000000 # new Date("2024-12-03Z").getTime()
REACT_APP_SURVEY_END_HOMEPAGE_FEEDBACK_2024: 1733616000000 # new Date("2024-12-08Z").getTime()
REACT_APP_SURVEY_RATE_FROM_HOMEPAGE_FEEDBACK_2024: 0.0
REACT_APP_SURVEY_RATE_TILL_HOMEPAGE_FEEDBACK_2024: 1 # 100%
REACT_APP_SURVEY_START_WEBDX_EDITING_2024: 1731628800000 # new Date("2024-11-15Z").getTime()
Expand Down
10 changes: 8 additions & 2 deletions .github/workflows/stage-build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -124,6 +124,12 @@ jobs:
lfs: true
token: ${{ secrets.MDN_STUDIO_PAT }}

- uses: actions/checkout@v4
if: ${{ ! vars.SKIP_BUILD }}
with:
repository: mdn/generic-content
path: mdn/generic-content

- uses: actions/checkout@v4
if: ${{ ! vars.SKIP_BUILD }}
with:
Expand Down Expand Up @@ -220,11 +226,11 @@ jobs:
CONTRIBUTOR_SPOTLIGHT_ROOT: ${{ github.workspace }}/mdn/mdn-contributor-spotlight/contributors
BLOG_ROOT: ${{ github.workspace }}/mdn/mdn-studio/content/posts
CURRICULUM_ROOT: ${{ github.workspace }}/mdn/curriculum
GENERIC_CONTENT_ROOT: ${{ github.workspace }}/mdn/generic-content/files
BASE_URL: "https://developer.allizom.org"

# rari
BUILD_OUT_ROOT: "client/build"
GENERIC_CONTENT_ROOT: "copy"
LIVE_SAMPLES_BASE_URL: https://live.mdnyalp.dev
INTERACTIVE_EXAMPLES_BASE_URL: https://interactive-examples.mdn.allizom.net
ADDITIONAL_LOCALES_FOR_GENERICS_AND_SPAS: de
Expand Down Expand Up @@ -312,7 +318,7 @@ jobs:
yarn rari content sync-translated-content
yarn rari git-history
yarn rari build --issues client/build/issues.json --templ-stats
yarn rari build --all --issues client/build/issues.json --templ-stats
# Sort DE search index by en-US popularity.
node scripts/reorder-search-index.mjs client/build/en-us/search-index.json client/build/de/search-index.json
Expand Down
10 changes: 8 additions & 2 deletions .github/workflows/test-build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,12 @@ jobs:
lfs: true
token: ${{ secrets.MDN_STUDIO_PAT }}

- uses: actions/checkout@v4
if: ${{ ! vars.SKIP_BUILD }}
with:
repository: mdn/generic-content
path: mdn/generic-content

- uses: actions/checkout@v4
if: ${{ ! vars.SKIP_BUILD }}
with:
Expand Down Expand Up @@ -130,11 +136,11 @@ jobs:
CONTRIBUTOR_SPOTLIGHT_ROOT: ${{ github.workspace }}/mdn/mdn-contributor-spotlight/contributors
BLOG_ROOT: ${{ github.workspace }}/mdn/mdn-studio/content/posts
CURRICULUM_ROOT: ${{ github.workspace }}/mdn/curriculum
GENERIC_CONTENT_ROOT: ${{ github.workspace }}/mdn/generic-content/files
BASE_URL: "https://test.developer.allizom.org"

# rari
BUILD_OUT_ROOT: "client/build"
GENERIC_CONTENT_ROOT: "copy"
LIVE_SAMPLES_BASE_URL: https://live.test.mdnyalp.dev
INTERACTIVE_EXAMPLES_BASE_URL: https://interactive-examples.mdn.allizom.net
ADDITIONAL_LOCALES_FOR_GENERICS_AND_SPAS: de
Expand Down Expand Up @@ -203,7 +209,7 @@ jobs:
yarn rari content sync-translated-content
yarn rari git-history
yarn rari build --issues client/build/issues.json --templ-stats
yarn rari build --all --issues client/build/issues.json --templ-stats
# SSR all pages
yarn render:html
Expand Down
52 changes: 29 additions & 23 deletions build/spas.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
import fs from "node:fs";
import path from "node:path";
import { fileURLToPath } from "node:url";

import frontmatter from "front-matter";
import { fdir, PathsOutput } from "fdir";
Expand All @@ -22,10 +21,16 @@ import {
CONTRIBUTOR_SPOTLIGHT_ROOT,
BUILD_OUT_ROOT,
DEV_MODE,
GENERIC_CONTENT_ROOT,
} from "../libs/env/index.js";
import { isValidLocale } from "../libs/locale-utils/index.js";
import { DocFrontmatter, DocParent, NewsItem } from "../libs/types/document.js";
import { getSlugByBlogPostUrl, makeTOC } from "./utils.js";
import {
getSlugByBlogPostUrl,
injectLoadingLazyAttributes,
makeTOC,
postProcessExternalLinks,
} from "./utils.js";
import { findByURL } from "../content/document.js";
import { buildDocument } from "./index.js";
import { findPostBySlug } from "./blog.js";
Expand Down Expand Up @@ -145,9 +150,9 @@ export async function buildSPAs(options: {

// The URL isn't very important as long as it triggers the right route in the <App/>
const locale = DEFAULT_LOCALE;
const url = `/${locale}/404.html`;
const url = `/${locale}/404/index.html`;
const context: HydrationData = { url, pageNotFound: true };
const outPath = path.join(BUILD_OUT_ROOT, locale.toLowerCase(), "_spas");
const outPath = path.join(BUILD_OUT_ROOT, locale.toLowerCase(), "404");
fs.mkdirSync(outPath, { recursive: true });
const jsonFilePath = path.join(
outPath,
Expand Down Expand Up @@ -271,7 +276,7 @@ export async function buildSPAs(options: {
async function buildStaticPages(
dirpath: string,
slugPrefix?: string,
title = "MDN"
title?: string
) {
const crawler = new fdir()
.withFullPaths()
Expand All @@ -282,7 +287,7 @@ export async function buildSPAs(options: {

for (const filepath of filepaths) {
const file = filepath.replace(dirpath, "");
const page = file.split(".")[0];
const page = file.split(".")[0].slice(1);

const locale = DEFAULT_LOCALE;
const pathLocale = locale.toLowerCase();
Expand All @@ -309,6 +314,8 @@ export async function buildSPAs(options: {
};
const [$] = await kumascript.render(url, {}, d);
wrapTables($);
postProcessExternalLinks($);
injectLoadingLazyAttributes($);
const [sections] = await extractSections($);
const toc = makeTOC({ body: sections });

Expand All @@ -320,9 +327,9 @@ export async function buildSPAs(options: {
};
const context: HydrationData = {
hyData,
pageTitle: frontMatter.attributes.title
pageTitle: title
? `${frontMatter.attributes.title} | ${title}`
: title,
: frontMatter.attributes.title,
url,
};

Expand All @@ -343,21 +350,20 @@ export async function buildSPAs(options: {
}
}

await buildStaticPages(
fileURLToPath(new URL("../copy/plus/", import.meta.url)),
"plus/docs",
"MDN Plus"
);
await buildStaticPages(
fileURLToPath(new URL("../copy/observatory/", import.meta.url)),
"observatory/docs",
OBSERVATORY_TITLE
);
await buildStaticPages(
fileURLToPath(new URL("../copy/community/", import.meta.url)),
"",
"Contribute to MDN"
);
if (GENERIC_CONTENT_ROOT) {
await buildStaticPages(
path.join(GENERIC_CONTENT_ROOT, "plus"),
"plus/docs",
"MDN Plus"
);
await buildStaticPages(
path.join(GENERIC_CONTENT_ROOT, "observatory"),
"observatory/docs",
OBSERVATORY_TITLE
);
await buildStaticPages(path.join(GENERIC_CONTENT_ROOT, "community"));
await buildStaticPages(path.join(GENERIC_CONTENT_ROOT, "about"));
}

// Build all the home pages in all locales.
// Fetch merged content PRs for the latest contribution section.
Expand Down
4 changes: 2 additions & 2 deletions client/pwa/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -12,14 +12,14 @@
"dev": "webpack-cli --watch"
},
"dependencies": {
"@zip.js/zip.js": "2.7.53",
"@zip.js/zip.js": "2.7.54",
"dexie": "4.0.10"
},
"devDependencies": {
"@types/dexie": "1.3.35",
"ts-loader": "^9.5.1",
"typescript": "^5.7.2",
"webpack": "^5.97.0",
"webpack": "^5.97.1",
"webpack-cli": "^5.1.4",
"workers-preview": "^1.0.6"
}
Expand Down
1 change: 1 addition & 0 deletions client/pwa/tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
"extends": "../tsconfig.json",
"compilerOptions": {
"lib": ["dom", "dom.iterable", "es2021", "webworker"],
"allowImportingTsExtensions": false,
"noEmit": false,
"preserveConstEnums": true,
"strictNullChecks": false,
Expand Down
16 changes: 8 additions & 8 deletions client/pwa/yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -254,10 +254,10 @@
resolved "https://registry.yarnpkg.com/@xtuc/long/-/long-4.2.2.tgz#d291c6a4e97989b5c61d9acf396ae4fe133a718d"
integrity sha512-NuHqBY1PB/D8xU6s/thBgOAiAP7HOYDQ32+BFZILJ8ivkUkAHQnWfn6WhL79Owj1qmUnoN/YPhktdIoucipkAQ==

"@zip.js/[email protected].53":
version "2.7.53"
resolved "https://registry.yarnpkg.com/@zip.js/zip.js/-/zip.js-2.7.53.tgz#bf88e90d8eed562182c01339643bc405446b0578"
integrity sha512-G6Bl5wN9EXXVaTUIox71vIX5Z454zEBe+akKpV4m1tUboIctT5h7ID3QXCJd/Lfy2rSvmkTmZIucf1jGRR4f5A==
"@zip.js/[email protected].54":
version "2.7.54"
resolved "https://registry.yarnpkg.com/@zip.js/zip.js/-/zip.js-2.7.54.tgz#ef0f46644b1a084155473b0d7710c80a892c2687"
integrity sha512-qMrJVg2hoEsZJjMJez9yI2+nZlBUxgYzGV3mqcb2B/6T1ihXp0fWBDYlVHlHquuorgNUQP5a8qSmX6HF5rFJNg==

acorn@^8.14.0, acorn@^8.8.2:
version "8.14.0"
Expand Down Expand Up @@ -902,10 +902,10 @@ webpack-sources@^3.2.3:
resolved "https://registry.yarnpkg.com/webpack-sources/-/webpack-sources-3.2.3.tgz#2d4daab8451fd4b240cc27055ff6a0c2ccea0cde"
integrity sha512-/DyMEOrDgLKKIG0fmvtz+4dUX/3Ghozwgm6iPp8KRhvn+eQf9+Q7GWxVNMk3+uCPWfdXYC4ExGBckIXdFEfH1w==

webpack@^5.97.0:
version "5.97.0"
resolved "https://registry.yarnpkg.com/webpack/-/webpack-5.97.0.tgz#1c5e3b9319f8c6decb19b142e776d90e629d5c40"
integrity sha512-CWT8v7ShSfj7tGs4TLRtaOLmOCPWhoKEvp+eA7FVx8Xrjb3XfT0aXdxDItnRZmE8sHcH+a8ayDrJCOjXKxVFfQ==
webpack@^5.97.1:
version "5.97.1"
resolved "https://registry.yarnpkg.com/webpack/-/webpack-5.97.1.tgz#972a8320a438b56ff0f1d94ade9e82eac155fa58"
integrity sha512-EksG6gFY3L1eFMROS/7Wzgrii5mBAFe4rIr3r2BTfo7bcc+DWwFZ4OJ/miOuHJO/A85HwyI4eQ0F6IKXesO7Fg==
dependencies:
"@types/eslint-scope" "^3.7.7"
"@types/estree" "^1.0.6"
Expand Down
Loading

0 comments on commit 55e0881

Please sign in to comment.