bridgetown_directus 0.1.3 → 0.3.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: b86e165473c96ffa32fc96cf04ec0b5564169bcdd53866489c6f806f16235dfe
4
- data.tar.gz: c7ea854a2e0263589a31d467b164f061fe15399126a90de273b4c1b8a6366226
3
+ metadata.gz: 6834fa39c0868873782728053787ca9fbcbd0defb231b70621c8737ba6e996ee
4
+ data.tar.gz: 9dfb896e01a1a7e48d0a6db38b41c12a092195650ea8945083b417d34a76bda6
5
5
  SHA512:
6
- metadata.gz: 80a9bfad8a419d19159a2f0a6f7538afc142837a3baff3737bd9c1c5f127f039d7990432ace15dffea1cf3b474129a23335919e1c9e6fa975e4df653ecf83e67
7
- data.tar.gz: '098a9aeb10f146c6a30ee1a60d428390d52998e3bf438735b95f5de0b7fbd0afdfbb61f3982f816c1c12b43224b71afcda6f1783aaf8cb4a52a9b9b1ad545aab'
6
+ metadata.gz: e2394537291cd18e7887344e9d37c21973eafc19ec2b89dfc38d7c6796011ac8d22ca4777bacf052cf5f4e5cd2ba1dd26019a897cf0a0d26a901fec4aaafba5e
7
+ data.tar.gz: a72244a4b1bf68e1e4d8834c5c0548c4a2a3287267a040f3133b5b5cca2a67432948adbc8c0abaf2bb577d852023300aa7dd80c765c374e8c17f72771ed63625
@@ -0,0 +1,23 @@
1
+ name: CI
2
+
3
+ on:
4
+ push:
5
+ branches:
6
+ - main
7
+ pull_request:
8
+ workflow_dispatch:
9
+
10
+ permissions:
11
+ contents: read
12
+
13
+ jobs:
14
+ test:
15
+ runs-on: ubuntu-latest
16
+ steps:
17
+ - uses: actions/checkout@v4
18
+ - uses: ruby/setup-ruby@v1
19
+ with:
20
+ ruby-version: "3.4"
21
+ bundler-cache: true
22
+ - name: Run tests
23
+ run: bundle exec rake test
@@ -0,0 +1,20 @@
1
+ name: Release Please
2
+
3
+ on:
4
+ push:
5
+ branches:
6
+ - main
7
+ workflow_dispatch:
8
+
9
+ permissions:
10
+ contents: write
11
+ pull-requests: write
12
+
13
+ jobs:
14
+ release-please:
15
+ runs-on: ubuntu-latest
16
+ steps:
17
+ - uses: googleapis/release-please-action@v4
18
+ with:
19
+ config-file: .release-please-config.json
20
+ manifest-file: .release-please-manifest.json
@@ -0,0 +1,28 @@
1
+ name: Release
2
+
3
+ on:
4
+ push:
5
+ tags:
6
+ - "v*"
7
+ workflow_dispatch:
8
+
9
+ permissions:
10
+ contents: read
11
+
12
+ jobs:
13
+ publish:
14
+ runs-on: ubuntu-latest
15
+ steps:
16
+ - uses: actions/checkout@v4
17
+ - uses: ruby/setup-ruby@v1
18
+ with:
19
+ ruby-version: "3.4"
20
+ bundler-cache: true
21
+ - name: Run tests
22
+ run: bundle exec rake test
23
+ - name: Build gem
24
+ run: bundle exec rake build
25
+ - name: Push gem
26
+ env:
27
+ GEM_HOST_API_KEY: ${{ secrets.RUBYGEMS_API_KEY }}
28
+ run: gem push pkg/*.gem
data/.gitignore CHANGED
@@ -38,3 +38,6 @@ test/dest
38
38
  .bridgetown-webpack
39
39
 
40
40
  .env
41
+
42
+ # MacOS
43
+ .DS_Store
@@ -0,0 +1,10 @@
1
+ {
2
+ "packages": {
3
+ ".": {
4
+ "release-type": "ruby",
5
+ "package-name": "bridgetown_directus",
6
+ "changelog-path": "CHANGELOG.md",
7
+ "include-v-in-tag": true
8
+ }
9
+ }
10
+ }
@@ -0,0 +1,3 @@
1
+ {
2
+ ".": "0.3.0"
3
+ }
data/CHANGELOG.md CHANGED
@@ -5,10 +5,27 @@ All notable changes to this project will be documented in this file.
5
5
  The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
6
6
  and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
7
7
 
8
+ ## [0.3.0](https://github.com/Munkun-Estudio/bridgetown_directus/compare/bridgetown_directus-v0.2.0...bridgetown_directus/v0.3.0) (2026-01-27)
9
+
10
+
11
+ ### Features
12
+
13
+ * improve builder mapping and release automation ([b87c719](https://github.com/Munkun-Estudio/bridgetown_directus/commit/b87c719cfec175a86bc1f9388c308c496035d2cf))
14
+
8
15
  ## [Unreleased]
9
16
 
10
17
  - ...
11
18
 
19
+ ## [0.2.0] - 2025-04-16
20
+
21
+ - BREAKING: Simplified configuration—`resource_type` is no longer required. Use the Bridgetown collection name and layout instead.
22
+ - Automation now prompts for both Directus and Bridgetown collection names and sets up the initializer accordingly.
23
+ - Generated files are now flagged with `directus_generated: true` in front matter for safe cleanup.
24
+ - Only plugin-generated files (with this flag) are deleted during cleanup; user-authored files are preserved.
25
+ - Layouts for custom collections are now singular (e.g., `staff_member.erb`).
26
+ - README and example configuration updated for new conventions.
27
+ - Test suite updated for custom collections and file safety logic.
28
+
12
29
  ## [0.1.0] - 2024-09-27
13
30
 
14
31
  - First version
data/README.md CHANGED
@@ -2,16 +2,19 @@
2
2
 
3
3
  [![Gem Version](https://badge.fury.io/rb/bridgetown_directus.svg)](https://badge.fury.io/rb/bridgetown_directus)
4
4
 
5
- This Bridgetown plugin integrates with [Directus](https://directus.io/), which is among other things a [headless CMS](https://en.wikipedia.org/wiki/Headless_content_management_system). The plugin allows Bridgetown to pull content from a Directus API during the build process and generate static content in your site. It supports both single-language and multilingual content through Directus translations.
5
+ This Bridgetown plugin integrates with [Directus](https://directus.io/), a flexible headless CMS. The plugin allows Bridgetown to pull content from a Directus API during the build process and generate static content in your site. It supports both single-language and multilingual content through Directus translations.
6
6
 
7
7
  ## Features
8
8
 
9
- - Fetch **published posts** from Directus during the build process
10
- - Support for **multilingual content** through Directus translations
9
+ - Fetch content from **multiple Directus collections** during the build process
10
+ - Support for **flexible field mapping** and custom converters
11
+ - Support for **multilingual content** via Directus translations
12
+ - **Experimental**: Advanced **filtering, sorting, and pagination** options
13
+ - Simple configuration for any Bridgetown collection (posts, pages, or custom types)
11
14
 
12
15
  ## Installation
13
16
 
14
- Before installing the plugin make sure you have an [Auth Token](https://docs.directus.io/reference/authentication.html#access-tokens) in your Directus instance.
17
+ Before installing the plugin, make sure you have an [Auth Token](https://docs.directus.io/reference/authentication.html#access-tokens) in your Directus instance.
15
18
 
16
19
  ### Recommended Installation (Bridgetown Automation)
17
20
 
@@ -21,11 +24,10 @@ Before installing the plugin make sure you have an [Auth Token](https://docs.dir
21
24
  bin/bridgetown apply https://github.com/munkun-estudio/bridgetown_directus
22
25
  ```
23
26
 
24
- 2. The setup will guide you through:
25
- - Providing the Directus API URL and Auth Token
26
- - Specifying your content collection name
27
- - Enabling/disabling translations support
28
- - Configuring translatable fields (if translations enabled)
27
+ This will:
28
+ - Prompt for your Directus API URL, token, Directus collection name, and Bridgetown collection name
29
+ - Generate a minimal `config/initializers.rb`
30
+ - All further customization is done in Ruby, not YAML
29
31
 
30
32
  ### Manual Installation
31
33
 
@@ -35,140 +37,97 @@ Before installing the plugin make sure you have an [Auth Token](https://docs.dir
35
37
  bundle add "bridgetown_directus"
36
38
  ```
37
39
 
38
- 2. Run bundle install to install the gem.
39
- 3. Add the plugin configuration to your config/initializers.rb file:
40
-
41
- ```ruby
42
- init :"bridgetown_directus" do
43
- api_url "https://your-directus-instance.com"
44
- token ENV['DIRECTUS_AUTH_TOKEN'] || "your_token"
45
- collection config.directus["collection"]
46
- mappings config.directus["mappings"]
47
- end
48
- ```
49
-
50
- 4. Configure your bridgetown.config.yml:
51
-
52
- ```yaml
53
- directus:
54
- collection: "posts"
55
- mappings:
56
- title: "title" # Required field
57
- content: "body" # Required field
58
- slug: "slug" # Optional, will be auto-generated if not provided
59
- date: "date" # Optional, defaults to current date/time if not provided
60
- category: "category" # Optional
61
- excerpt: "excerpt" # Optional, defaults to content excerpt if not provided
62
- image: "image" # Optional, URL for the image associated with the post
63
- translations:
64
- enabled: false # Set to true for multilingual support
65
- fields: # Only required if translations are enabled
66
- - title
67
- - excerpt
68
- - body
69
- ```
40
+ 2. Run `bundle install` to install the gem.
41
+ 3. Create `config/initializers.rb` (see below for configuration).
70
42
 
71
43
  ## Configuration
72
44
 
73
- ### Basic Configuration
74
-
75
- You can configure the plugin either through environment variables or direct configuration:
76
-
77
- 1. Using environment variables:
45
+ ### Minimal Example
78
46
 
79
- ```bash
80
- export DIRECTUS_API_URL="https://your-directus-instance.com"
81
- export DIRECTUS_AUTH_TOKEN="your-token"
82
- ```
83
-
84
- 2. Or through bridgetown.config.yml as shown in the installation section.
85
-
86
- ### Translations Configuration
47
+ ```ruby
48
+ # config/initializers/bridgetown_directus.rb
49
+ init :bridgetown_directus do |directus|
50
+ directus.api_url = ENV["DIRECTUS_API_URL"] || "https://your-directus-instance.com"
51
+ directus.token = ENV["DIRECTUS_API_TOKEN"] || "your-token"
87
52
 
88
- To enable multilingual support:
89
-
90
- 1. In your bridgetown.config.yml, set translations.enabled to true:
91
-
92
- ```yaml
93
- directus:
94
- # ... other config ...
95
- translations:
96
- enabled: true
97
- fields:
98
- - title
99
- - excerpt
100
- - body
101
- ```
53
+ directus.register_collection(:posts) do |c|
54
+ c.endpoint = "posts"
55
+ c.layout = "post" # Use the singular layout for individual pages
56
+ # Minimal mapping (optional):
57
+ c.field :id, "id"
58
+ c.field :title, "title"
59
+ # To enable translations, uncomment and edit:
60
+ # c.enable_translations([:title, :content])
61
+ end
62
+ end
63
+ ```
102
64
 
103
- 2. Ensure your Directus collection has translations enabled and configured for the specified fields.
65
+ For custom collections, create a layout file at `src/_layouts/[singular].erb` (e.g., `staff_member.erb`) to control the page rendering.
104
66
 
105
- 3. The plugin will automatically:
67
+ **By default, all Directus fields will be written to the front matter of generated Markdown files.**
68
+ You only need to declare fields with `c.field` if you want to:
106
69
 
107
- - Generate posts for each available language
108
- - Create appropriate URLs based on locale
109
- - Handle fallback content if translations are missing
70
+ - Rename a field in the output
71
+ - Transform/convert a field value (e.g., format a date, generate a slug, etc.)
72
+ - Set a default value if a field is missing
110
73
 
111
- ## Usage
74
+ Mapped fields are merged into the full Directus payload, so you still retain access to original fields unless you override them.
112
75
 
113
- Once the plugin is installed and configured, it will fetch posts from your Directus instance during each build. These posts will be generated as in-memory resources, meaning they are not written to disk but are treated as normal posts by Bridgetown.
76
+ ### Environment Variables
114
77
 
115
- ### Directus Setup
78
+ - `DIRECTUS_API_URL` (required unless you set `directus.api_url` in config)
79
+ - `DIRECTUS_API_TOKEN` (required unless you set `directus.token` in config)
80
+ - `DIRECTUS_TOKEN` (legacy fallback; supported for backward compatibility)
116
81
 
117
- #### Basic Collection Setup
82
+ #### Example: Customizing a Field
118
83
 
119
- Create a collection in your Directus instance with these fields:
84
+ ```ruby
85
+ c.field :slug, "slug" do |value|
86
+ value || "staff_member-#{SecureRandom.hex(4)}"
87
+ end
88
+ ```
120
89
 
121
- - **title**: The title of the post (Text field)
122
- - **body**: The content of the post (Rich Text or Text field)
123
- - **slug**: Optional. A unique slug for the post (Text field)
124
- - **date**: Optional. The publish date (Datetime field)
125
- - **status**: Optional. The status of the post (Option field with values like "published", "draft", etc.)
126
- - **category**: Optional. The category for the post (Text field)
127
- - **excerpt**: Optional. A short excerpt (Text field)
128
- - **image**: Optional. An image associated with the post (File/Media field)
90
+ ### Translations
129
91
 
130
- Make sure the **status** field uses `"published"` for posts that you want to be visible on your site.
92
+ To enable translations for specific fields, add this inside your collection block:
131
93
 
132
- #### Image Permissions
94
+ ```ruby
95
+ c.enable_translations([:title, :content])
96
+ ```
133
97
 
134
- If your posts contain images, and you want to display them in your Bridgetown site, you'll need to ensure that the **directus_files** collection has the appropriate permissions for public access.
98
+ - You can list any field that exists in your Directus collection, even if it's not declared above with `c.field`.
99
+ - Only declare a field with `c.field` if you want to rename, transform, or set a default for it.
135
100
 
136
- 1. **Public Role Configuration:**
137
- - In Directus, navigate to **Settings** > **Roles & Permissions**.
138
- - Select the **Public** role (or create a custom role if needed).
139
- - Under the **Collections** tab, locate the **directus_files** collection.
140
- - Set the **read** permission to **enabled** so that the images can be accessed publicly.
101
+ ### File Generation & Cleanup
141
102
 
142
- 2. **Image Uploads and Management:**
143
- - When users upload images to posts, ensure that the images are associated with the **directus_files** collection.
144
- - By default, Directus will store image URLs, which the plugin can reference directly. Ensure that the **image** field or URL is added to the **body** field (or wherever applicable).
103
+ - **Generated files**: The plugin writes Markdown files to `src/_[bridgetown_collection]/` (e.g., `src/_staff_members/`).
104
+ - **Safety**: Only files with the `directus_generated: true` flag in their front matter are deleted during cleanup. User-authored files are never removed.
105
+ - **Posts**: If `date` or `published_at` is present, filenames are generated as `YYYY-MM-DD-slug.md` to preserve date-based permalinks.
145
106
 
146
- ### Fetching Posts
107
+ ### Debug Logging
147
108
 
148
- Posts are fetched from Directus during each build and treated as Bridgetown resources. These resources are available in your site just like regular posts, and you can access them through your templates or layouts.
109
+ Set `BRIDGETOWN_DIRECTUS_LOG=1` to print per-collection activity logs during builds.
149
110
 
150
- By default, only posts with a status of "published" are fetched from Directus.
111
+ ### Advanced Configuration
151
112
 
152
- ## TODO List
113
+ See the plugin source and inline documentation for advanced features such as:
153
114
 
154
- Here are features that are planned for future versions of the plugin:
115
+ - Multiple collections
116
+ - Custom layouts per collection
117
+ - Filtering, sorting, and pagination via `c.default_query` (**experimental**; not fully tested in production—see notes below)
118
+ - Selective field output
155
119
 
156
- - [ ] Support for Additional Content Types: Extend the plugin to handle other Directus collections and custom content types.
157
- - [ ] Custom Field Mapping via DSL: Implement a DSL for more advanced field mapping.
158
- - [ ] Asset Handling: Add functionality to download and manage images and other assets.
159
- - [ ] Caching & Incremental Builds: Implement caching to improve build performance when fetching content.
160
- - [ ] Draft Previews: Add support for previewing unpublished (draft) posts.
120
+ **Note:** Filtering, sorting, and pagination via `c.default_query` is experimental and not yet fully tested in real Bridgetown projects. Please report issues or contribute test cases if you use this feature!
161
121
 
162
- ## Testing
122
+ ### Migrating from 0.1.x
163
123
 
164
- Testing isn't fully set up yet, but contributions and improvements are welcome.
124
+ - **YAML config is no longer used.** All configuration is now in Ruby in `config/initializers.rb`.
125
+ - Field mapping, transformation, and translations are handled in the initializer.
126
+ - All Directus fields are output by default; use `c.field` for customization.
127
+ - **Upgrading?** The `resource_type` option is no longer required. Use the Bridgetown collection name and layout instead. See the [CHANGELOG](CHANGELOG.md) for details.
165
128
 
166
- ## Contributing
129
+ ---
167
130
 
168
- We welcome contributions! To contribute:
131
+ For more details and advanced usage, see the [plugin README](https://github.com/Munkun-Estudio/bridgetown_directus).
169
132
 
170
- 1. Fork the repository
171
- 2. Create a new branch (git checkout -b feature-branch)
172
- 3. Make your changes
173
- 4. Push to the branch (git push origin feature-branch)
174
- 5. Open a Pull Request
133
+ See [CHANGELOG.md](CHANGELOG.md) for upgrade notes and detailed changes.
data/Rakefile CHANGED
@@ -4,7 +4,7 @@ require "rake/testtask"
4
4
  Rake::TestTask.new(:test) do |t|
5
5
  t.libs << "test"
6
6
  t.libs << "lib"
7
- t.test_files = FileList["test/**/test_*.rb"]
7
+ t.test_files = FileList["test/**/*_test.rb"]
8
8
  t.warning = false
