nice clean recipes pear.dunkirk.sh
recipes
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

feat: add meta parsing

+35
+35
internal/extract/schema/jsonld.go
··· 22 22 recipe := parseJSONLD(node) 23 23 if recipe != nil { 24 24 recipe.ExtractionMethod = "schema.org" 25 + if recipe.Description == "" { 26 + recipe.Description = findMetaDescription(doc) 27 + } 25 28 return recipe, true 26 29 } 27 30 } 28 31 29 32 return nil, false 33 + } 34 + 35 + func findMetaDescription(n *html.Node) string { 36 + var f func(*html.Node) string 37 + f = func(n *html.Node) string { 38 + if n.Type == html.ElementNode && n.Data == "meta" { 39 + name := "" 40 + prop := "" 41 + content := "" 42 + for _, a := range n.Attr { 43 + if a.Key == "name" { 44 + name = a.Val 45 + } 46 + if a.Key == "property" { 47 + prop = a.Val 48 + } 49 + if a.Key == "content" { 50 + content = a.Val 51 + } 52 + } 53 + if name == "description" || prop == "og:description" { 54 + return content 55 + } 56 + } 57 + for c := n.FirstChild; c != nil; c = c.NextSibling { 58 + if desc := f(c); desc != "" { 59 + return desc 60 + } 61 + } 62 + return "" 63 + } 64 + return f(n) 30 65 } 31 66 32 67 func findJSONLDScripts(n *html.Node) []string {