Add docsearch-config.json.hbs and change publish-docs.sh

Issue gh-2234
This commit is contained in:
Marcus Da Coregio
2023-02-15 14:41:32 -03:00
parent 20109f8767
commit befa470b2c
2 changed files with 86 additions and 3 deletions

View File

@@ -0,0 +1,65 @@
{
"index_name": "spring-session-docs",
"start_urls": [
{{#each latestVersions}}
{
"url": "{{{@root.site.url}}}/{{#if (eq ./activeVersionSegment '')}}(?:$|index.html$|[a-z].*){{else}}{{{./activeVersionSegment}}}/{{/if}}",
"extra_attributes": {
"component": "{{#if (eq ./name 'ROOT')}}session{{else}}{{{./name}}}{{/if}}",
"version": "{{{./version}}}",
"version_rank": {{#if (eq ./activeVersionSegment '')}}1{{else}}2{{/if}}
}
}{{#unless @last}},{{/unless}}
{{/each}}
],
"sitemap_urls": [
"{{{site.url}}}/sitemap.xml"
],
"scrape_start_urls": true,
"stop_urls": [
{{#each stopPages}}
"{{{@root.site.url}}}{{{./pub.url}}}"{{#unless @last}},{{/unless}}
{{/each}}
],
"selectors": {
"default": {
"lvl0": {
"global": true,
"selector": ".nav-panel-explore .context .title, .nav-panel-explore .context .version"
},
"lvl1": ".doc > h1.page",
"lvl2": ".doc .sect1 > h2:first-child",
"lvl3": ".doc .sect2 > h3:first-child",
"lvl4": ".doc .sect3 > h4:first-child",
"text": ".doc p, .doc dt, .doc td.content, .doc th.tableblock"
}
},
"selectors_exclude": [
"#section-summary"
],
"min_indexed_level": 1,
"custom_settings": {
"advancedSyntax": true,
"attributesForFaceting": [
"component",
"version"
],
"attributesToRetrieve": [
"anchor",
"content",
"hierarchy",
"url",
"component",
"version"
],
"attributesToSnippet": [
"content:25"
],
"customRanking": [
"desc(weight.page_rank)",
"asc(version_rank)",
"desc(weight.level)",
"asc(weight.position)"
]
}
}

View File

@@ -1,22 +1,40 @@
#!/bin/bash
FROM=build/site
HOST="$1"
HOST_PATH="$2"
SSH_PRIVATE_KEY="$3"
SSH_KNOWN_HOST="$4"
CLOUDFLARE_ZONE_ID="$5"
CLOUDFLARE_CACHE_TOKEN="$6"
SSH_PRIVATE_KEY_PATH="$HOME/.ssh/${GITHUB_REPOSITORY:-publish-docs}"
if [ "$#" -ne 4 ]; then
echo -e "not enough arguments USAGE:\n\n$0 \$HOST \$HOST_PATH \$SSH_PRIVATE_KEY \$SSH_KNOWN_HOST\n\n" >&2
if [ "$#" -ne 6 ]; then
echo -e "not enough arguments USAGE:\n\n$0 \$HOST \$HOST_PATH \$SSH_PRIVATE_KEY \$SSH_KNOWN_HOST \$CLOUDFLARE_ZONE_ID \$CLOUDFLARE_CACHE_TOKEN\n\n" >&2
exit 1
fi
(
set -e
set -f
install -m 600 -D /dev/null "$SSH_PRIVATE_KEY_PATH"
echo "$SSH_PRIVATE_KEY" > "$SSH_PRIVATE_KEY_PATH"
echo "$SSH_KNOWN_HOST" > ~/.ssh/known_hosts
rsync --delete -avze "ssh -i $SSH_PRIVATE_KEY_PATH" build/site/ "$HOST:$HOST_PATH"
RSYNC_OPTS='-avz --delete'
if [ -f .full-build ]; then
unlink .full-build
BUILD_REFNAME=
fi
if [ -n "$BUILD_REFNAME" ]; then
RSYNC_OPTS="-c $RSYNC_OPTS$(find $FROM -mindepth 1 -maxdepth 1 \! -name 404.html \! -name '.*' -type f -printf ' --include /%P')"
RSYNC_OPTS="$RSYNC_OPTS$(find $FROM -mindepth 1 -maxdepth 1 -type d \! -name _ -printf ' --include /%P --include /%P/**') --exclude **"
fi
rsync $RSYNC_OPTS -e "ssh -i $SSH_PRIVATE_KEY_PATH" $FROM/ "$HOST:$HOST_PATH"
if [ -z "$BUILD_REFNAME" ]; then
curl -X POST "https://api.cloudflare.com/client/v4/zones/$CLOUDFLARE_ZONE_ID/purge_cache" \
-H "Content-Type:application/json" -H "Authorization: Bearer $CLOUDFLARE_CACHE_TOKEN" \
--data '{"files":["https://docs.spring.io/spring-session"]}'
fi
)
exit_code=$?