diff --git a/roq-data/deployment/src/main/java/io/quarkiverse/roq/data/deployment/RoqDataRuntimeProcessor.java b/roq-data/deployment/src/main/java/io/quarkiverse/roq/data/deployment/RoqDataRuntimeProcessor.java index 413fb439..4c8c1442 100644 --- a/roq-data/deployment/src/main/java/io/quarkiverse/roq/data/deployment/RoqDataRuntimeProcessor.java +++ b/roq-data/deployment/src/main/java/io/quarkiverse/roq/data/deployment/RoqDataRuntimeProcessor.java @@ -16,6 +16,7 @@ import io.quarkus.deployment.annotations.ExecutionTime; import io.quarkus.deployment.annotations.Record; import io.quarkus.deployment.builditem.FeatureBuildItem; +import io.quarkus.deployment.builditem.nativeimage.ReflectiveClassBuildItem; import io.vertx.core.json.JsonArray; import io.vertx.core.json.JsonObject; @@ -34,8 +35,10 @@ FeatureBuildItem feature() { @Record(ExecutionTime.STATIC_INIT) void generateSyntheticBeans(BuildProducer beansProducer, List roqDataJsonBuildItems, + BuildProducer reflectiveClassProducer, RoqDataRecorder recorder) { - + reflectiveClassProducer.produce( + ReflectiveClassBuildItem.builder(JsonObject.class).serialization().constructors().fields().methods().build()); for (RoqDataJsonBuildItem roqData : roqDataJsonBuildItems) { if (roqData.getData() instanceof JsonObject) { beansProducer.produce(SyntheticBeanBuildItem.configure(JsonObject.class) @@ -58,8 +61,11 @@ void generateSyntheticBeans(BuildProducer beansProducer, @BuildStep @Record(ExecutionTime.STATIC_INIT) void generateDataMappings(RoqDataRecorder roqDataRecorder, List dataBeanBuildItems, + BuildProducer reflectiveClassProducer, BuildProducer syntheticBeansProducer) { for (RoqDataBeanBuildItem beanBuildItem : dataBeanBuildItems) { + reflectiveClassProducer.produce(ReflectiveClassBuildItem.builder(beanBuildItem.getBeanClass()).serialization() + .constructors().fields().methods().build()); syntheticBeansProducer.produce(SyntheticBeanBuildItem.configure(beanBuildItem.getBeanClass()) .scope(beanBuildItem.isRecord() ? Singleton.class : ApplicationScoped.class) .named(beanBuildItem.getName()) diff --git a/roq-frontmatter/deployment/src/main/java/io/quarkiverse/roq/frontmatter/deployment/RoqFrontMatterProcessor.java b/roq-frontmatter/deployment/src/main/java/io/quarkiverse/roq/frontmatter/deployment/RoqFrontMatterProcessor.java index 8457d6fd..87a8ebc3 100644 --- a/roq-frontmatter/deployment/src/main/java/io/quarkiverse/roq/frontmatter/deployment/RoqFrontMatterProcessor.java +++ b/roq-frontmatter/deployment/src/main/java/io/quarkiverse/roq/frontmatter/deployment/RoqFrontMatterProcessor.java @@ -63,9 +63,9 @@ void generateTemplate( } validationParserHookProducer.produce(new ValidationParserHookBuildItem(c -> { if (templates.contains(c.getTemplateId())) { - //c.addParameter("page", Page.class.getName()); - //c.addParameter("site", Site.class.getName()); - //c.addParameter("collections", RoqCollections.class.getName()); + c.addParameter("page", Page.class.getName()); + c.addParameter("site", Site.class.getName()); + c.addParameter("collections", RoqCollections.class.getName()); } })); @@ -83,7 +83,7 @@ AdditionalIndexedClassesBuildItem addSite() { } @BuildStep - @Record(ExecutionTime.RUNTIME_INIT) + @Record(ExecutionTime.STATIC_INIT) RoqFrontMatterOutputBuildItem bindFrontMatterData(BuildProducer beansProducer, List roqFrontMatterBuildItems, RoqFrontMatterRecorder recorder) { @@ -108,7 +108,6 @@ RoqFrontMatterOutputBuildItem bindFrontMatterData(BuildProducer addBuildItem(Path root, HashSet { watch.produce(HotDeploymentWatchedFileBuildItem.builder().setLocation(file.toAbsolutePath().toString()).build()); - var relative = collection != null ? collection + "/" + root.relativize(file) : root.relativize(file).toString(); + var relative = toUnixPath( + collection != null ? collection + "/" + root.relativize(file) : root.relativize(file).toString()); String sourcePath = relative; String templatePath = removeExtension(relative) + ".html"; diff --git a/roq-frontmatter/runtime/src/main/java/io/quarkiverse/roq/frontmatter/runtime/RoqCollections.java b/roq-frontmatter/runtime/src/main/java/io/quarkiverse/roq/frontmatter/runtime/RoqCollections.java index b56cb35f..ad180c3a 100644 --- a/roq-frontmatter/runtime/src/main/java/io/quarkiverse/roq/frontmatter/runtime/RoqCollections.java +++ b/roq-frontmatter/runtime/src/main/java/io/quarkiverse/roq/frontmatter/runtime/RoqCollections.java @@ -1,12 +1,7 @@ package io.quarkiverse.roq.frontmatter.runtime; -import java.util.HashMap; import java.util.Map; -public class RoqCollections extends HashMap { - - public RoqCollections(Map map) { - super(map); - } +public record RoqCollections(Map collections) { } diff --git a/roq-frontmatter/runtime/src/main/java/io/quarkiverse/roq/frontmatter/runtime/RoqTemplateExtension.java b/roq-frontmatter/runtime/src/main/java/io/quarkiverse/roq/frontmatter/runtime/RoqTemplateExtension.java index 4aaf44af..12165d33 100644 --- a/roq-frontmatter/runtime/src/main/java/io/quarkiverse/roq/frontmatter/runtime/RoqTemplateExtension.java +++ b/roq-frontmatter/runtime/src/main/java/io/quarkiverse/roq/frontmatter/runtime/RoqTemplateExtension.java @@ -29,6 +29,11 @@ public static Object data(Page page, String key) { return page.data(key); } + @TemplateExtension(matchName = "*") + public static RoqCollection data(RoqCollections collections, String key) { + return collections.collections().get(key); + } + @TemplateExtension public static Object readTime(Page page) { final long count = numberOfWords(page.rawContent());