Introduce transition page while preserving meta tags for crawlers #60
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Problem
Provide a transition page on redirect for browsers, whilst preserving meta tags for social media crawlers.
Closes #10
Solution
Detecting a crawler
Crawlers tend to have fairly unique user-agent (UA) strings, which are either terse or have the word "bot" embedded (see Telegram, Facebook and Google).
To discern between bots/crawlers and human users, we rely on the popular
ua-parser-js
library to parse the user-agent string and determine additional metadata such aswhich would be readily available for common browsers but not for crawler UAs. The server only serves the transition page if all three pieces of metadata can be determined with confidence. This method leans towards safety - the server should prefer immediately redirecting when operating under uncertainty, rather than risk serving a transition page to a crawler.
TODOs
Tests
Also see metatags.io.
Features:
Improvements:
src
which can take advantage of hot-reloadingScreenshots
Desktop
Deploy Notes
New dependencies:
ua-parser-js
: User-agent string parsing libraryNew dev dependencies:
copyfiles
: Used to move server-side EJS template files into/build
after Typescript compilation