Skip to content

Commit a7cf57b

Browse files
reakaleekclaude
andauthored
Assembler: embed elastic-website-search web component on staging (#3411)
Adds the elastic-website-search web component (chat-mode="input") to the assembler build, gated behind a new WEBSITE_SEARCH feature flag. The script URL is configurable per environment via website_search_url in assembler.yml, so staging and local dev can each point at their own bundle. The chat input mounts into a sticky container at the bottom of the content column with a short entrance animation. Co-authored-by: Claude Sonnet 4.6 (1M context) <noreply@anthropic.com>
1 parent 30e4fca commit a7cf57b

7 files changed

Lines changed: 50 additions & 0 deletions

File tree

config/assembler.yml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,8 @@ environments:
2424
cookies_win: x
2525
feature_flags:
2626
SEARCH_OR_ASK_AI: true
27+
WEBSITE_SEARCH: true
28+
website_search_url: https://staging-website.elastic.co/search/elastic-website-search.js
2729
edge:
2830
uri: https://d34ipnu52o64md.cloudfront.net
2931
path_prefix: docs
@@ -38,6 +40,8 @@ environments:
3840
path_prefix: docs
3941
feature_flags:
4042
SEARCH_OR_ASK_AI: true
43+
WEBSITE_SEARCH: true
44+
website_search_url: http://localhost:4078/elastic-website-search.js
4145
preview:
4246
uri: https://docs-v3-preview.elastic.dev
4347
path_prefix: ${ASSEMBLER_PREVIEW_PATH_PREFIX}

src/Elastic.Documentation.Configuration/Assembler/PublishEnvironment.cs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,4 +31,7 @@ public record PublishEnvironment
3131

3232
[YamlMember(Alias = "feature_flags")]
3333
public Dictionary<string, bool> FeatureFlags { get; set; } = [];
34+
35+
[YamlMember(Alias = "website_search_url")]
36+
public string? WebsiteSearchScriptUrl { get; set; }
3437
}

src/Elastic.Documentation.Configuration/Builder/FeatureFlags.cs

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,14 @@ public bool StagingElasticNavEnabled
3838
set => _featureFlags["staging-elastic-nav"] = value;
3939
}
4040

41+
public bool WebsiteSearchEnabled
42+
{
43+
get => IsEnabled("website-search");
44+
set => _featureFlags["website-search"] = value;
45+
}
46+
47+
public string? WebsiteSearchScriptUrl { get; set; }
48+
4149
public bool AirGappedEnabled
4250
{
4351
get => IsEnabled("air-gapped");

src/Elastic.Documentation.Site/Assets/assembler.css

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,21 @@ body.air-gapped elastic-docs-header .euiHeader {
2121
padding-inline: calc((100vw - var(--max-layout-width)) / 2 + 8px);
2222
}
2323

24+
@keyframes website-search-enter {
25+
from {
26+
opacity: 0;
27+
translate: 0 1rem;
28+
}
29+
to {
30+
opacity: 1;
31+
translate: 0 0;
32+
}
33+
}
34+
35+
#elastic-website-search-input-container {
36+
animation: website-search-enter 0.2s ease-out 0.6s both;
37+
}
38+
2439
#elastic-nav {
2540
@media screen and (min-width: 1200px) {
2641
[data-component='Container'] {

src/Elastic.Documentation.Site/Layout/_Head.cshtml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,10 @@
2727
}
2828
<script>window.__DOCS_CONFIG__=@(new HtmlString(Model.FrontendConfigJson));</script>
2929
<script src="@Model.Static("main.js")" defer></script>
30+
@if (Model.Features.WebsiteSearchEnabled && Model.Features.WebsiteSearchScriptUrl is { } websiteSearchUrl)
31+
{
32+
<script type="module" src="@websiteSearchUrl"></script>
33+
}
3034
@if (Model.CanonicalBaseUrl is not null)
3135
{
3236
<link rel="canonical" href="@Model.CanonicalUrl" />

src/Elastic.Markdown/_Layout.cshtml

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,12 @@
4747
@await RenderBodyAsync()
4848
</article>
4949
@await RenderPartialAsync(_PrevNextNav.Create(Model))
50+
@if (Model.Features.WebsiteSearchEnabled && Model.Features.WebsiteSearchScriptUrl is not null)
51+
{
52+
<div id="elastic-website-search-input-container"
53+
class="sticky bottom-8 mt-8 z-40">
54+
</div>
55+
}
5056
</div>
5157
@await RenderPartialAsync(_TableOfContents.Create(Model))
5258
</main>
@@ -89,6 +95,15 @@
8995
break;
9096
}
9197
</div>
98+
@if (Model.Features.WebsiteSearchEnabled && Model.Features.WebsiteSearchScriptUrl is not null)
99+
{
100+
<elastic-website-search
101+
nav-mode="off"
102+
chat-enabled="true"
103+
chat-mode="input"
104+
chat-input-container="#elastic-website-search-input-container">
105+
</elastic-website-search>
106+
}
92107
@if (RenderHeaderAndFooter)
93108
{
94109
if (Model.BuildType == BuildType.Assembler)

src/services/Elastic.Documentation.Assembler/Building/AssemblerBuilder.cs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -180,6 +180,7 @@ private void SetFeatureFlags(AssemblerDocumentationSet set)
180180
_logger.LogInformation("Setting feature flag: {ConfigurationFeatureFlagKey}={ConfigurationFeatureFlagValue}", configurationFeatureFlag.Key, configurationFeatureFlag.Value);
181181
set.DocumentationSet.Configuration.Features.Set(configurationFeatureFlag.Key, configurationFeatureFlag.Value);
182182
}
183+
set.DocumentationSet.Configuration.Features.WebsiteSearchScriptUrl = set.AssembleContext.Environment.WebsiteSearchScriptUrl;
183184
}
184185

185186
private void LogBuildTimes(List<(string Name, int FileCount, TimeSpan Duration)> buildTimes)

0 commit comments

Comments
 (0)