You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
@@ -35,6 +47,10 @@ class TestExternalSources < BridgetownFeatureTest
35
47
assert_file_contains"<head><title>Marked Down</title></head><body><h1 id=\"marked-down\">Marked Down</h1>\n\n<p>This is <strong>Markdown</strong> text. It’s as easy as 1, 2, 3!</p>\n",
Copy file name to clipboardExpand all lines: bridgetown-website/src/_docs/content/external-sources.md
+15-1Lines changed: 15 additions & 1 deletion
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -5,7 +5,7 @@ top_section: Writing Content
5
5
category: resources
6
6
---
7
7
8
-
There are times you may want Bridgetown to include resources you've created which live outside of your site project folder hierarchy. In particular, you may have a folder(s) of Markdown files already saved somewhere and would like those to be included in your site build.
8
+
There are times you may want Bridgetown to include resources you've created which live outside of your site project folder hierarchy. In particular, you may have a folder(s) of Markdown files already saved somewhere and would like those to be included in your site build.
9
9
10
10
To add a new content source to your project, use the `external_sources` plugin initializer in your `config/initializers.rb` file:
11
11
@@ -43,6 +43,20 @@ init :external_sources do
43
43
end
44
44
```
45
45
46
+
If you want to include only certain files from an external source, you can do so in a `filters` block. For example, here is how to add a filter to external sources to the `pages` collection, so as to include only files and folders whose name does not start with an underscore:
47
+
48
+
```ruby
49
+
init :external_sourcesdo
50
+
contents do
51
+
pages "path/to/folder"
52
+
end
53
+
54
+
filters do
55
+
pages ->(name, path) { !name.start_with?("_") }
56
+
end
57
+
end
58
+
```
59
+
46
60
## Loading Markdown Content from Other Applications
47
61
48
62
Unlike with standard Bridgetown content files within `src` where you must use front matter if you wish Markdown files get processed as resources instead of static files, Markdown files in external sources don't require any front matter. However, in order to ensure those files are rendered with a layout, you'll need to set up [front matter defaults](/docs/content/front-matter-defaults) (as shown in the example above).
0 commit comments