2222import static zone .nox .components .Components .footer ;
2323import static zone .nox .components .Components .header ;
2424
25- public record Layout (String title , String description , Optional <String > thumbnail , List <? extends Element > content ) implements Component {
25+ public record Layout (String slug , String title , String description , Optional <String > thumbnail , List <? extends Element > content ) implements Component {
2626
2727 public record Style (Classes layout , Classes page , Classes header , Classes content , Classes footer , Css css ) implements CssStyle { }
2828
@@ -137,11 +137,17 @@ public Element compose() {
137137 var metaElements = List .of (
138138 meta .name ("viewport" ).content ("width=device-width, initial-scale=1" ),
139139 meta .name ("description" ).content (description ),
140+ meta .name ("og:type" ).content ("website" ),
141+ // TODO: the root URL shouldn't be hard-coded
142+ meta .name ("og:url" ).content ("https://nox.zone/" + slug ),
143+ meta .name ("og:title" ).content (title ),
140144 meta .name ("twitter:title" ).content (title ),
145+ meta .name ("og:description" ).content (description ),
141146 meta .name ("twitter:description" ).content (description )
142147 );
143148 var card = thumbnail .map (thumb -> List .of (
144149 // TODO: the root URL shouldn't be hard-coded
150+ meta .name ("og:image" ).content ("https://nox.zone/thumbnails/" + thumb ),
145151 meta .name ("twitter:image" ).content ("https://nox.zone/thumbnails/" + thumb ),
146152 meta .name ("twitter:card" ).content ("summary_large_image" )))
147153 .orElse (List .of (meta .name ("twitter:card" ).content ("summary" )));
@@ -163,24 +169,28 @@ public Element compose() {
163169 footer .classes (STYLE .footer ))));
164170 }
165171
172+ public Layout slug (String slug ) {
173+ return new Layout (slug , this .title , this .description , this .thumbnail , this .content );
174+ }
175+
166176 public Layout title (String title ) {
167- return new Layout (title , this .description , this .thumbnail , this .content );
177+ return new Layout (this . slug , title , this .description , this .thumbnail , this .content );
168178 }
169179
170180 public Layout description (String description ) {
171- return new Layout (this .title , description , this .thumbnail , this .content );
181+ return new Layout (this .slug , this . title , description , this .thumbnail , this .content );
172182 }
173183
174184 public Layout thumbnail (Optional <String > thumbnail ) {
175- return new Layout (this .title , this .description , thumbnail , this .content );
185+ return new Layout (this .slug , this . title , this .description , thumbnail , this .content );
176186 }
177187
178188 public Layout content (List <? extends Element > children ) {
179- return new Layout (this .title , this .description , this .thumbnail , children );
189+ return new Layout (this .slug , this . title , this .description , this .thumbnail , children );
180190 }
181191
182192 public Layout content (Element ... children ) {
183- return new Layout (this .title , this .description , this .thumbnail , List .of (children ));
193+ return new Layout (this .slug , this . title , this .description , this .thumbnail , List .of (children ));
184194 }
185195
186196}
0 commit comments