Skip to content

Commit

Permalink
Merge branch 'main' into remove-not-from-stopwords
Browse files Browse the repository at this point in the history
  • Loading branch information
caugner authored Mar 15, 2024
2 parents 341cd95 + 49c84bb commit d61f88f
Show file tree
Hide file tree
Showing 49 changed files with 1,233 additions and 1,041 deletions.
2 changes: 1 addition & 1 deletion .release-please-manifest.json
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
{
".": "2.42.1"
".": "2.43.0"
}
27 changes: 27 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,32 @@
# Changelog

## [2.43.0](https://github.com/mdn/yari/compare/v2.42.1...v2.43.0) (2024-03-05)


### Features

* **article-footer:** redesign footer + add feedback buttons ([#10625](https://github.com/mdn/yari/issues/10625)) ([40659a8](https://github.com/mdn/yari/commit/40659a8359af372c0e1af4e2c40da4d0979afc06))
* **latest-news:** fetch metadata from Blog articles + update list ([#10614](https://github.com/mdn/yari/issues/10614)) ([734c37c](https://github.com/mdn/yari/commit/734c37c0834713f0cfd62d98d282a7c37522b68f))


### Bug Fixes

* **cloud-function:** redirect blog/curriculum/play without locale ([#10654](https://github.com/mdn/yari/issues/10654)) ([2fe9d54](https://github.com/mdn/yari/commit/2fe9d540a0c4cd7b78047770d6195fb30fff0a91))
* **featured-articles:** improve how Blog articles are shown ([#10624](https://github.com/mdn/yari/issues/10624)) ([4900d37](https://github.com/mdn/yari/commit/4900d37495b30cb0d2adb99dded61a88f30c2c3b))
* **logo:** set width to width of largest logo ([#10652](https://github.com/mdn/yari/issues/10652)) ([e606646](https://github.com/mdn/yari/commit/e60664601ea55cd61a94ee4ad5db304b2df0f49d))
* **recent-contributions:** break long words instead of overflowing ([#10503](https://github.com/mdn/yari/issues/10503)) ([9ec8963](https://github.com/mdn/yari/commit/9ec8963de4277cb98ff8633c29687c411cbf5db2))
* **types:** pass types through memoize properly ([#10567](https://github.com/mdn/yari/issues/10567)) ([ed9cbf3](https://github.com/mdn/yari/commit/ed9cbf3e0b2b3dd017b266ac04dd9c540388f42c))


### Miscellaneous

* **deps-dev:** bump the types group with 1 update ([#10648](https://github.com/mdn/yari/issues/10648)) ([a6293c3](https://github.com/mdn/yari/commit/a6293c3ee4ac66334f9dda5b124b02130517839d))
* **deps-dev:** bump typescript-eslint from 7.1.0 to 7.1.1 ([#10649](https://github.com/mdn/yari/issues/10649)) ([cc74431](https://github.com/mdn/yari/commit/cc74431283efead765156e2453a306c0329341d6))
* **deps:** bump [@zip](https://github.com/zip).js/zip.js from 2.7.36 to 2.7.37 in /client/pwa ([#10646](https://github.com/mdn/yari/issues/10646)) ([b218c21](https://github.com/mdn/yari/commit/b218c2192ab6d06dc1db4cca7e3b65444bb4da4e))
* **deps:** bump @stripe/stripe-js from 3.0.6 to 3.0.7 ([#10651](https://github.com/mdn/yari/issues/10651)) ([0071314](https://github.com/mdn/yari/commit/00713146c396aad3c9187044def1abbb17760fe2))
* **deps:** bump dexie from 3.2.5 to 3.2.6 ([#10650](https://github.com/mdn/yari/issues/10650)) ([8a6f76d](https://github.com/mdn/yari/commit/8a6f76d294167f8cc72893bad5d62bbd67bc4f1d))
* **deps:** bump dexie from 3.2.5 to 3.2.6 in /client/pwa ([#10645](https://github.com/mdn/yari/issues/10645)) ([17e353f](https://github.com/mdn/yari/commit/17e353ffcfe180153e1de1644f5b7d49527ce6e1))

## [2.42.1](https://github.com/mdn/yari/compare/v2.42.0...v2.42.1) (2024-03-04)


Expand Down
16 changes: 10 additions & 6 deletions build/blog.ts
Original file line number Diff line number Diff line change
Expand Up @@ -281,7 +281,7 @@ export async function buildBlogPosts(options: {

const url = `/${locale}/blog/${blogMeta.slug}/`;
const renderUrl = `/${locale}/blog/${blogMeta.slug}`;
const renderDoc = {
const renderDoc: BlogPostDoc = {
url: renderUrl,
rawBody: body,
metadata: { locale, ...blogMeta },
Expand Down Expand Up @@ -344,11 +344,11 @@ export async function buildBlogPosts(options: {
}
}

interface BlogPostDoc {
export interface BlogPostDoc {
url: string;
rawBody: string;
metadata: BlogPostMetadata & { locale: string };
isMarkdown: boolean;
isMarkdown: true;
fileInfo: {
path: string;
};
Expand All @@ -368,7 +368,7 @@ export async function buildPost(
let $ = null;
const liveSamples: LiveSample[] = [];

[$] = await kumascript.render(document.url, {}, document as any);
[$] = await kumascript.render(document.url, {}, document);

const liveSamplePages = await kumascript.buildLiveSamplePages(
document.url,
Expand Down Expand Up @@ -449,8 +449,12 @@ export async function buildBlogFeed(options: { verbose?: boolean }) {
description: post.description,
author: [
{
name: post.author?.name || "The MDN Team",
link: post.author?.link,
name:
(typeof post.author === "string"
? post.author
: post.author?.name) || "The MDN Team",
link:
typeof post.author === "string" ? post.author : post.author?.link,
},
],
date: new Date(post.date),
Expand Down
4 changes: 2 additions & 2 deletions build/curriculum.ts
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ import { memoize, slugToFolder } from "../content/utils.js";
import { renderHTML } from "../ssr/dist/main.js";
import { CheerioAPI } from "cheerio";

export const allFiles: () => string[] = memoize(async () => {
export const allFiles = memoize(async () => {
const api = new fdir()
.withFullPaths()
.withErrors()
Expand All @@ -49,7 +49,7 @@ export const allFiles: () => string[] = memoize(async () => {
return (await api.withPromise()).sort();
});

export const buildIndex: () => CurriculumMetaData[] = memoize(async () => {
export const buildIndex = memoize(async () => {
const files = await allFiles();
const modules = await Promise.all(
files.map(
Expand Down
40 changes: 26 additions & 14 deletions build/flaws/broken-links.ts
Original file line number Diff line number Diff line change
Expand Up @@ -49,13 +49,16 @@ function mutateLink(
) {
if (isSelfLink) {
$element.attr("aria-current", "page");
} else if (suggestion) {
$element.attr("href", suggestion);
} else if (enUSFallback) {
// If we have an English (US) fallback, then we use this first.
// As we still suggest the translated version even if we only
// have an English (US) version.
$element.attr("href", enUSFallback);
$element.append(` <small>(${DEFAULT_LOCALE})<small>`);
$element.addClass("only-in-en-us");
$element.attr("title", "Currently only available in English (US)");
} else if (suggestion) {
$element.attr("href", suggestion);
} else {
$element.addClass("page-not-created");
$element.attr("title", "This is a link to an unwritten page");
Expand Down Expand Up @@ -299,7 +302,6 @@ export function getBrokenLinksFlaws(
resolved + absoluteURL.search + absoluteURL.hash.toLowerCase()
);
} else {
let enUSFallbackURL = null;
// Test if the document is a translated document and the link isn't
// to an en-US URL. We know the link is broken (in this locale!)
// but it might be "salvageable" if we link the en-US equivalent.
Expand All @@ -316,28 +318,38 @@ export function getBrokenLinksFlaws(
`/${DEFAULT_LOCALE}/`
);
const enUSFound = Document.findByURL(enUSHrefNormalized);
// Note, we still recommend that contributors use localized links,
// even if the target document is still not localized.
if (enUSFound) {
enUSFallbackURL = enUSFound.url;
// Found the en-US version of the document. Just link to that.
mutateLink(a, null, enUSFound.url);
} else {
const enUSResolved = Redirect.resolve(enUSHrefNormalized);
let suggestion = null;
let enUSFallbackURL = null;
if (enUSResolved !== enUSHrefNormalized) {
enUSFallbackURL =
enUSResolved +
absoluteURL.search +
absoluteURL.hash.toLowerCase();
suggestion = enUSFallbackURL.replace(
`/${DEFAULT_LOCALE}/`,
`/${doc.locale}/`
);
}
addBrokenLink(
a,
checked.get(href),
href,
suggestion,
null,
enUSFallbackURL
);
}
} else {
// The link is broken and we don't have a suggestion.
addBrokenLink(a, checked.get(href), href);
}
addBrokenLink(
a,
checked.get(href),
href,
null,
enUSFallbackURL
? "Can use the English (en-US) link as a fallback"
: null,
enUSFallbackURL
);
}
}
// But does it have the correct case?!
Expand Down
124 changes: 40 additions & 84 deletions build/spas.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ import fs from "node:fs";
import path from "node:path";
import { fileURLToPath } from "node:url";

import cheerio from "cheerio";
import frontmatter from "front-matter";
import { fdir, PathsOutput } from "fdir";
import got from "got";
Expand All @@ -22,7 +21,7 @@ import {
DEV_MODE,
} from "../libs/env/index.js";
import { isValidLocale } from "../libs/locale-utils/index.js";
import { DocFrontmatter, NewsItem } from "../libs/types/document.js";
import { DocFrontmatter, DocParent, NewsItem } from "../libs/types/document.js";
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
// @ts-ignore
import { renderHTML } from "../ssr/dist/main.js";
Expand All @@ -38,6 +37,12 @@ const FEATURED_ARTICLES = [
"docs/Web/CSS/color_value",
];

const LATEST_NEWS: (NewsItem | string)[] = [
"blog/mdn-curriculum-launch/",
"blog/baseline-evolution-on-mdn/",
"blog/introducing-the-mdn-playground/",
];

const contributorSpotlightRoot = CONTRIBUTOR_SPOTLIGHT_ROOT;

async function buildContributorSpotlight(
Expand Down Expand Up @@ -318,6 +323,10 @@ export async function buildSPAs(options: {
mdn_url: `/${DEFAULT_LOCALE}/blog/${slug}/`,
summary: description,
title,
tag: {
uri: `/${DEFAULT_LOCALE}/blog/`,
title: "Blog",
} satisfies DocParent,
};
}
}
Expand Down Expand Up @@ -415,90 +424,37 @@ async function fetchRecentContributions() {
}

async function fetchLatestNews() {
const items: NewsItem[] = [];

items.push(
{
title: "Responsibly empowering developers with AI on MDN",
url: `https://blog.mozilla.org/en/products/mdn/responsibly-empowering-developers-with-ai-on-mdn/`,
author: "Steve Teixeira",
published_at: new Date("Thu, 06 Jul 2023 14:41:20 +0000").toString(),
source: {
name: "blog.mozilla.org",
url: `https://blog.mozilla.org/en/latest/`,
},
},
{
title: "Introducing AI Help: Your Trusted Companion for Web Development",
url: `/${DEFAULT_LOCALE}/blog/introducing-ai-help/`,
author: "Hermina Condei",
published_at: new Date("2023-06-27").toString(),
source: {
name: "developer.mozilla.org",
url: `/${DEFAULT_LOCALE}/blog/`,
},
},
{
title: "Introducing the MDN Playground: Bring your code to life!",
url: `/${DEFAULT_LOCALE}/blog/introducing-the-mdn-playground/`,
author: "Florian Dieminger",
published_at: new Date("2023-06-22").toString(),
source: {
name: "developer.mozilla.org",
url: `/${DEFAULT_LOCALE}/blog/`,
},
},
{
title: "Introducing Baseline: a unified view of stable web features",
url: `/${DEFAULT_LOCALE}/blog/baseline-unified-view-stable-web-features/`,
author: "Hermina Condei",
published_at: new Date("2023-05-10").toString(),
source: {
name: "developer.mozilla.org",
url: `/${DEFAULT_LOCALE}/blog/`,
},
},
...(await fetchHacksNews())
);
const items: NewsItem[] = (
await Promise.all(
LATEST_NEWS.map(async (itemOrUrl) => {
if (typeof itemOrUrl !== "string") {
return itemOrUrl;
}
const url = itemOrUrl;
const post = await findPostBySlug(
getSlugByBlogPostUrl(`/${DEFAULT_LOCALE}/${url}`)
);
if (post) {
const {
doc: { title },
blogMeta: { author, date, slug },
} = post;
return {
title,
url: `/${DEFAULT_LOCALE}/blog/${slug}/`,
author: author?.name || "The MDN Team",
published_at: new Date(date).toString(),
source: {
name: "developer.mozilla.org",
url: `/${DEFAULT_LOCALE}/blog/`,
},
};
}
})
)
).filter(Boolean);

return {
items,
};
}

async function fetchHacksNews(): Promise<NewsItem[]> {
try {
const xml = await got(
"https://hacks.mozilla.org/category/mdn/feed/"
).text();

const $ = cheerio.load(xml, { xmlMode: true });

const items: NewsItem[] = [];
$("item").each((i, item) => {
const $item = $(item);

items.push({
title: $item.find("title").text(),
url: $item.find("guid").text(),
author: $item.find("dc\\:creator").text(),
published_at: $item.find("pubDate").text(),
source: {
name: "hacks.mozilla.org",
url: "https://hacks.mozilla.org/category/mdn/",
},
});
});

return items;
} catch (e) {
const msg = "Couldn't fetch hacks.mozilla.org feed!";
if (!DEV_MODE) {
console.error(`Error: ${msg}`);
throw e;
}

console.warn(`Warning: ${msg}`);
return [];
}
}
6 changes: 3 additions & 3 deletions client/pwa/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -12,13 +12,13 @@
"dev": "webpack-cli --watch"
},
"dependencies": {
"@zip.js/zip.js": "2.7.36",
"dexie": "3.2.5"
"@zip.js/zip.js": "2.7.40",
"dexie": "3.2.6"
},
"devDependencies": {
"@types/dexie": "1.3.1",
"ts-loader": "^9.5.1",
"typescript": "^5.3.3",
"typescript": "^5.4.2",
"webpack": "^5.90.3",
"webpack-cli": "^5.1.4",
"workers-preview": "^1.0.6"
Expand Down
Loading

0 comments on commit d61f88f

Please sign in to comment.