-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
✨ Add sitemap.xml to interactors site.
We're going to use sitemaps as a standards based mechanism to compose our static websites. This adds a sitemap for the interactors website so that it can be "mounted" on frontside.com by enabling the docusaurus "sitemap" plugin. Docusaurus does a bunch of dynamic chicanery with React, Webpack and code-splitting to render a static webpage because reasons, so we add a synthetic entry to the sitemap that serves as an index for all dynamic JavaScript resources. That way, the static site generator knows to download all those resources ahead of time even though they are not referenced in any page.
- Loading branch information
Showing
6 changed files
with
125 additions
and
7 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
name: Website | ||
|
||
on: | ||
push: | ||
branches: | ||
- main | ||
- www # remove this branch once this is merged to main | ||
paths: | ||
- 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.224.0/http/file_server.ts | ||
root: website/build |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -11,3 +11,4 @@ build | |
docs/**/api | ||
sidebars | ||
public | ||
/node_modules |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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("./build/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://interactors.deno.dev/interactors/assets/js/index.html', | ||
}, { | ||
loc: 'https://interactors.deno.dev/interactors/images/index.html' | ||
}); | ||
|
||
writeFileSync("./build/interactors/sitemap.xml", builder.buildObject(sitemap)); | ||
|
||
const assets = readdirSync("./build/interactors/assets/js"); | ||
|
||
writeFileSync("./build/interactors/assets/js/index.html",` | ||
<html> | ||
<head> | ||
${assets.map((asset) => ` <link rel="asset" href="${asset}"/>`).join("\n")} | ||
</head> | ||
<body> | ||
<h1> JavaScript Index</h1> | ||
<ul> | ||
${assets.map((asset) => ` <li><a href="${asset}">${asset}</a></li>`).join("\n")} | ||
</ul> | ||
<body> | ||
<html> | ||
`); | ||
|
||
const images = readdirSync("./build/interactors/images"); | ||
|
||
writeFileSync("./build/interactors/images/index.html",` | ||
<html> | ||
<head> | ||
${images.map((image) => ` <link rel="asset" href="${image}"/>`).join("\n")} | ||
</head> | ||
<body> | ||
<h1> JavaScript Index</h1> | ||
<ul> | ||
${images.map((image) => ` <li><a href="${image}">${image}</a></li>`).join("\n")} | ||
</ul> | ||
<body> | ||
<html> | ||
`); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters