diff --git a/CSharpGhostImporter/HtmlConverter.cs b/CSharpGhostImporter/HtmlConverter.cs index b3618b6..31c4b2a 100644 --- a/CSharpGhostImporter/HtmlConverter.cs +++ b/CSharpGhostImporter/HtmlConverter.cs @@ -187,6 +187,9 @@ namespace wp2ghost SetClasses(ghostGallery, "kg-card kg-gallery-card"); AddWideClass(ghostGallery, gallery); + // Neue Format-Prüfung: data-carousel-extra Attribut speichern + string carouselExtra = gallery.GetAttributeValue("data-carousel-extra", ""); + var container = htmlDoc.CreateElement("div"); container.AddClass("kg-gallery-container"); @@ -204,6 +207,7 @@ namespace wp2ghost AppendGalleryRows(htmlDoc, container, wrappers, GetGalleryColumns(gallery)); ghostGallery.AppendChild(container); + // Caption aus erstem figcaption im Gallery-Container extrahieren var captionNode = gallery.SelectSingleNode(".//figcaption"); if (captionNode != null && !string.IsNullOrWhiteSpace(captionNode.InnerText)) { @@ -213,6 +217,14 @@ namespace wp2ghost ghostGallery.AddClass("kg-card-hascaption"); } + // data-carousel-extra als Ghost-Attribut übertragen (falls vorhanden) + if (!string.IsNullOrEmpty(carouselExtra)) + { + var extraAttr = htmlDoc.CreateAttribute("data-carousel-extra"); + extraAttr.Value = carouselExtra; + ghostGallery.Attributes.Append(extraAttr); + } + gallery.ParentNode?.ReplaceChild(ghostGallery, gallery); count++; } diff --git a/CSharpGhostImporter/PostFetcher.cs b/CSharpGhostImporter/PostFetcher.cs index a8e38db..5375be8 100644 --- a/CSharpGhostImporter/PostFetcher.cs +++ b/CSharpGhostImporter/PostFetcher.cs @@ -121,6 +121,21 @@ namespace wp2ghost var parsedDate = DateTime.MinValue; var postDate = DateTime.TryParse(wpPost.Date, out parsedDate) ? parsedDate : new DateTime(2026, 9, 1); + // Featured Image: falls von der WP API nicht gesetzt, ersten Bild-URL aus HTML nehmen + if (string.IsNullOrEmpty(wpPost.FeaturedImage)) + { + var firstImgMatch = System.Text.RegularExpressions.Regex.Match(htmlContent, @"]*src=[""']([^""']+)[""'][^>]*>", System.Text.RegularExpressions.RegexOptions.IgnoreCase); + if (firstImgMatch.Success) + { + string firstImgUrl = firstImgMatch.Groups[1].Value; + if (IsInternalUrl(firstImgUrl, wpHost)) + { + wpPost.FeaturedImage = firstImgUrl; + Console.WriteLine($" [Featured Image] Aus HTML extrahiert (da API keine lieferte): {Path.GetFileName(new Uri(firstImgUrl).AbsolutePath)}"); + } + } + } + // Alle internen Bild-URLs aus dem HTML extrahieren (keine externen Links) var htmlImageUrls = ExtractImageUrls(htmlContent, wpHost);