Prepare your SPA for searching system bots like a boss!
prerender-go creates html pages for your SPA and allow you to put htmls as files to
Amazon S3 bucket or in file system. Use them as response when google|yandex|whatever
crawler visits your site by simple rewrite or proxy_pass rule in nginx.
Create configuration for prerender and storage in configuration/<stage> folder.
Default stage is development, selected by the STAGE env var; every stage is
merged over configuration/defaults. How to configure you can guess by reading
configs. ;) If not - ask us.
make help lists every target. Targets are grouped by area with a dot:
build.*, docker.*, test.*, compose.*.
On the host machine (Google Chrome must be installed):
make run
In docker:
make docker.build
docker run --rm \
--name prerender \
-e STAGE=development \
-v "$(pwd)"/configuration/development:/app/configuration/development \
spacetabio/prerender-go:<version>
docker-compose.yml brings up everything the service talks to: a JS-rendered test
site behind nginx, a real headless Chrome, and MinIO as S3-compatible storage.
make compose.up # site + browser + storage
make compose.run # one prerender run against them
make compose.pages # what ended up in storage
make compose.down
STAGE=docker (default) stores into MinIO; STAGE=docker-local stores into
./.pages. MinIO console is at http://localhost:19001 (prerender/prerender123);
override the host ports with MINIO_PORT / MINIO_CONSOLE_PORT.
cmd/cli/ binary entrypoint, cobra commands, report rendering
internal/service/
config/ configuration structs and loading
entity/ Page, Link
valueObject/ PageURL, FileName, HTTPStatus, Body, enums
query/
listSitemapLinks/ reads the sitemaps and returns their links
filterStaleLinks/ keeps the links whose stored html is out of date
command/
renderPage/ Command + CommandHandler over the browser
storePage/ Command + CommandHandler over the repository
usecase/prerender/ the run: lookup -> filter -> render -> store
repository/page/ page storage
local/ directory tree on disk
s3/ S3-compatible bucket
client/ chrome (CDP) and sitemap (HTTP) adapters
ioc/ command and query registration
pkg/checker/ use case wiring completeness check
pkg/logger/ zap setup
pkg/now/ injectable clock
docker/ Dockerfile and the compose test site
src/ makefile blocks, included by the root Makefile
A Query/Command is a struct with private fields: its constructor turns raw input
into value objects and entities, returning an error when they do not hold up, while
NewXxxUnsafe takes values that are already trusted. The matching QueryHandler /
CommandHandler carries no logic; it executes through an interface declared in the
same package, and holds the parameters of its own work, supplied once when the
service starts. Use cases take their handlers through functional options and expose a
single Run.
MIT License
Copyright (c) 2020 SpaceTab.io
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.