Skip to content

Commit

Permalink
Fixes #1670
Browse files Browse the repository at this point in the history
  • Loading branch information
zachleat committed Mar 26, 2024
1 parent 3675c93 commit 3f83b14
Show file tree
Hide file tree
Showing 295 changed files with 7,097 additions and 5,748 deletions.
8 changes: 4 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

# 11ty.dev 🕚⚡️🎈🐀

* https://www.11ty.dev/
- https://www.11ty.dev/

The website and documentation for the [Eleventy static site generator](https://github.com/11ty/eleventy/).

Expand All @@ -16,9 +16,9 @@ npx @11ty/eleventy --serve

Browse to http://localhost:8080/ (8080 is the default but it’ll bump to a new port if that one is taken, so use whatever port shows up when you run the `--serve` command).

* Refresh Supporters: `npm run get-new-supporters`
- Refresh Supporters: `npm run get-new-supporters`

## Third-party Integrations

* [IFTTT](https://ifttt.com/) daily web hook to build the site once a day to update stats and counts in footer.
* [Zapier](https://zapier.com/) (Open Collective + Netlify integration) to run a new production build when a new contributor joins Open Collective. _Warning: while avatar will show on the site, there is still a manual step to send the Netlify Identity invitation for the Eleventy Contributor Account._
- [IFTTT](https://ifttt.com/) daily web hook to build the site once a day to update stats and counts in footer.
- [Zapier](https://zapier.com/) (Open Collective + Netlify integration) to run a new production build when a new contributor joins Open Collective. _Warning: while avatar will show on the site, there is still a manual step to send the Netlify Identity invitation for the Eleventy Contributor Account._
47 changes: 31 additions & 16 deletions config/activity.js
Original file line number Diff line number Diff line change
@@ -1,41 +1,56 @@
import "dotenv/config";
import EleventyFetch from "@11ty/eleventy-fetch";
import { ActivityFeed } from '@11ty/eleventy-activity-feed';
import { ActivityFeed } from "@11ty/eleventy-activity-feed";

export default async function() {
export default async function () {
let feed = new ActivityFeed();

feed.setCacheDuration("1d"); // note that cache is persisted on CI server

// The Eleventy Activity Feed
feed.addSource("youtubeUser", "YouTube", "UCskGTioqrMBcw8pd14_334A"); // Eleventy
feed.addSource("atom", "Blog", "https://www.11ty.dev/blog/feed.xml");
feed.addSource("atom", "Quick Tips", "https://www.11ty.dev/docs/quicktips/feed.xml");
feed.addSource(
"atom",
"Quick Tips",
"https://www.11ty.dev/docs/quicktips/feed.xml"
);
feed.addSource("rss", "Mastodon", "https://fosstodon.org/users/eleventy.rss");
// feed.addSource("twitterUser", "Twitter", "eleven_ty", "949639269433380864");

if(process.env.NODE_ENV === "production") {
if (process.env.NODE_ENV === "production") {
// Warning: at time of writing Eleventy has 51 repos, beware if this grows beyond the max of 100
const PER_PAGE = 100; // max: 100
let githubOrgRepos = await EleventyFetch(`https://api.github.com/orgs/11ty/repos?per_page=${PER_PAGE}`, {
type: "json",
duration: "1d",
directory: ".cache/eleventy-fetch/",
fetchOptions: {
headers: {
"Authorization": `bearer ${process.env.GITHUB_READ_TOKEN}`
let githubOrgRepos = await EleventyFetch(
`https://api.github.com/orgs/11ty/repos?per_page=${PER_PAGE}`,
{
type: "json",
duration: "1d",
directory: ".cache/eleventy-fetch/",
fetchOptions: {
headers: {
Authorization: `bearer ${process.env.GITHUB_READ_TOKEN}`,
},
},
}
});
);

for(let repository of githubOrgRepos) {
if(repository.visibility === "public") {
feed.addSource("atom", `GitHub Releases [${repository.full_name}]`, `https://github.com/${repository.full_name}/releases.atom`);
for (let repository of githubOrgRepos) {
if (repository.visibility === "public") {
feed.addSource(
"atom",
`GitHub Releases [${repository.full_name}]`,
`https://github.com/${repository.full_name}/releases.atom`
);
}
}
} else {
// only use core for local dev
feed.addSource("atom", `GitHub Releases [11ty/eleventy]`, `https://github.com/11ty/eleventy/releases.atom`);
feed.addSource(
"atom",
`GitHub Releases [11ty/eleventy]`,
`https://github.com/11ty/eleventy/releases.atom`
);
}

return feed;
Expand Down
50 changes: 31 additions & 19 deletions config/addedin.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ const MINIMUM_VERSION_SHOWN = "1.0.0";
const COERCE = {
// should have `v` prefix
"v2.0.0-canary.": "v2.0.0", // 2.0.0-beta.1 => 2.0.0 is handled automatically (see Note 1 below)
}
};

function isCoreRelease(version) {
// For version text that starts with a number (plugins don’t do this)
Expand All @@ -18,7 +18,7 @@ function isPreRelease(version) {
}

function isPreReleaseOf(version, releasedVersion) {
if(!isPreRelease(version)) {
if (!isPreRelease(version)) {
return false;
}

Expand All @@ -29,29 +29,34 @@ function isPreReleaseOf(version, releasedVersion) {

// coerce -canary to -beta or if stable version is released, strips -canary and -beta
function coerceVersion(version) {
const newestPublishedVersion = versions.filter(v => v.tag !== "LATEST").shift();
if(!isCoreRelease(version)) {
const newestPublishedVersion = versions
.filter((v) => v.tag !== "LATEST")
.shift();
if (!isCoreRelease(version)) {
return version;
}

let versionText = version;

if(!versionText.startsWith("v")) {
if (!versionText.startsWith("v")) {
versionText = `v${versionText}`;
}

// Change all -canary.X to .beta.1
for(let coerceKey in COERCE) {
if(versionText.startsWith(coerceKey)) {
for (let coerceKey in COERCE) {
if (versionText.startsWith(coerceKey)) {
let newVersion = COERCE[coerceKey];
versionText = newVersion;
}
}

if(isPreReleaseOf(versionText, newestPublishedVersion.tag)) {
if (isPreReleaseOf(versionText, newestPublishedVersion.tag)) {
// Note 1: Strip -canary.1 or -beta.1 suffixes after 2.0.0 is shipped
versionText = versionText.split("-")[0];
} else if(isPreRelease(versionText) && semver.lt(versionText, newestPublishedVersion.tag)) {
} else if (
isPreRelease(versionText) &&
semver.lt(versionText, newestPublishedVersion.tag)
) {
// v2.0.0-beta.1 and the newest version is v2.0.1
versionText = versionText.split("-")[0];
}
Expand All @@ -61,23 +66,30 @@ function coerceVersion(version) {

function addedIn(version, tag, extraClass) {
let beforeText = "Added in ";
if(isCoreRelease(version)) {
if (isCoreRelease(version)) {
// Show no content for super old version notes
if(semver.lt(version, MINIMUM_VERSION_SHOWN)) {
if (semver.lt(version, MINIMUM_VERSION_SHOWN)) {
return "";
}
const newestPublishedVersion = versions.filter(v => v.tag !== "LATEST").shift();
if(isPreRelease(version) && semver.gt(version, newestPublishedVersion.tag)) {
beforeText = "Pre-release only: "
const newestPublishedVersion = versions
.filter((v) => v.tag !== "LATEST")
.shift();
if (
isPreRelease(version) &&
semver.gt(version, newestPublishedVersion.tag)
) {
beforeText = "Pre-release only: ";
}
}

tag = tag || "span";

return `<${tag} data-pagefind-ignore class="minilink minilink-addedin${extraClass ? ` ${extraClass}`: ""}" data-uncoerced-version="${version}">${beforeText}${coerceVersion.call(this, version)}</${tag}>`;
return `<${tag} data-pagefind-ignore class="minilink minilink-addedin${
extraClass ? ` ${extraClass}` : ""
}" data-uncoerced-version="${version}">${beforeText}${coerceVersion.call(
this,
version
)}</${tag}>`;
}

export {
addedIn,
coerceVersion
};
export { addedIn, coerceVersion };
4 changes: 2 additions & 2 deletions config/cleanAuthorName.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@
export default function cleanAuthorName(name) {
name = name || "";

if(name.startsWith("@")) {
if (name.startsWith("@")) {
return name.substr(1);
}
return name;
};
}
12 changes: 6 additions & 6 deletions config/getAuthorsFromSites.js
Original file line number Diff line number Diff line change
@@ -1,18 +1,18 @@
export default function getAuthors(sites) {
let names = new Set();
for(let key in sites) {
for (let key in sites) {
let site = sites[key];
if(site.disabled) {
if (site.disabled) {
continue;
}

if(site.opened_by) {
if (site.opened_by) {
names.add(site.opened_by);
}

if(Array.isArray(site.authors)) {
for(let name of site.authors) {
if(name) {
if (Array.isArray(site.authors)) {
for (let name of site.authors) {
if (name) {
names.add(name);
}
}
Expand Down
111 changes: 60 additions & 51 deletions config/markdownPlugin.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ function markdownItSlugify(s) {
}

function removeExtraText(s) {
let newStr = String(s)
let newStr = String(s);
newStr = newStr.replace(/\-beta\.\d+/, "");
newStr = newStr.replace(/\-canary\.\d+/, "");
newStr = newStr.replace(/New\ in\ v\d+\.\d+\.\d+/, "");
Expand All @@ -20,77 +20,86 @@ function removeExtraText(s) {
return newStr;
}

export default function(eleventyConfig) {

export default function (eleventyConfig) {
let mdIt = markdownIt({
html: true,
breaks: true,
linkify: true
linkify: true,
})
.disable('code') // disable indent -> code block
.use(markdownItAnchor, {
slugify: markdownItSlugify,
level: [2,3,4],
permalink: markdownItAnchor.permalink.linkInsideHeader({
symbol: `
.disable("code") // disable indent -> code block
.use(markdownItAnchor, {
slugify: markdownItSlugify,
level: [2, 3, 4],
permalink: markdownItAnchor.permalink.linkInsideHeader({
symbol: `
<span class="sr-only" data-pagefind-ignore>Jump to heading</span>
<span aria-hidden="true" data-pagefind-ignore>#</span>
`,
class: "direct-link",
placement: 'after'
class: "direct-link",
placement: "after",
}),
})
})
.use(markdownItToc, {
includeLevel: [2, 3],
slugify: markdownItSlugify,
format: function(heading) {
return removeExtraText(heading);
},
transformLink: function(link) {
if(typeof link === "string") {
// remove backticks from markdown code
return link.replace(/\%60/g, "");
}
return link;
}
});
.use(markdownItToc, {
includeLevel: [2, 3],
slugify: markdownItSlugify,
format: function (heading) {
return removeExtraText(heading);
},
transformLink: function (link) {
if (typeof link === "string") {
// remove backticks from markdown code
return link.replace(/\%60/g, "");
}
return link;
},
});

// opt out of linkification for .io TLD, e.g. 11ty.io
mdIt.linkify.tlds('.io', false);
mdIt.linkify.tlds(".io", false);

eleventyConfig.setLibrary("md", mdIt);

eleventyConfig.addPairedShortcode("markdown", function(content) {
eleventyConfig.addPairedShortcode("markdown", function (content) {
return mdIt.renderInline(content);
});
eleventyConfig.addFilter("markdown", function(content) {
eleventyConfig.addFilter("markdown", function (content) {
return mdIt.renderInline(content);
});

// WebC migration: callout.webc
eleventyConfig.addPairedShortcode("callout", function(content, level = "", format = "html", customLabel = "") {
if( format === "md" ) {
content = mdIt.renderInline(content);
} else if( format === "md-block" ) {
content = mdIt.render(content);
}
let label = "";
if(customLabel) {
label = customLabel;
} else if(level === "info" || level === "error") {
label = level.toUpperCase() + ":";
} else if(level === "warn") {
label = "WARNING:";
}
let labelHtml = label ? `<div class="elv-callout-label">${customLabel || label}</div>` : "";
let contentHtml = (content || "").trim().length > 0 ? `<div class="elv-callout-c">${content}</div>` : "";
eleventyConfig.addPairedShortcode(
"callout",
function (content, level = "", format = "html", customLabel = "") {
if (format === "md") {
content = mdIt.renderInline(content);
} else if (format === "md-block") {
content = mdIt.render(content);
}
let label = "";
if (customLabel) {
label = customLabel;
} else if (level === "info" || level === "error") {
label = level.toUpperCase() + ":";
} else if (level === "warn") {
label = "WARNING:";
}
let labelHtml = label
? `<div class="elv-callout-label">${customLabel || label}</div>`
: "";
let contentHtml =
(content || "").trim().length > 0
? `<div class="elv-callout-c">${content}</div>`
: "";

return `<div class="elv-callout${level ? ` elv-callout-${level}` : ""}">${labelHtml}${contentHtml}</div>`;
});
return `<div class="elv-callout${
level ? ` elv-callout-${level}` : ""
}">${labelHtml}${contentHtml}</div>`;
}
);

eleventyConfig.addShortcode("tableofcontents", function(isOpen) {
eleventyConfig.addShortcode("tableofcontents", function (isOpen) {
// Markdown only.
if(this.page.inputPath.endsWith("md")) {
if (this.page.inputPath.endsWith("md")) {
return `<details class="toc"${isOpen ? " open" : ""}>
<summary>Contents</summary>
Expand All @@ -99,4 +108,4 @@ export default function(eleventyConfig) {
</details>`;
}
});
};
}
Loading

0 comments on commit 3f83b14

Please sign in to comment.