diff --git a/.github/workflows/gh-pages-build-deploy.yml b/.github/workflows/gh-pages-build-deploy.yml index 727f2828113..a232b215a0b 100644 --- a/.github/workflows/gh-pages-build-deploy.yml +++ b/.github/workflows/gh-pages-build-deploy.yml @@ -7,8 +7,9 @@ on: branches: - "main" paths: - - "gh-pages/**" - - ".github/workflows/gh-pages-build-deploy.yml" + - "gh-pages/**" # Rebuild when any of the pages are updated. + - ".github/workflows/gh-pages-build-deploy.yml" # Rebuild when this file is updated. + - "packages/web-features/package.json" # Rebuild when a new package is released. # Allows you to run this workflow manually from the Actions tab workflow_dispatch: @@ -41,6 +42,7 @@ jobs: with: cache: npm node-version-file: .node-version + cache-dependency-path: gh-pages/package-lock.json - name: NPM Install run: npm ci working-directory: gh-pages/ diff --git a/gh-pages/eleventy.config.js b/gh-pages/eleventy.config.js index 1a72caec02c..11b5f1fb3a8 100644 --- a/gh-pages/eleventy.config.js +++ b/gh-pages/eleventy.config.js @@ -1,12 +1,30 @@ const { EleventyHtmlBasePlugin } = require("@11ty/eleventy"); const markdownIt = require("markdown-it"); const markdownItAnchor = require("markdown-it-anchor"); +const webFeatures = require("web-features/data.json"); module.exports = function (eleventyConfig) { + eleventyConfig.addPlugin(EleventyHtmlBasePlugin); eleventyConfig.addPassthroughCopy("./src/assets/img"); eleventyConfig.addPassthroughCopy("./src/assets/fonts"); eleventyConfig.addPassthroughCopy("./src/assets/css"); - eleventyConfig.addPlugin(EleventyHtmlBasePlugin); + + // Get keys from features, loop through them to create an array of + // objects with the feature names & keys. + eleventyConfig.addGlobalData("featuresList", () => { + const result = []; + + const features = webFeatures.features; + const keys = Object.keys(features); + for (const key of keys) { + const featureName = features[key].name; + const name = featureName.replaceAll("<", "<").replaceAll(">", ">"); + result.push({ key, name }); + } + + return result; + }); + const mdOpts = { html: true, breaks: true, diff --git a/gh-pages/package-lock.json b/gh-pages/package-lock.json index 142e25b8ec9..a966d8c392e 100644 --- a/gh-pages/package-lock.json +++ b/gh-pages/package-lock.json @@ -7,6 +7,9 @@ "": { "name": "@web-platform-dx/web-features/site", "version": "0.1.0", + "dependencies": { + "web-features": "^1.3.0-dev-20240918141109-a1c1086" + }, "devDependencies": { "@11ty/eleventy": "^2.0.1", "markdown-it": "^14.1.0", @@ -2695,6 +2698,12 @@ "node": ">=0.10.0" } }, + "node_modules/web-features": { + "version": "1.3.0-dev-20240918141109-a1c1086", + "resolved": "https://registry.npmjs.org/web-features/-/web-features-1.3.0-dev-20240918141109-a1c1086.tgz", + "integrity": "sha512-eUvE2Wx4WaGTuM0D4dbD0mHKosguJfd7wCsPyecKG+p2yLS0IrkOVHJEn/atjbjBvHK4tI6i2GSGrjqYFLJ4pA==", + "license": "Apache-2.0" + }, "node_modules/which": { "version": "2.0.2", "resolved": "https://registry.npmjs.org/which/-/which-2.0.2.tgz", diff --git a/gh-pages/package.json b/gh-pages/package.json index 21bd31e93ed..09f570eabc8 100644 --- a/gh-pages/package.json +++ b/gh-pages/package.json @@ -13,11 +13,13 @@ "scripts": { "build:dev": "eleventy", "build:prod": "eleventy --pathprefix=web-features", - "dev": "eleventy --serve" + "dev": "eleventy --serve", + "clean": "rm -rf ../_site" }, "devDependencies": { "@11ty/eleventy": "^2.0.1", "markdown-it": "^14.1.0", - "markdown-it-anchor": "^9.1.0" + "markdown-it-anchor": "^9.1.0", + "web-features": "next" } } diff --git a/gh-pages/src/_includes/default.html b/gh-pages/src/_includes/default.html index 3dc416fc1cc..b5123d066f2 100644 --- a/gh-pages/src/_includes/default.html +++ b/gh-pages/src/_includes/default.html @@ -45,6 +45,7 @@