diff --git a/CHANGELOG.md b/CHANGELOG.md index 0f480d4..2d7ebb4 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -67,6 +67,9 @@ The eraser, laser pointer and polygon tools, pinch zoom, and features that forks - The showcase has keyboard shortcuts for the tools, undo, redo, copy, paste, delete, save and zoom, listed by `?`. - The showcase is deployed to by `.github/workflows/pages.yml`, when the library, the showcase or their dependencies change on `master`, and on demand from the Actions tab. +- The page of the showcase has a link preview (Open Graph and Twitter card tags, with a 1200 x 630 image), so a + link to it shows a title, a description and an image in chats and on social networks. It also has PNG icons + (32 pixel and Apple touch) next to the icon file. ### Changed diff --git a/packages/showcase/public/apple-touch-icon.png b/packages/showcase/public/apple-touch-icon.png new file mode 100644 index 0000000..094b32a Binary files /dev/null and b/packages/showcase/public/apple-touch-icon.png differ diff --git a/packages/showcase/public/base.html b/packages/showcase/public/base.html index 8d94e82..35f4c91 100644 --- a/packages/showcase/public/base.html +++ b/packages/showcase/public/base.html @@ -10,6 +10,34 @@ + + + + + + + + + + + + + + + + + +
diff --git a/packages/showcase/public/favicon-32.png b/packages/showcase/public/favicon-32.png new file mode 100644 index 0000000..ffbfb20 Binary files /dev/null and b/packages/showcase/public/favicon-32.png differ diff --git a/packages/showcase/public/og-image.png b/packages/showcase/public/og-image.png new file mode 100644 index 0000000..4d224bb Binary files /dev/null and b/packages/showcase/public/og-image.png differ diff --git a/packages/showcase/webpack.config.js b/packages/showcase/webpack.config.js index 1cd4790..0301815 100644 --- a/packages/showcase/webpack.config.js +++ b/packages/showcase/webpack.config.js @@ -1,8 +1,42 @@ +const fs = require("fs"); const path = require("path"); +const webpack = require("webpack"); const HtmlWebpackPlugin = require("html-webpack-plugin"); const port = 23000; +/** + * Where the showcase is deployed (GitHub Pages). The link preview of the page (Open Graph + * and Twitter card) needs absolute URLs, a relative one shows no image. + */ +const siteUrl = "https://tbolis.github.io/react-sketch/"; + +/** The files of public/ which the build copies as they are, the page links them by name */ +const staticFiles = ["og-image.png", "apple-touch-icon.png", "favicon-32.png"]; + +class CopyStaticFiles { + apply(compiler) { + compiler.hooks.thisCompilation.tap("CopyStaticFiles", (compilation) => { + compilation.hooks.processAssets.tap( + { + name: "CopyStaticFiles", + stage: webpack.Compilation.PROCESS_ASSETS_STAGE_ADDITIONAL, + }, + () => { + for (const name of staticFiles) { + const file = path.join(__dirname, "public", name); + compilation.fileDependencies.add(file); + compilation.emitAsset( + name, + new webpack.sources.RawSource(fs.readFileSync(file)) + ); + } + } + ); + }); + } +} + module.exports = { target: "web", entry: "./src/index.tsx", @@ -59,6 +93,8 @@ module.exports = { filename: "index.html", template: "./public/base.html", favicon: "./public/favicon.ico", + siteUrl, }), + new CopyStaticFiles(), ], };