Skip to content

Commit 33ba431

Browse files
authored
Only hide the github edit link (#1645)
* Only hide the github edit link So we can make it visible with query string Also, make it always visible in isolated builds * Refactor * Remove deleted property * Run prettier
1 parent fb91e75 commit 33ba431

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.HideEditThisPage ? "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
@@ -12,6 +12,7 @@ public record MarkdownLayoutViewModel : GlobalLayoutViewModel
1212
{
1313
public required string? GithubEditUrl { get; init; }
1414

15+
public required bool HideEditThisPage { get; init; }
1516
public required string? ReportIssueUrl { get; init; }
1617

1718
public required INavigationItem[] Parents { get; init; }

src/Elastic.Markdown/Page/Index.cshtml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,8 @@
2828
NavigationHtml = Model.NavigationHtml,
2929
NavigationFileName = Model.NavigationFileName,
3030
UrlPathPrefix = Model.UrlPathPrefix,
31-
GithubEditUrl = Model.Features.DisableGitHubEditLink ? null : Model.GithubEditUrl,
31+
GithubEditUrl = Model.GithubEditUrl,
32+
HideEditThisPage = Model.Features.DisableGitHubEditLink && Model.IsAssemblerBuild,
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)