- Feature Image funktioniert
- neue Gallerie hinzugefügt
This commit is contained in:
parent
4c1c2c3e6a
commit
d9df4947f4
2 changed files with 27 additions and 0 deletions
|
|
@ -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++;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -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, @"<img\s+[^>]*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);
|
||||
|
||||
|
|
|
|||
Loading…
Reference in a new issue