Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions src/Elastic.Documentation.Site/Assets/main.ts
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,12 @@ document.addEventListener('htmx:load', function (event) {
openDetailsWithAnchor()
initDismissibleBanner()
initImageCarousel()

const urlParams = new URLSearchParams(window.location.search)
const editParam = urlParams.has('edit')
if (editParam) {
$('.edit-this-page.hidden')?.classList.remove('hidden')
}
})

// Don't remove style tags because they are used by the elastic global nav.
Expand Down
1 change: 1 addition & 0 deletions src/Elastic.Markdown/HtmlWriter.cs
Original file line number Diff line number Diff line change
Expand Up @@ -119,6 +119,7 @@ private async Task<RenderResult> RenderLayout(MarkdownFile markdown, MarkdownDoc

var slice = Page.Index.Create(new IndexViewModel
{
IsAssemblerBuild = DocumentationSet.Context.AssemblerBuild,
SiteName = siteName,
DocSetName = DocumentationSet.Name,
Title = markdown.Title ?? "[TITLE NOT SET]",
Expand Down
2 changes: 1 addition & 1 deletion src/Elastic.Markdown/Layout/_TableOfContents.cshtml
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
<ul class="mt-6 hidden md:flex items-center lg:block gap-4">
@if (!string.IsNullOrEmpty(Model.GithubEditUrl))
{
<li class="edit-this-page lg:not-first:mt-1">
<li class="edit-this-page lg:not-first:mt-1 @(Model.HideEditThisPage ? "hidden" : string.Empty)">
<a href="@Model.GithubEditUrl" class="link text-sm" target="_blank">
<svg class="link-icon" xmlns="http://www.w3.org/2000/svg" fill="none" viewBox="0 0 24 24" stroke-width="1.5" stroke="currentColor">
<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"/>
Expand Down
1 change: 1 addition & 0 deletions src/Elastic.Markdown/MarkdownLayoutViewModel.cs
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ public record MarkdownLayoutViewModel : GlobalLayoutViewModel
{
public required string? GithubEditUrl { get; init; }

public required bool HideEditThisPage { get; init; }
public required string? ReportIssueUrl { get; init; }

public required INavigationItem[] Parents { get; init; }
Expand Down
3 changes: 2 additions & 1 deletion src/Elastic.Markdown/Page/Index.cshtml
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,8 @@
NavigationHtml = Model.NavigationHtml,
NavigationFileName = Model.NavigationFileName,
UrlPathPrefix = Model.UrlPathPrefix,
GithubEditUrl = Model.Features.DisableGitHubEditLink ? null : Model.GithubEditUrl,
GithubEditUrl = Model.GithubEditUrl,
HideEditThisPage = Model.Features.DisableGitHubEditLink && Model.IsAssemblerBuild,
AllowIndexing = Model.AllowIndexing,
CanonicalBaseUrl = Model.CanonicalBaseUrl,
GoogleTagManager = Model.GoogleTagManager,
Expand Down
1 change: 1 addition & 0 deletions src/Elastic.Markdown/Page/IndexViewModel.cs
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ namespace Elastic.Markdown.Page;

public class IndexViewModel
{
public required bool IsAssemblerBuild { get; init; }
public required string SiteName { get; init; }
public required string DocSetName { get; init; }
public required string Title { get; init; }
Expand Down
Loading