9
9
  end
10
10
 
@@ -2,61 +2,63 @@ say_status :directus, "Installing the bridgetown_directus plugin..."
2
2
 
3
3
  # Prompt the user for Directus API URL and Auth Token
4
4
  api_url = ask("What's your Directus instance URL? (Example: https://your-instance.example.com)")
5
- auth_token = ask("What's your Directus API auth token? (Leave blank to use ENV['DIRECTUS_AUTH_TOKEN'])")
6
- collection = ask("What's the name of the collection (Directus Model)? (Example: posts)")
7
-
8
- # Ask if translations should be enabled with a default of 'n'
9
- translations_enabled_input = ask("Do you want to enable translations? (y/n) default:", :yellow, default: "n")
10
- translations_enabled = translations_enabled_input.strip.downcase.start_with?("y")
11
-
12
- # Prepare the translations YAML block based on the user’s response
13
- translations_yaml = if translations_enabled
14
- translatable_fields_input = ask("List the translatable fields separated by commas (e.g., title, excerpt, content)")
15
- translatable_fields = translatable_fields_input.split(',').map(&:strip)
16
-
17
- " translations:\n enabled: true\n fields:\n#{translatable_fields.map { |field| " - #{field}" }.join("\n")}"
18
- else
19
- " translations:\n enabled: false"
20
- end
5
+ auth_token = ask("What's your Directus API auth token? (Leave blank to use ENV['DIRECTUS_API_TOKEN'])")
6
+ directus_collection = ask("What's the Directus collection name (API endpoint/model)? (Example: posts)")
7
+ bridgetown_collection = ask("What's the Bridgetown collection name (used for folder and resource)? (Example: posts)")
21
8
 
