File tree Expand file tree Collapse file tree 4 files changed +32
-5
lines changed
Expand file tree Collapse file tree 4 files changed +32
-5
lines changed Original file line number Diff line number Diff line change @@ -2,6 +2,7 @@ package blog
22
33import (
44 "bytes"
5+ "regexp"
56 "time"
67)
78
@@ -47,3 +48,13 @@ func (p Post) Adminlink() string {
4748func (t Tag ) Permalink () string {
4849 return "/tag/" + t .Name
4950}
51+
52+ func (p Post ) ExtractImages () []string {
53+ var result []string
54+ pattern := regexp .MustCompile (`\[file\]\((.+)\)` )
55+ substrings := pattern .FindAllStringSubmatch ("" , - 1 )
56+ for _ , r := range substrings {
57+ result = append (result , r [1 ])
58+ }
59+ return result
60+ }
Original file line number Diff line number Diff line change @@ -12,7 +12,7 @@ require (
1212 github.com/stretchr/testify v1.8.4
1313 gorm.io/driver/mysql v1.5.1
1414 gorm.io/driver/sqlite v1.5.2
15- gorm.io/gorm e61b98d69677
15+ gorm.io/gorm v1.25.2-0.20230530020048-26663ab9bf55
1616)
1717
1818require (
Original file line number Diff line number Diff line change @@ -95,7 +95,6 @@ github.com/stretchr/testify v1.7.1/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/
9595github.com/stretchr/testify v1.8.0 /go.mod h1:yNjHg4UonilssWZ8iaSj1OCr/vHnekPRkoO+kdMU+MU =
9696github.com/stretchr/testify v1.8.1 /go.mod h1:w2LPCIKwWwSfY2zedu0+kehJoqGctiVI29o6fzry7u4 =
9797github.com/stretchr/testify v1.8.2 /go.mod h1:w2LPCIKwWwSfY2zedu0+kehJoqGctiVI29o6fzry7u4 =
98- github.com/stretchr/testify v1.8.3 h1:RP3t2pwF7cMEbC1dqtB6poj3niw/9gnV4Cjg5oW5gtY =
9998github.com/stretchr/testify v1.8.3 /go.mod h1:sz/lmYIOXD/1dqDmKjjqLyZ2RngseejIcXlSw2iwfAo =
10099github.com/stretchr/testify v1.8.4 h1:CcVxjf3Q8PM0mHUKJCdn+eZZtm5yQwehR5yeSVQQcUk =
101100github.com/stretchr/testify v1.8.4 /go.mod h1:sz/lmYIOXD/1dqDmKjjqLyZ2RngseejIcXlSw2iwfAo =
@@ -135,11 +134,8 @@ gopkg.in/yaml.v3 v3.0.1 h1:fxVm/GzAzEWqLHuvctI91KS9hhNmmWOoWu0XTYJS7CA=
135134gopkg.in/yaml.v3 v3.0.1 /go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM =
136135gorm.io/driver/mysql v1.5.1 h1:WUEH5VF9obL/lTtzjmML/5e6VfFR/788coz2uaVCAZw =
137136gorm.io/driver/mysql v1.5.1 /go.mod h1:Jo3Xu7mMhCyj8dlrb3WoCaRd1FhsVh+yMXb1jUInf5o =
138- gorm.io/driver/sqlite v1.5.1 h1:hYyrLkAWE71bcarJDPdZNTLWtr8XrSjOWyjUYI6xdL4 =
139- gorm.io/driver/sqlite v1.5.1 /go.mod h1:7MZZ2Z8bqyfSQA1gYEV6MagQWj3cpUkJj9Z+d1HEMEQ =
140137gorm.io/driver/sqlite v1.5.2 h1:TpQ+/dqCY4uCigCFyrfnrJnrW9zjpelWVoEVNy5qJkc =
141138gorm.io/driver/sqlite v1.5.2 /go.mod h1:qxAuCol+2r6PannQDpOP1FP6ag3mKi4esLnB/jHed+4 =
142- gorm.io/gorm v1.25.1 h1:nsSALe5Pr+cM3V1qwwQ7rOkw+6UeLrX5O4v3llhHa64 =
143139gorm.io/gorm v1.25.1 /go.mod h1:L4uxeKpfBml98NYqVqwAdmV1a2nBtAec/cf3fpucW/k =
144140gorm.io/gorm v1.25.2-0.20230530020048-26663ab9bf55 h1:sC1Xj4TYrLqg1n3AN10w871An7wJM0gzgcm8jkIkECQ =
145141gorm.io/gorm v1.25.2-0.20230530020048-26663ab9bf55 /go.mod h1:L4uxeKpfBml98NYqVqwAdmV1a2nBtAec/cf3fpucW/k =
Original file line number Diff line number Diff line change 99 < meta name ="description " content ="{{ .post.PreviewContent 155 }} ">
1010 < meta name ="robots " content ="index, follow " />
1111 < title > Jason Ernst: {{ .post.Title }}</ title >
12+ < script type ="application/ld+json ">
13+ {
14+ "@context" : "https://schema.org" ,
15+ "@type" : "BlogPosting" ,
16+ "headline" : "{{ .post.Title }}" ,
17+ "image" : [
18+ { { range . post . ExtractImages} }
19+ "https://www.jasonernst.com{{.}}" ,
20+ { { end} }
21+ "https://www.jasonernst.com/img/jason.jpg"
22+ ] ,
23+ "datePublished" : "{{ .post.CreatedAt }}" ,
24+ "dateModified" : "{{ .post.UpdatedAt }}" ,
25+ "author" : [ {
26+ "@type" : "Person" ,
27+ "name" : "Jason Ernst" ,
28+ "url" : "https://www.jasonernst.com"
29+ } ]
30+ }
31+ </ script >
1232 {{ else }}
1333 < meta name ="description " content ="Jason Ernst's blog, code, projects and publications ">
1434 < title > Jason Ernst: {{ .title }}</ title >
You can’t perform that action at this time.
0 commit comments