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 top-level index.html for dev only (not GH Pages / W3C site) #4076

Merged
merged 1 commit into from
Sep 20, 2024
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
3 changes: 2 additions & 1 deletion .eleventyignore
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
*.*
*.md
11ty/
acknowledgements.html
acknowledgements/
conformance-challenges/
guidelines/
Expand Down
2 changes: 2 additions & 0 deletions 11ty/CustomLiquid.ts
Original file line number Diff line number Diff line change
Expand Up @@ -89,6 +89,8 @@ export class CustomLiquid extends Liquid {
const isIndex = indexPattern.test(filepath);
const isTechniques = techniquesPattern.test(filepath);
const isUnderstanding = understandingPattern.test(filepath);

if (!isTechniques && !isUnderstanding) return super.parse(html);

const $ = flattenDom(html, filepath);

Expand Down
8 changes: 8 additions & 0 deletions eleventy.config.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import compact from "lodash-es/compact";
import { rimraf } from "rimraf";

import { copyFile } from "fs/promises";

Expand Down Expand Up @@ -124,6 +125,7 @@ export default function (eleventyConfig: any) {
eleventyConfig.addGlobalData("eleventyComputed", {
// permalink determines output structure; see https://www.11ty.dev/docs/permalinks/
permalink: ({ page, isUnderstanding }: GlobalData) => {
if (page.inputPath === "./index.html" && process.env.WCAG_MODE) return false;
if (isUnderstanding) {
// understanding-metadata.html exists in 2 places; top-level wins in XSLT process
if (/\/20\/understanding-metadata/.test(page.inputPath)) return false;
Expand Down Expand Up @@ -173,6 +175,12 @@ export default function (eleventyConfig: any) {

eleventyConfig.addPassthroughCopy("working-examples/**");

eleventyConfig.on("eleventy.before", async ({ runMode }: EleventyEvent) => {
// Clear the _site folder before publishes to GH Pages or W3C site,
// to avoid inheriting dev-only files from previous runs
if (runMode === "build" && process.env.WCAG_MODE) await rimraf("_site");
});

eleventyConfig.on("eleventy.after", async ({ dir }: EleventyEvent) => {
// addPassthroughCopy can only map each file once,
// but base.css needs to be copied to a 2nd destination
Expand Down
14 changes: 14 additions & 0 deletions index.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8"/>
<title>Web Content Accessibility Guidelines {{ versionDecimal }}</title>
</head>
<body>
<h1>Web Content Accessibility Guidelines {{ versionDecimal }}</h1>
<ul>
<li><a href="techniques/">Techniques</a></li>
<li><a href="understanding/">Understanding Docs</a></li>
</ul>
</body>
</html>
100 changes: 59 additions & 41 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@
"liquidjs": "^10.14.0",
"lodash-es": "^4.17.21",
"mkdirp": "^3.0.1",
"rimraf": "^5.0.10",
"tsx": "^4.11.0"
},
"devDependencies": {
Expand Down