22
9
  # Add the bridgetown_directus gem
23
10
  add_gem "bridgetown_directus"
24
11
 
25
- # Add Directus configuration to config/initializers.rb
26
- add_initializer :bridgetown_directus do
12
+ # Add minimal Directus configuration to config/initializers.rb in the idiomatic Bridgetown plugin style
13
+ add_initializer :bridgetown_directus do |directus|
27
14
  <<~RUBY
28
- do
29
- api_url "#{api_url}"
30
- token "#{auth_token.present? ? auth_token : "<%= ENV['DIRECTUS_AUTH_TOKEN'] %>"}"
31
- collection config.directus["collection"]
32
- mappings config.directus["mappings"]
33
- end
34
- RUBY
35
- end
15
+ # This block was generated by bridgetown_directus automation.
16
+ # All Directus configuration is now handled here (not in YAML).
17
+ # Set DIRECTUS_API_URL and DIRECTUS_API_TOKEN in your .env or shell environment.
18
+ #
19
+ # By default, ALL fields from Directus will be written to the front matter of generated Markdown files.
20
+ # You only need to declare fields here if you want to:
21
+ # - Rename a field in the output
22
+ # - Transform/convert a field value (e.g., format a date, generate a slug, etc.)
23
+ # - Set a default value if a field is missing
24
+ #
25
+ # Example: To customize or transform fields, use the c.field declaration:
26
+ # # require "securerandom" # Uncomment if you use SecureRandom in your mapping
27
+ # c.field :slug, "slug" do |value|
28
+ # value || "post-#{SecureRandom.hex(4)}"
29
+ # end
30
+ #
31
+ # ---
32
+ # TRANSLATIONS:
33
+ # To enable translations for specific fields, add this line inside your collection block:
34
+ # c.enable_translations([:title, :content])
35
+ # You can list any field that exists in your Directus collection, even if it's not declared above with c.field.
36
+ # Declaring a field with c.field is only required if you want to rename, transform, or set a default for it.
37
+ # ---
38
+
39
+ directus.api_url = ENV["DIRECTUS_API_URL"] || "#{api_url}"
40
+ directus.token = ENV["DIRECTUS_API_TOKEN"] || "#{auth_token}"
36
41
 
