diff --git a/.github/workflows/website.yaml b/.github/workflows/website.yaml new file mode 100644 index 00000000..da03b219 --- /dev/null +++ b/.github/workflows/website.yaml @@ -0,0 +1,26 @@ +name: Website + +on: + push: + branches: + - website + +jobs: + website: + runs-on: ubuntu-latest + permissions: + contents: read + id-token: write + + steps: + - uses: actions/checkout@v4 + - uses: volta-cli/action@v4 + + - run: yarn install && yarn build + working-directory: website + + - uses: denoland/deployctl@v1 + with: + project: interactors + entrypoint: https://deno.land/std@0.140.0/http/file_server.ts + root: website/public/interactors diff --git a/website/.gitignore b/website/.gitignore index 550a50e6..80c13723 100644 --- a/website/.gitignore +++ b/website/.gitignore @@ -11,3 +11,4 @@ build docs/**/api sidebars public +/node_modules diff --git a/website/docusaurus.config.js b/website/docusaurus.config.js index d7375bdf..7e160ed5 100644 --- a/website/docusaurus.config.js +++ b/website/docusaurus.config.js @@ -2,7 +2,7 @@ module.exports = { title: "Interactors", tagline: "Page Objects for components libraries", url: "https://frontside.com/", - baseUrl: "/interactors/", + baseUrl: "/", onBrokenLinks: "throw", favicon: "images/favicon-interactors.png", organizationName: "thefrontside", @@ -119,6 +119,7 @@ module.exports = { theme: { customCss: require.resolve("./src/css/custom.css"), }, + sitemap: {} }, ], ], diff --git a/website/package.json b/website/package.json index f8cf789d..c7febbd2 100644 --- a/website/package.json +++ b/website/package.json @@ -4,7 +4,7 @@ "private": true, "scripts": { "start": "docusaurus start", - "build": "docusaurus build --out-dir public/interactors", + "build": "docusaurus build --out-dir public/interactors && node sitemap.mjs", "swizzle": "docusaurus swizzle", "deploy": "docusaurus deploy", "serve": "docusaurus serve --dir public/interactors" @@ -21,7 +21,8 @@ "email-validator": "^2.0.4", "jsonp": "^0.2.1", "react": "^16.8.4", - "react-dom": "^16.8.4" + "react-dom": "^16.8.4", + "xml2js": "^0.6.2" }, "browserslist": { "production": [ @@ -34,5 +35,9 @@ "last 1 firefox version", "last 1 safari version" ] + }, + "volta": { + "node": "16.20.2", + "yarn": "1.22.22" } } diff --git a/website/sitemap.mjs b/website/sitemap.mjs new file mode 100644 index 00000000..d4e17967 --- /dev/null +++ b/website/sitemap.mjs @@ -0,0 +1,58 @@ +/* Add indexes of all dynamically loaded assets so that they can be staticalized */ + +import { readFileSync, writeFileSync, readdirSync } from "node:fs"; +import { Parser, Builder } from "xml2js"; + +const [parser, builder] = [new Parser(), new Builder()]; + +const sitemapXML = readFileSync("./public/interactors/sitemap.xml"); + +const sitemap = await parser.parseStringPromise(sitemapXML); + +// ideally we would use the docusaurs sitemap plugin to do this +// but support for plugins came with => 3.0.0 and upgrade no thank you. +sitemap.urlset.url.push({ + loc: 'https://frontside.com/assets/js/index.html', +}, { + loc: 'https://frontside.com/images/index.html' +}); + +writeFileSync("./public/interactors/sitemap.xml", builder.buildObject(sitemap)); + +const assets = readdirSync("./public/interactors/assets/js"); + +writeFileSync("./public/interactors/assets/js/index.html",` + +
+${assets.map((asset) => ` `).join("\n")} + + +