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,18 @@ 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:logo" ).content ("https://nox.zone/favicon.ico" ),
144+ meta .name ("og:title" ).content (title ),
140145 meta .name ("twitter:title" ).content (title ),
146+ meta .name ("og:description" ).content (description ),
141147 meta .name ("twitter:description" ).content (description )
142148 );
143149 var card = thumbnail .map (thumb -> List .of (
144150 // TODO: the root URL shouldn't be hard-coded
151+ meta .name ("og:image" ).content ("https://nox.zone/thumbnails/" + thumb ),
145152 meta .name ("twitter:image" ).content ("https://nox.zone/thumbnails/" + thumb ),
146153 meta .name ("twitter:card" ).content ("summary_large_image" )))
147154 .orElse (List .of (meta .name ("twitter:card" ).content ("summary" )));
@@ -163,24 +170,28 @@ public Element compose() {
163170 footer .classes (STYLE .footer ))));
164171 }
165172
173+ public Layout slug (String slug ) {
174+ return new Layout (slug , this .title , this .description , this .thumbnail , this .content );
175+ }
176+
166177 public Layout title (String title ) {
167- return new Layout (title , this .description , this .thumbnail , this .content );
178+ return new Layout (this . slug , title , this .description , this .thumbnail , this .content );
168179 }
169180
170181 public Layout description (String description ) {
171- return new Layout (this .title , description , this .thumbnail , this .content );
182+ return new Layout (this .slug , this . title , description , this .thumbnail , this .content );
172183 }
173184
174185 public Layout thumbnail (Optional <String > thumbnail ) {
175- return new Layout (this .title , this .description , thumbnail , this .content );
186+ return new Layout (this .slug , this . title , this .description , thumbnail , this .content );
176187 }
177188
178189 public Layout content (List <? extends Element > children ) {
179- return new Layout (this .title , this .description , this .thumbnail , children );
190+ return new Layout (this .slug , this . title , this .description , this .thumbnail , children );
180191 }
181192
182193 public Layout content (Element ... children ) {
183- return new Layout (this .title , this .description , this .thumbnail , List .of (children ));
194+ return new Layout (this .slug , this . title , this .description , this .thumbnail , List .of (children ));
184195 }
185196
186197}
0 commit comments