37
- # Append the configuration to bridgetown.config.yml
38
- append_to_file "bridgetown.config.yml" do
39
- <<~YAML
40
-
41
- directus:
42
- collection: "#{collection}"
43
- mappings:
44
- title: "title" # Required field
45
- content: "body" # Required field
46
- slug: "slug" # Optional, will be auto-generated if not provided
47
- date: "date" # Optional, defaults to the current date/time if not provided
48
- category: "category" # Optional
49
- excerpt: "excerpt" # Optional, defaults to content excerpt if not provided
50
- image: "image" # Optional, URL for the image associated with the post
51
- #{translations_yaml}
52
- YAML
42
+ directus.register_collection(:#{bridgetown_collection}) do |c|
43
+ c.endpoint = "#{directus_collection}"
44
+ c.layout = "#{bridgetown_collection.to_s.singularize}"
45
+ # Minimal mapping (optional):
46
+ c.field :id, "id"
47
+ c.field :title, "title"
48
+ # Add more c.field declarations above as needed for custom logic.
49
+ # To enable translations, uncomment and edit the following line:
50
+ # c.enable_translations([:title, :content])
51
+ end
52
+ RUBY
53
53
  end
54
54
 
55
55
  say_status :success, "Bridgetown Directus plugin has been installed!", :green
56
- say_status :info, "Add your posts to Directus and they will be automatically imported when you build your site.", :yellow
57
- if translations_enabled
58
- say_status :info, "Translations are enabled. Make sure your Directus collection has translations configured.", :yellow
56
+ say_status :directus, "Check config/initializers.rb for your Directus setup."
57
+ say_status :directus, "Check bridgetown.config.yml for your collection setup."
58
+
59
+ # Only remind the user to create a layout if it's a custom collection (not 'posts' or 'pages')
60
+ if !%w[posts pages].include?(bridgetown_collection.to_s)
61
+ say_status :directus, "Don't forget to create a layout file at src/_layouts/#{bridgetown_collection.to_s.singularize}.erb for your custom collection pages!"
59
62
  end
60
- say_status :directus, "Check config/initializers.rb for your Directus setup and config.bridgetown.yml to adjust fields mappings if necessary."
61
- say_status :directus, "For usage help visit:"
62
- say_status :directus, "https://github.com/Munkun-Estudio/bridgetown_directus/blob/main/README.md"
63
+
64
+ say_status :directus, "For advanced usage and field customization, see the README: https://github.com/Munkun-Estudio/bridgetown_directus"
@@ -24,7 +24,7 @@ Gem::Specification.new do |spec|
24
24
 
25
25
  spec.required_ruby_version = ">= 2.7.0"
26
26
 
27
- spec.add_dependency "bridgetown", ">= 1.2.0", "< 2.0"
27
+ spec.add_dependency "bridgetown", ">= 2.0.0.beta4", "< 3.0"
28
28
  spec.add_dependency "faraday", "~> 2.12"
29
29
 
30
30
  spec.add_development_dependency "bundler", "~> 2.0"
@@ -32,7 +32,7 @@ Gem::Specification.new do |spec|
32
32
  spec.add_development_dependency "rubocop-bridgetown", "~> 0.3"
33
33
  spec.add_development_dependency "shoulda", "~> 3.0"
34
34
  spec.add_development_dependency "minitest", "~> 5.0"
35
- spec.add_development_dependency "minitest-profile", "~> 0.5"
35
+ spec.add_development_dependency "minitest-profile", "~> 0.0.2"
36
36
  spec.add_development_dependency "minitest-reporters", "~> 1.0"
37
37
  spec.add_development_dependency "webmock", "~> 3.0"
38
38
  end
@@ -0,0 +1,24 @@
1
+ # Example Bridgetown configuration file for the enhanced Directus plugin
2
+
3
+ # Site settings
4
+ title: My Bridgetown Site with Directus
5
+ email: your-email@example.com
6
+ description: >-
7
+ A Bridgetown site powered by Directus headless CMS
8
+ baseurl: ""
9
+ url: ""
10
+
11
+ # Collections
12
+ collections:
13
+ posts:
14
+ output: true
15
+ permalink: /blog/:slug/
16
+ source: _posts
17
+ future: true
18
+ staff_members:
19
+ output: true
20
+ permalink: /staff_members/:slug/
21
+ source: _staff_members
22
+ sort_field: 'created_at'
23
+ sort_reverse: false
24
+
@@ -0,0 +1,34 @@
1
+ # frozen_string_literal: true
2
+
3
+ # Example Bridgetown Directus plugin initializer for v2+
4
+ #
5
+ # All Directus configuration is now handled here, NOT in bridgetown.config.yml.
6
+ # Use ENV variables for secrets and API credentials.
7
+
8
+ require "securerandom"
9
+ require "time"
10
+
11
+ init :bridgetown_directus do |directus|
12
+ # Set API credentials from environment variables
13
+ directus.api_url = ENV["DIRECTUS_API_URL"] || "https://your-directus-instance.com"
14
+ directus.token = ENV["DIRECTUS_API_TOKEN"] || "your-token-here"
15
+
16
+ # Example custom collection: staff_members
17
+ directus.register_collection(:staff_members) do |c|
18
+ c.endpoint = "staff_members"
19
+ c.layout = "staff_member"
20
+ c.field :id, "id"
21
+ c.field :title, "title"
22
+ # To enable translations, uncomment and edit:
23
+ # c.enable_translations([:title, :content])
24
+ # Add more fields as needed
25
+ end
26
+
27
+ # Example for posts (if needed)
28
+ directus.register_collection(:posts) do |c|
29
+ c.endpoint = "articles"
30
+ c.layout = "post"
31
+ c.field :title, "title"
32
+ c.field :content, "body"
33
+ end
34
+ end