jekyll-notion 1.0.0 → 1.1.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 +4 -4
- data/README.md +16 -1
- data/lib/jekyll-notion/abstract_generator.rb +15 -0
- data/lib/jekyll-notion/collection_generator.rb +5 -7
- data/lib/jekyll-notion/data_generator.rb +17 -0
- data/lib/jekyll-notion/generator.rb +13 -11
- data/lib/jekyll-notion/generator_factory.rb +13 -0
- data/lib/jekyll-notion/notion_database.rb +4 -0
- data/lib/jekyll-notion/version.rb +1 -1
- data/lib/jekyll-notion.rb +3 -0
- metadata +5 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 043b3ae753a651d756c95dc6372af86589106030dd3d41d8b886ccc95c5d5d7a
|
4
|
+
data.tar.gz: 5a6bf3508185e27978836cd1158ef70a080d53be183c642d7948015f6d7de215
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 74e147fe3f6f91a88bafb24f273284bb71d42f39f207c48f85577229aebb6ceb6de6cbe331b48e6f99afb6191466e9f27d436fb45bc710104a0ac3a80e016c6c
|
7
|
+
data.tar.gz: 2257337e331db87e4594e5117739ea7e1082739b3f497a4c63bba7f2dc79d2c173a484fc574ea20eb40d8650c14c84a607c9e17cef9f49174ff97bf79edab73e
|
data/README.md
CHANGED
@@ -40,6 +40,8 @@ notion:
|
|
40
40
|
id: e42383cd-4975-4897-b967-ce453760499f
|
41
41
|
```
|
42
42
|
|
43
|
+
After running `jekyll build` (or `serve`) command, the `posts` collection is loaded with pages of the notion database specified in the configuration.
|
44
|
+
|
43
45
|
### Mutiple dabatases
|
44
46
|
|
45
47
|
You can also define multiple databases as follows.
|
@@ -58,7 +60,20 @@ notion:
|
|
58
60
|
collection: films
|
59
61
|
```
|
60
62
|
|
61
|
-
|
63
|
+
In this example, the notion database `b0e688e1-99af-4295-ae80-b67eb52f2e2f` pages are mapped into the posts collection. `recipes` and `films` will contain the database pages `2190450d-4cb3-4739-a5c8-340c4110fe21` and `e42383cd-4975-4897-b967-ce453760499f`, respectively.
|
64
|
+
|
65
|
+
### data
|
66
|
+
|
67
|
+
Instead of storing notion pages in a collection, you can also map to the data object. Declare the data property as follows.
|
68
|
+
|
69
|
+
```yml
|
70
|
+
notion:
|
71
|
+
database:
|
72
|
+
id: e42383cd-4975-4897-b967-ce453760499f
|
73
|
+
data: films
|
74
|
+
```
|
75
|
+
|
76
|
+
Unlike collections, only the properties of the notion page are assigned to the each data item. The body of the notion page is omitted.
|
62
77
|
|
63
78
|
### Database options
|
64
79
|
|
@@ -0,0 +1,15 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module JekyllNotion
|
4
|
+
class AbstractGenerator
|
5
|
+
def initialize(db:, site:, plugin:)
|
6
|
+
@db = db
|
7
|
+
@site = site
|
8
|
+
@plugin = plugin
|
9
|
+
end
|
10
|
+
|
11
|
+
def generate
|
12
|
+
raise "Do not use the AbstractGenerator class directly. Implement the generate method in a subclass."
|
13
|
+
end
|
14
|
+
end
|
15
|
+
end
|
@@ -1,10 +1,7 @@
|
|
1
|
-
|
2
|
-
class CollectionGenerator
|
3
|
-
def initialize(db:, site:)
|
4
|
-
@db = db
|
5
|
-
@site = site
|
6
|
-
end
|
1
|
+
# frozen_string_literal: true
|
7
2
|
|
3
|
+
module JekyllNotion
|
4
|
+
class CollectionGenerator < AbstractGenerator
|
8
5
|
def generate
|
9
6
|
@db.pages.each do |page|
|
10
7
|
next if file_exists?(make_path(page))
|
@@ -12,7 +9,8 @@ module JekyllNotion
|
|
12
9
|
collection.docs << make_doc(page)
|
13
10
|
log_new_page(page)
|
14
11
|
end
|
15
|
-
collection
|
12
|
+
# Caching current collection
|
13
|
+
@plugin.collections[@db.collection] = collection
|
16
14
|
end
|
17
15
|
|
18
16
|
def collection
|
@@ -0,0 +1,17 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module JekyllNotion
|
4
|
+
class DataGenerator < AbstractGenerator
|
5
|
+
def generate
|
6
|
+
@site.data[@db.data] = data
|
7
|
+
# Caching current data
|
8
|
+
@plugin.data[@db.data] = data
|
9
|
+
end
|
10
|
+
|
11
|
+
private
|
12
|
+
|
13
|
+
def data
|
14
|
+
@data ||= @db.pages.map(&:props)
|
15
|
+
end
|
16
|
+
end
|
17
|
+
end
|
@@ -16,17 +16,6 @@ module JekyllNotion
|
|
16
16
|
end
|
17
17
|
end
|
18
18
|
|
19
|
-
protected
|
20
|
-
|
21
|
-
def read_notion_database
|
22
|
-
databases.each do |db_config|
|
23
|
-
db = NotionDatabase.new(:config => db_config)
|
24
|
-
new_collection = CollectionGenerator.new(:db => db, :site => @site).generate
|
25
|
-
# Caching current collection
|
26
|
-
collections[db.collection] = new_collection
|
27
|
-
end
|
28
|
-
end
|
29
|
-
|
30
19
|
def databases
|
31
20
|
config["databases"] || [config["database"]]
|
32
21
|
end
|
@@ -35,6 +24,19 @@ module JekyllNotion
|
|
35
24
|
@collections ||= {}
|
36
25
|
end
|
37
26
|
|
27
|
+
def data
|
28
|
+
@data ||= {}
|
29
|
+
end
|
30
|
+
|
31
|
+
protected
|
32
|
+
|
33
|
+
def read_notion_database
|
34
|
+
databases.each do |db_config|
|
35
|
+
db = NotionDatabase.new(:config => db_config)
|
36
|
+
GeneratorFactory.for(:db => db, :site => @site, :plugin => self).generate
|
37
|
+
end
|
38
|
+
end
|
39
|
+
|
38
40
|
def config
|
39
41
|
@config ||= @site.config["notion"] || {}
|
40
42
|
end
|
@@ -0,0 +1,13 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module JekyllNotion
|
4
|
+
class GeneratorFactory
|
5
|
+
def self.for(db:, site:, plugin:)
|
6
|
+
if db.data.nil?
|
7
|
+
CollectionGenerator.new(:db => db, :site => site, :plugin => plugin)
|
8
|
+
else
|
9
|
+
DataGenerator.new(:db => db, :site => site, :plugin => plugin)
|
10
|
+
end
|
11
|
+
end
|
12
|
+
end
|
13
|
+
end
|
data/lib/jekyll-notion.rb
CHANGED
@@ -13,7 +13,10 @@ Notion.configure do |config|
|
|
13
13
|
end
|
14
14
|
|
15
15
|
module JekyllNotion
|
16
|
+
autoload :GeneratorFactory, "jekyll-notion/generator_factory"
|
17
|
+
autoload :AbstractGenerator, "jekyll-notion/abstract_generator"
|
16
18
|
autoload :CollectionGenerator, "jekyll-notion/collection_generator"
|
19
|
+
autoload :DataGenerator, "jekyll-notion/data_generator"
|
17
20
|
autoload :DocumentWithoutAFile, "jekyll-notion/document_without_a_file"
|
18
21
|
autoload :NotionDatabase, "jekyll-notion/notion_database"
|
19
22
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: jekyll-notion
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.
|
4
|
+
version: 1.1.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Enrique Arias
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2022-02-
|
11
|
+
date: 2022-02-26 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: jekyll
|
@@ -110,9 +110,12 @@ extra_rdoc_files:
|
|
110
110
|
files:
|
111
111
|
- README.md
|
112
112
|
- lib/jekyll-notion.rb
|
113
|
+
- lib/jekyll-notion/abstract_generator.rb
|
113
114
|
- lib/jekyll-notion/collection_generator.rb
|
115
|
+
- lib/jekyll-notion/data_generator.rb
|
114
116
|
- lib/jekyll-notion/document_without_a_file.rb
|
115
117
|
- lib/jekyll-notion/generator.rb
|
118
|
+
- lib/jekyll-notion/generator_factory.rb
|
116
119
|
- lib/jekyll-notion/notion_database.rb
|
117
120
|
- lib/jekyll-notion/version.rb
|
118
121
|
homepage: https://github.com/emoriarty/jekyll-notion
|