diff --git a/CHANGELOG.md b/CHANGELOG.md index ed6f709..84ef3d2 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -9,6 +9,11 @@ ## Unreleased +* BREAKING: Changed collection configuration format to nest `path` within `inputs` + * Allows multiple inputs to merge into one collection + * Add ability to put each input under a sub key + * Allows fixed metadata to be attacked to each input + ## v0.2.1 (May 2, 2024) * Flatlake now looks into symlinks when finding content diff --git a/docs/content/docs/_index.md b/docs/content/docs/_index.md index 9499f88..79f17f2 100644 --- a/docs/content/docs/_index.md +++ b/docs/content/docs/_index.md @@ -58,9 +58,11 @@ A simple configuration to start with for the above folder structure is: ```yml collections: - output_key: "posts" - path: "collections/posts" + inputs: + - path: "collections/posts" - output_key: "people" - path: "collections/authors" + inputs: + - path: "collections/authors" ``` This denotes our `posts` and `authors` folders as collections, each output under the same name in our final API. diff --git a/docs/content/docs/collections.md b/docs/content/docs/collections.md index cb0eca2..55e887a 100644 --- a/docs/content/docs/collections.md +++ b/docs/content/docs/collections.md @@ -15,60 +15,79 @@ Collections are how files are grouped in Flatlake. Each collection specifies: `flatlake.yml`: ```yml collections: - - path: "collections/posts" - output_key: "posts" - - path: "collections/authors" - output_key: "people" + - output_key: "posts" + inputs: + - path: "collections/posts" + - output_key: "people" + inputs: + - path: "collections/authors" ``` ## Options -Each collection requires a `path` and an `output_key` to be defined. +Each collection requires an `output_key`, and at least one `inputs` entry containing a `path`. -### Path +### Input > Path -The path from the global `source` to this collection. +A path from the global `source` to add to this collection. -Files within this collection will be treated relative to this path. +Files within this collection input will be treated relative to this path. In the below example, a file at `/collections/posts/post-a.md` will be output at `/posts/post-a.json`. {{< diffcode >}} ```yml collections: -+ - path: "collections/posts" - output_key: "posts" + - output_key: "posts" + inputs: ++ - path: "collections/posts" ``` {{< /diffcode >}} -### Output key +### Input > Glob -The folder to use when writing single and list files for this collection. +The glob expression Flatlake should use when finding files within this collection. Defaults to `**/*.{md}` to select all markdown files in any directory. -In the below example, a file at `/collections/posts/post-a.md` will be output at `/files/post-a.json`, -and list files for this collection will be available at `/files/all/page-1.json`. +{{< diffcode >}} +```yml +collections: + - output_key: "posts" + inputs: + - path: "collections/posts" ++ glob: "**/*.{md}" +``` +{{< /diffcode >}} + +### Input > Meta + +Fixed metadata that should be added to each collection item sourced from this input. {{< diffcode >}} ```yml collections: - - path: "collections/posts" -+ output_key: "files" + - output_key: "posts" + inputs: + - path: "collections/posts" ++ meta: ++ source: "collections" ++ url: https://example.com ``` {{< /diffcode >}} -### Glob +### Output key -The glob expression Flatlake should use when finding files within this collection. Defaults to `**/*.{md}` to select all markdown files in any directory. +The folder to use when writing single and list files for this collection. + +In the below example, a file at `/collections/posts/post-a.md` will be output at `/files/post-a.json`, +and list files for this collection will be available at `/files/all/page-1.json`. {{< diffcode >}} ```yml collections: - path: "collections/posts" - output_key: "posts" -+ glob: "**/*.{md}" ++ output_key: "files" ``` {{< /diffcode >}} - ### Page size The page size to use when writing paginated endpoints within this collection.