Skip to content

Commit 49337b4

Browse files
committed
Only hide the github edit link
So we can make it visible with query string Also, make it always visible in isolated builds
1 parent a125677 commit 49337b4

File tree

6 files changed

+12
-2
lines changed

6 files changed

+12
-2
lines changed

src/Elastic.Documentation.Site/Assets/main.ts

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,12 @@ document.addEventListener('htmx:load', function (event) {
3535
openDetailsWithAnchor()
3636
initDismissibleBanner()
3737
initImageCarousel()
38+
39+
const urlParams = new URLSearchParams(window.location.search);
40+
const editParam = urlParams.has('edit');
41+
if (editParam) {
42+
$('.edit-this-page.hidden')?.classList.remove("hidden")
43+
}
3844
})
3945

4046
// Don't remove style tags because they are used by the elastic global nav.

src/Elastic.Markdown/HtmlWriter.cs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -119,6 +119,7 @@ private async Task<RenderResult> RenderLayout(MarkdownFile markdown, MarkdownDoc
119119

120120
var slice = Page.Index.Create(new IndexViewModel
121121
{
122+
IsAssemblerBuild = DocumentationSet.Context.AssemblerBuild,
122123
SiteName = siteName,
123124
DocSetName = DocumentationSet.Name,
124125
Title = markdown.Title ?? "[TITLE NOT SET]",

src/Elastic.Markdown/Layout/_TableOfContents.cshtml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
<ul class="mt-6 hidden md:flex items-center lg:block gap-4">
1010
@if (!string.IsNullOrEmpty(Model.GithubEditUrl))
1111
{
12-
<li class="edit-this-page lg:not-first:mt-1">
12+
<li class="edit-this-page lg:not-first:mt-1 @(Model.Features.DisableGitHubEditLink && Model.IsAssemblerBuild ? "hidden" : string.Empty)">
1313
<a href="@Model.GithubEditUrl" class="link text-sm" target="_blank">
1414
<svg class="link-icon" xmlns="http://www.w3.org/2000/svg" fill="none" viewBox="0 0 24 24" stroke-width="1.5" stroke="currentColor">
1515
<path stroke-linecap="round" stroke-linejoin="round" d="m16.862 4.487 1.687-1.688a1.875 1.875 0 1 1 2.652 2.652L6.832 19.82a4.5 4.5 0 0 1-1.897 1.13l-2.685.8.8-2.685a4.5 4.5 0 0 1 1.13-1.897L16.863 4.487Zm0 0L19.5 7.125"/>

src/Elastic.Markdown/MarkdownLayoutViewModel.cs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ namespace Elastic.Markdown;
1010

1111
public record MarkdownLayoutViewModel : GlobalLayoutViewModel
1212
{
13+
public required bool IsAssemblerBuild { get; init; }
1314
public required string? GithubEditUrl { get; init; }
1415

1516
public required string? ReportIssueUrl { get; init; }

src/Elastic.Markdown/Page/Index.cshtml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@
1010
@functions {
1111
public MarkdownLayoutViewModel LayoutModel => new()
1212
{
13+
IsAssemblerBuild = Model.IsAssemblerBuild,
1314
DocsBuilderVersion = ShortId.Create(BuildContext.Version),
1415
Layout = Model.CurrentDocument.YamlFrontMatter?.Layout,
1516
RenderHamburgerIcon = Model.CurrentDocument.YamlFrontMatter?.Layout != MarkdownPageLayout.LandingPage,
@@ -28,7 +29,7 @@
2829
NavigationHtml = Model.NavigationHtml,
2930
NavigationFileName = Model.NavigationFileName,
3031
UrlPathPrefix = Model.UrlPathPrefix,
31-
GithubEditUrl = Model.Features.DisableGitHubEditLink ? null : Model.GithubEditUrl,
32+
GithubEditUrl = Model.GithubEditUrl,
3233
AllowIndexing = Model.AllowIndexing,
3334
CanonicalBaseUrl = Model.CanonicalBaseUrl,
3435
GoogleTagManager = Model.GoogleTagManager,

src/Elastic.Markdown/Page/IndexViewModel.cs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@ namespace Elastic.Markdown.Page;
1717

1818
public class IndexViewModel
1919
{
20+
public required bool IsAssemblerBuild { get; init; }
2021
public required string SiteName { get; init; }
2122
public required string DocSetName { get; init; }
2223
public required string Title { get; init; }

0 commit comments

Comments
 (0)