public async Task <IActionResult> IndexAsync([FromQuery] string theme, long id, CancellationToken token) { _userManager.TryGetLongUserId(User, out var userId); var query = new DocumentById(id, userId); var model = await _queryBus.QueryAsync(query, token); if (model == null) { return(NotFound()); } if (model.DuplicateId.HasValue && id != model.DuplicateId) { var url = Url.RouteUrl("ShortDocumentLink2", new { id = model.DuplicateId.Value }, "https"); Response.Headers.Add("Link", $"<{url}>; rel=\"canonical\""); } ViewBag.title = _localizer["Title", model.Document.Course, model.Document.Title]; ViewBag.metaDescription = _localizer["Description", model.Document.Course]; Country country = model.Document.User.Country; if (model.Document.DocumentType == DocumentType.Video && !string.IsNullOrEmpty(model.Document.Snippet)) { var jsonLd = new VideoObject() { Description = model.Document.Snippet, Name = model.Document.Title, ThumbnailUrl = new Uri(_urlBuilder.BuildDocumentImageShareEndpoint(model.Document.Id, new { width = 703, height = 395, mode = "crop", theme, rtl = country.MainLanguage.Info.TextInfo.IsRightToLeft.ToString() })), UploadDate = model.Document.DateTime, Duration = model.Document.Duration, }; ViewBag.jsonLd = jsonLd; } ViewBag.ogImage = new Uri(_urlBuilder.BuildDocumentImageShareEndpoint(model.Document.Id, new { width = 1200, height = 630, mode = "crop", theme, rtl = country.MainLanguage.Info.TextInfo.IsRightToLeft.ToString() })); ViewBag.ogTitle = model.Document.Title; ViewBag.ogDescription = _localizer.WithCulture(country.MainLanguage.Info) ["OgDescription", model.Document.Course]; ViewBag.ogImageWidth = 1200; ViewBag.ogImageHeight = 630; return(View()); }