jekyll-notion 1.1.0 → 2.0.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 043b3ae753a651d756c95dc6372af86589106030dd3d41d8b886ccc95c5d5d7a
4
- data.tar.gz: 5a6bf3508185e27978836cd1158ef70a080d53be183c642d7948015f6d7de215
3
+ metadata.gz: 79520a9f4d598b024d2934fd68140f0f34775e2611ff601b1352ba60f67e9dd3
4
+ data.tar.gz: bcd325965c4eec49a498fe99c2101fa238f6c67587cb13723927abe0b8e83c1f
5
5
  SHA512:
6
- metadata.gz: 74e147fe3f6f91a88bafb24f273284bb71d42f39f207c48f85577229aebb6ceb6de6cbe331b48e6f99afb6191466e9f27d436fb45bc710104a0ac3a80e016c6c
7
- data.tar.gz: 2257337e331db87e4594e5117739ea7e1082739b3f497a4c63bba7f2dc79d2c173a484fc574ea20eb40d8650c14c84a607c9e17cef9f49174ff97bf79edab73e
6
+ metadata.gz: 17ca3742b0b48a22dd7cca185c25f9368565e7af35ccdc3e9add259faa20aa101e908aac961363c1ecf2b0d2f6822153e6b7d4a6bc53a3dc1d49697cb1199bc1
7
+ data.tar.gz: 0a46f5e5ce29f09bc1966ac4199a080da5eea58cedcaa37062cf5fd3bc77b35a8ad45bbf1067d01d32ca9094e53e36e21223187b8c3d94970ef092eb09ca56d0
data/README.md CHANGED
@@ -1,6 +1,6 @@
1
1
  # jekyll-notion
2
2
 
3
- Import notion pages to a jekyll collection.
3
+ Import notion pages to a jekyll collection or data.
4
4
 
5
5
  ## Installation
6
6
 
@@ -22,29 +22,29 @@ plugins:
22
22
  - jekyll-notion
23
23
  ```
24
24
 
25
- ## Setup
25
+ ## Usage
26
26
 
27
27
  Before using the gem create an integration and generate a secret token. Check [notion getting started guide](https://developers.notion.com/docs/getting-started) to learn more.
28
28
 
29
- Export the notion secret token in an environment variable named `NOTION_TOKEN`.
29
+ Once you have youe secret, export it in an environment variable named `NOTION_TOKEN`.
30
30
 
31
31
  ```bash
32
32
  $ export NOTION_TOKEN=<secret_...>
33
33
  ```
34
34
 
35
- Once your notion database has been shared, specify the database `id` in your `_config.yml` as follows.
35
+ ### Databases
36
+
37
+ Once your [notion database](https://www.notion.so/help/intro-to-databases) has been shared, specify the database `id` in your `_config.yml` as follows.
36
38
 
37
39
  ```yml
38
40
  notion:
39
41
  database:
40
- id: e42383cd-4975-4897-b967-ce453760499f
42
+ id: 5cfed4de3bdc4f43ae8ba653a7a2219b
41
43
  ```
42
44
 
43
- After running `jekyll build` (or `serve`) command, the `posts` collection is loaded with pages of the notion database specified in the configuration.
44
-
45
- ### Mutiple dabatases
45
+ By default, the notion pages contained in the database will be loaded into the `posts` collection.
46
46
 
47
- You can also define multiple databases as follows.
47
+ You can also define __multiple databases__ as follows.
48
48
 
49
49
  ```yml
50
50
  collections:
@@ -53,29 +53,16 @@ collections:
53
53
 
54
54
  notion:
55
55
  databases:
56
- - id: b0e688e1-99af-4295-ae80-b67eb52f2e2f
57
- - id: 2190450d-4cb3-4739-a5c8-340c4110fe21
56
+ - id: b0e688e199af4295ae80b67eb52f2e2f
57
+ - id: 2190450d4cb34739a5c8340c4110fe21
58
58
  collection: recipes
59
- - id: e42383cd-4975-4897-b967-ce453760499f
59
+ - id: e42383cd49754897b967ce453760499f
60
60
  collection: films
61
61
  ```
62
62
 
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.
63
+ After running `jekyll build` (or `serve`) command, the `posts`, `recipes` and `films` collections will be loaded with pages from the notion databases.
77
64
 
78
- ### Database options
65
+ #### Database options
79
66
 
80
67
  Each dabatase support the following options.
81
68
 
@@ -87,12 +74,72 @@ Each dabatase support the following options.
87
74
  ```yml
88
75
  notion:
89
76
  database:
90
- id: e42383cd-4975-4897-b967-ce453760499f
77
+ id: e42383cd49754897b967ce453760499f
91
78
  collection: posts
92
79
  filter: { "property": "Published", "checkbox": { "equals": true } }
93
80
  sort: { "property": "Last ordered", "direction": "ascending" }
94
81
  ```
95
82
 
83
+ ### Pages
84
+
85
+ Individual Notion pages can also be loaded into Jekyll. Just define the `page` property as follows.
86
+
87
+ ```yml
88
+ notion:
89
+ page:
90
+ id: 5cfed4de3bdc4f43ae8ba653a7a2219b
91
+ ```
92
+
93
+ As databases, we can set up multiple pages.
94
+
95
+ ```yaml
96
+ notion:
97
+ pages:
98
+ - id: e42383cd49754897b967ce453760499f
99
+ - id: b0e688e199af4295ae80b67eb52f2e2f
100
+ - id: 2190450d4cb34739a5c8340c4110fe21
101
+ ```
102
+
103
+ The filename of the generated page is the notion page title. Check [below](#page-filename) for more info.
104
+
105
+ All properties assigned to a notion page will be interpreted by jekyll as front matter. For example, if the [permalink](https://jekyllrb.com/docs/permalinks/#front-matter) property is set to `/about/` in the notion page, jekyll will use it to create the corresponding path at the output directory at `/about/index.html`.
106
+
107
+ ### Data
108
+
109
+ Instead of storing the notion pages in a collection or in the pages list, you can assign them to the data object.Just declare the `data` property next to the page or database id.
110
+
111
+ ```yml
112
+ notion:
113
+ databases:
114
+ - id: b0e688e199af4295ae80b67eb52f2e2f
115
+ - id: e42383cd49754897b967ce453760499f
116
+ data: films
117
+ pages:
118
+ - id: e42383cd49754897b967ce453760499f
119
+ - id: b0e688e199af4295ae80b67eb52f2e2f
120
+ data: about
121
+ ```
122
+
123
+ Page properties and body of the notion page are stored as a hash object.
124
+
125
+ In the previous example, data objects can be accesses as follows.
126
+
127
+ ```html
128
+ <ul>
129
+ {% for film in site.data.films %}
130
+ <li>{{ film.title }}</li>
131
+ {% endfor %}
132
+ </ul>
133
+ ```
134
+
135
+ Notice, the page body is stored in the key `content`.
136
+
137
+ ```html
138
+ {{ site.data.about.content }}
139
+ ```
140
+
141
+ The rest of properties are mapped as expected. For more info go to [notion properties](#notion-properties).
142
+
96
143
  ### Watch
97
144
 
98
145
  By default, databases are only requested during the first build. Subsequent builds use the results from the cache.
@@ -103,7 +150,7 @@ Set `fetch_on_watch` to true to allow request on each rebuild.
103
150
  notion:
104
151
  fetch_on_watch: true
105
152
  database:
106
- id: e42383cd-4975-4897-b967-ce453760499f
153
+ id: e42383cd49754897b967ce453760499f
107
154
  ```
108
155
 
109
156
  And that's all. Each page in the notion database will be included in the selected collection.
@@ -131,12 +178,12 @@ Please, refer to the [notion_to_md](https://github.com/emoriarty/notion_to_md/)
131
178
 
132
179
  ## Page filename
133
180
 
134
- There are two kinds of collections: posts and others.
181
+ There are two kinds of documents in Jekyll: posts and others.
135
182
 
136
- When the collection is posts, the filename format contains the `created_time` property plus the page title as specified in [jekyll docs](https://jekyllrb.com/docs/posts/#creating-posts).
183
+ When the document is a post, the filename format contains the `created_time` property plus the page title as specified in [jekyll docs](https://jekyllrb.com/docs/posts/#creating-posts).
137
184
 
138
185
  ```
139
186
  YEAR-MONTH-DAY-title.MARKUP
140
187
  ```
141
188
 
142
- Any other collection, the filename is the page title.
189
+ The filename for any other document is the page title.
@@ -0,0 +1,41 @@
1
+ # frozen_string_literal: true
2
+
3
+ module JekyllNotion
4
+ class AbstractNotionResource
5
+ def initialize(config:)
6
+ @notion = Notion::Client.new
7
+ @config = config
8
+ end
9
+
10
+ def config
11
+ @config || {}
12
+ end
13
+
14
+ def id
15
+ config["id"]
16
+ end
17
+
18
+ def fetch
19
+ raise "Do not use the AbstractNotionResource class. Implement the fetch method in a subclass."
20
+ end
21
+
22
+ def collection_name
23
+ raise "Do not use the AbstractGenerator class. Implement the collection_name method in a subclass."
24
+ end
25
+
26
+ def data_name
27
+ raise "Do not use the AbstractGenerator class. Implement the data_name method in a subclass."
28
+ end
29
+
30
+ protected
31
+
32
+ def id?
33
+ if id.nil? || id.empty?
34
+ Jekyll.logger.warn("Jekyll Notion:",
35
+ "Database or page id is not provided. Cannot read from Notion.")
36
+ return false
37
+ end
38
+ true
39
+ end
40
+ end
41
+ end
@@ -0,0 +1,14 @@
1
+ # frozen_string_literal: true
2
+
3
+ module JekyllNotion
4
+ class DatabaseFactory
5
+ def self.for(notion_resource:, site:, plugin:)
6
+ if notion_resource.data_name.nil?
7
+ CollectionGenerator.new(:notion_resource => notion_resource, :site => site,
8
+ :plugin => plugin)
9
+ else
10
+ DataGenerator.new(:notion_resource => notion_resource, :site => site, :plugin => plugin)
11
+ end
12
+ end
13
+ end
14
+ end
@@ -0,0 +1,14 @@
1
+ # frozen_string_literal: true
2
+
3
+ module JekyllNotion
4
+ class PageFactory
5
+ def self.for(notion_resource:, site:, plugin:)
6
+ if notion_resource.data_name.nil?
7
+ PageGenerator.new(:notion_resource => notion_resource, :site => site,
8
+ :plugin => plugin)
9
+ else
10
+ DataGenerator.new(:notion_resource => notion_resource, :site => site, :plugin => plugin)
11
+ end
12
+ end
13
+ end
14
+ end
@@ -9,17 +9,24 @@ module JekyllNotion
9
9
 
10
10
  return unless notion_token? && config?
11
11
 
12
- if fetch_on_watch? || collections.empty?
13
- read_notion_database
12
+ if fetch_on_watch? || cache_empty?
13
+ read_notion_databases
14
+ read_notion_pages
14
15
  else
15
16
  collections.each_pair { |key, val| @site.collections[key] = val }
17
+ data.each_pair { |key, val| @site.data[key] = val }
18
+ pages.each { |page| @site.pages << page }
16
19
  end
17
20
  end
18
21
 
19
- def databases
22
+ def config_databases
20
23
  config["databases"] || [config["database"]]
21
24
  end
22
25
 
26
+ def config_pages
27
+ config["pages"] || [config["page"]]
28
+ end
29
+
23
30
  def collections
24
31
  @collections ||= {}
25
32
  end
@@ -28,12 +35,27 @@ module JekyllNotion
28
35
  @data ||= {}
29
36
  end
30
37
 
38
+ def pages
39
+ @pages ||= []
40
+ end
41
+
31
42
  protected
32
43
 
33
- def read_notion_database
34
- databases.each do |db_config|
44
+ def cache_empty?
45
+ collections.empty? && pages.empty? && data.empty?
46
+ end
47
+
48
+ def read_notion_databases
49
+ config_databases.each do |db_config|
35
50
  db = NotionDatabase.new(:config => db_config)
36
- GeneratorFactory.for(:db => db, :site => @site, :plugin => self).generate
51
+ DatabaseFactory.for(:notion_resource => db, :site => @site, :plugin => self).generate
52
+ end
53
+ end
54
+
55
+ def read_notion_pages
56
+ config_pages.each do |page_config|
57
+ page = NotionPage.new(:config => page_config)
58
+ PageFactory.for(:notion_resource => page, :site => @site, :plugin => self).generate
37
59
  end
38
60
  end
39
61
 
@@ -0,0 +1,15 @@
1
+ # frozen_string_literal: true
2
+
3
+ module JekyllNotion
4
+ class AbstractGenerator
5
+ def initialize(notion_resource:, site:, plugin:)
6
+ @notion_resource = notion_resource
7
+ @site = site
8
+ @plugin = plugin
9
+ end
10
+
11
+ def generate
12
+ raise "Do not use the AbstractGenerator class. Implement the generate method in a subclass."
13
+ end
14
+ end
15
+ end
@@ -3,18 +3,18 @@
3
3
  module JekyllNotion
4
4
  class CollectionGenerator < AbstractGenerator
5
5
  def generate
6
- @db.pages.each do |page|
6
+ @notion_resource.fetch.each do |page|
7
7
  next if file_exists?(make_path(page))
8
8
 
9
9
  collection.docs << make_doc(page)
10
10
  log_new_page(page)
11
11
  end
12
12
  # Caching current collection
13
- @plugin.collections[@db.collection] = collection
13
+ @plugin.collections[@notion_resource.collection_name] = collection
14
14
  end
15
15
 
16
16
  def collection
17
- @site.collections[@db.collection]
17
+ @site.collections[@notion_resource.collection_name]
18
18
  end
19
19
 
20
20
  private
@@ -35,11 +35,11 @@ module JekyllNotion
35
35
  end
36
36
 
37
37
  def make_path(page)
38
- "_#{@db.collection}/#{make_filename(page)}"
38
+ "_#{@notion_resource.collection_name}/#{make_filename(page)}"
39
39
  end
40
40
 
41
41
  def make_filename(page)
42
- if @db.collection == "posts"
42
+ if @notion_resource.collection_name == "posts"
43
43
  "#{page.created_time.to_date}-#{Jekyll::Utils.slugify(page.title,
44
44
  :mode => "latin")}.md"
45
45
  else
@@ -54,10 +54,10 @@ module JekyllNotion
54
54
  def log_new_page(page)
55
55
  Jekyll.logger.info("Jekyll Notion:", "Page => #{page.title}")
56
56
  if @site.config.dig(
57
- "collections", @db.collection, "output"
57
+ "collections", @notion_resource.collection_name, "output"
58
58
  )
59
59
  Jekyll.logger.info("",
60
- "Path => #{collection.docs.last.path}")
60
+ "URL => #{collection.docs.last.url}")
61
61
  end
62
62
  Jekyll.logger.debug("", "Props => #{collection.docs.last.data.keys.inspect}")
63
63
  end
@@ -0,0 +1,59 @@
1
+ # frozen_string_literal: true
2
+
3
+ module JekyllNotion
4
+ class DataGenerator < AbstractGenerator
5
+ def generate
6
+ unless data.nil?
7
+ @site.data[@notion_resource.data_name] = data
8
+ # Caching current data in Generator instance (plugin)
9
+ @plugin.data[@notion_resource.data_name] = data
10
+ log_pages
11
+ end
12
+ end
13
+
14
+ private
15
+
16
+ def data
17
+ @data ||= if @notion_resource.is_a?(NotionDatabase)
18
+ pages = @notion_resource.fetch
19
+ pages.map { |page| page.props.merge({ "content" => convert(page) }) }
20
+ else
21
+ page = @notion_resource.fetch
22
+ page&.props&.merge({ "content" => convert(page) })
23
+ end
24
+ end
25
+
26
+ # Convert the notion page body using the site.converters.
27
+ #
28
+ # Returns String the converted content.
29
+ def convert(page)
30
+ converters.reduce(page.body) do |output, converter|
31
+ converter.convert(output)
32
+ rescue StandardError => e
33
+ Jekyll.logger.error "Conversion error:",
34
+ "#{converter.class} encountered an error while "\
35
+ "converting notion page '#{page.title}':"
36
+ Jekyll.logger.error("", e.to_s)
37
+ raise e
38
+ end
39
+ end
40
+
41
+ def converters
42
+ @converters ||= @site.converters.select { |c| c.matches(".md") }.tap(&:sort!)
43
+ end
44
+
45
+ def log_pages
46
+ if data.is_a?(Array)
47
+ data.each { |page| log_page(page, Array.to_s) }
48
+ else
49
+ log_page(data, Hash.to_s)
50
+ end
51
+ end
52
+
53
+ def log_page(page, type)
54
+ Jekyll.logger.info("Jekyll Notion:", "Page => #{page["title"]}")
55
+ Jekyll.logger.info("", "#{type} => site.data.#{@notion_resource.data_name}")
56
+ Jekyll.logger.debug("", "Props => #{page.keys.inspect}")
57
+ end
58
+ end
59
+ end
@@ -0,0 +1,30 @@
1
+ # frozen_string_literal: true
2
+
3
+ module JekyllNotion
4
+ class PageGenerator < AbstractGenerator
5
+ def generate
6
+ notion_page = @notion_resource.fetch
7
+ unless notion_page.nil?
8
+ page = make_page(notion_page)
9
+ @site.pages << page
10
+ log_page(notion_page)
11
+ @plugin.pages << page
12
+ end
13
+ end
14
+
15
+ def make_page(notion_page)
16
+ JekyllNotion::PageWithoutAFile.new(@site, @site.source, "", "#{notion_page.title}.md",
17
+ make_md)
18
+ end
19
+
20
+ def log_page(notion_page)
21
+ Jekyll.logger.info("Jekyll Notion:", "Page => #{notion_page.title}")
22
+ Jekyll.logger.info("", "URL => #{@site.pages.last.url}")
23
+ Jekyll.logger.debug("", "Props => #{notion_page.props.keys.inspect}")
24
+ end
25
+
26
+ def make_md
27
+ NotionToMd::Converter.new(:page_id => @notion_resource.id).convert(:frontmatter => true)
28
+ end
29
+ end
30
+ end
@@ -1,24 +1,16 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module JekyllNotion
4
- class NotionDatabase
5
- def initialize(config:)
6
- @notion = Notion::Client.new
7
- @config = config
8
- end
9
-
10
- def pages
4
+ class NotionDatabase < AbstractNotionResource
5
+ # Returns an empty array or a NotionToMd:Page array
6
+ def fetch
11
7
  return [] unless id?
12
8
 
13
- @pages ||= @notion.database_query(query)[:results].map do |page|
14
- NotionToMd::Page.new(:page => page)
9
+ @fetch ||= @notion.database_query(query)[:results].map do |page|
10
+ NotionToMd::Page.new(:page => page, :blocks => @notion.block_children(:id => page.id))
15
11
  end
16
12
  end
17
13
 
18
- def config
19
- @config || {}
20
- end
21
-
22
14
  def filter
23
15
  config["filter"]
24
16
  end
@@ -27,29 +19,16 @@ module JekyllNotion
27
19
  config["sort"]
28
20
  end
29
21
 
30
- def id
31
- config["id"]
32
- end
33
-
34
- def collection
22
+ def collection_name
35
23
  config["collection"] || "posts"
36
24
  end
37
25
 
38
- def data
26
+ def data_name
39
27
  config["data"]
40
28
  end
41
29
 
42
30
  private
43
31
 
44
- def id?
45
- if id.nil? || id.empty?
46
- Jekyll.logger.warn("Jekyll Notion:",
47
- "database id is not provided. Cannot read from Notion.")
48
- return false
49
- end
50
- true
51
- end
52
-
53
32
  def query
54
33
  { :id => id, :filter => filter, :sort => sort }.compact
55
34
  end
@@ -0,0 +1,27 @@
1
+ # frozen_string_literal: true
2
+
3
+ module JekyllNotion
4
+ class NotionPage < AbstractNotionResource
5
+ # Returns the nil or a NotionToMd::Page instance
6
+ def fetch
7
+ return nil unless id?
8
+
9
+ @fetch ||= NotionToMd::Page.new(:page => @notion.page(query),
10
+ :blocks => @notion.block_children(query))
11
+ end
12
+
13
+ def data_name
14
+ config["data"]
15
+ end
16
+
17
+ def collection_name
18
+ nil
19
+ end
20
+
21
+ private
22
+
23
+ def query
24
+ { :id => id }
25
+ end
26
+ end
27
+ end
@@ -0,0 +1,32 @@
1
+ # frozen_string_literal: true
2
+
3
+ module JekyllNotion
4
+ class PageWithoutAFile < Jekyll::Page
5
+ def initialize(site, base, dir, name, new_content)
6
+ self.content = new_content
7
+ super(site, base, dir, name)
8
+ end
9
+
10
+ def read_yaml(base, name, _opts = {})
11
+ filename = @path || site.in_source_dir(base, name)
12
+ Jekyll.logger.debug "Reading:", relative_path
13
+
14
+ begin
15
+ if content =~ Jekyll::Document::YAML_FRONT_MATTER_REGEXP
16
+ self.content = Regexp.last_match.post_match
17
+ self.data = SafeYAML.load(Regexp.last_match(1))
18
+ end
19
+ rescue Psych::SyntaxError => e
20
+ Jekyll.logger.warn "YAML Exception reading page #{name}: #{e.message}"
21
+ raise e if site.config["strict_front_matter"]
22
+ end
23
+
24
+ self.data ||= {}
25
+
26
+ validate_data! filename
27
+ validate_permalink! filename
28
+
29
+ self.data
30
+ end
31
+ end
32
+ end
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module JekyllNotion
4
- VERSION = "1.1.0"
4
+ VERSION = "2.0.0"
5
5
  end
data/lib/jekyll-notion.rb CHANGED
@@ -13,10 +13,15 @@ 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"
18
- autoload :CollectionGenerator, "jekyll-notion/collection_generator"
19
- autoload :DataGenerator, "jekyll-notion/data_generator"
16
+ autoload :DatabaseFactory, "jekyll-notion/factories/database_factory"
17
+ autoload :PageFactory, "jekyll-notion/factories/page_factory"
18
+ autoload :AbstractGenerator, "jekyll-notion/generators/abstract_generator"
19
+ autoload :DataGenerator, "jekyll-notion/generators/data_generator"
20
+ autoload :PageGenerator, "jekyll-notion/generators/page_generator"
21
+ autoload :CollectionGenerator, "jekyll-notion/generators/collection_generator"
20
22
  autoload :DocumentWithoutAFile, "jekyll-notion/document_without_a_file"
23
+ autoload :PageWithoutAFile, "jekyll-notion/page_without_a_file"
24
+ autoload :AbstractNotionResource, "jekyll-notion/abstract_notion_resource"
21
25
  autoload :NotionDatabase, "jekyll-notion/notion_database"
26
+ autoload :NotionPage, "jekyll-notion/notion_page"
22
27
  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.1.0
4
+ version: 2.0.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-26 00:00:00.000000000 Z
11
+ date: 2022-03-16 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: jekyll
@@ -50,14 +50,14 @@ dependencies:
50
50
  requirements:
51
51
  - - "~>"
52
52
  - !ruby/object:Gem::Version
53
- version: '0'
53
+ version: '1.0'
54
54
  type: :runtime
55
55
  prerelease: false
56
56
  version_requirements: !ruby/object:Gem::Requirement
57
57
  requirements:
58
58
  - - "~>"
59
59
  - !ruby/object:Gem::Version
60
- version: '0'
60
+ version: '1.0'
61
61
  - !ruby/object:Gem::Dependency
62
62
  name: bundler
63
63
  requirement: !ruby/object:Gem::Requirement
@@ -110,13 +110,18 @@ extra_rdoc_files:
110
110
  files:
111
111
  - README.md
112
112
  - lib/jekyll-notion.rb
113
- - lib/jekyll-notion/abstract_generator.rb
114
- - lib/jekyll-notion/collection_generator.rb
115
- - lib/jekyll-notion/data_generator.rb
113
+ - lib/jekyll-notion/abstract_notion_resource.rb
116
114
  - lib/jekyll-notion/document_without_a_file.rb
115
+ - lib/jekyll-notion/factories/database_factory.rb
116
+ - lib/jekyll-notion/factories/page_factory.rb
117
117
  - lib/jekyll-notion/generator.rb
118
- - lib/jekyll-notion/generator_factory.rb
118
+ - lib/jekyll-notion/generators/abstract_generator.rb
119
+ - lib/jekyll-notion/generators/collection_generator.rb
120
+ - lib/jekyll-notion/generators/data_generator.rb
121
+ - lib/jekyll-notion/generators/page_generator.rb
119
122
  - lib/jekyll-notion/notion_database.rb
123
+ - lib/jekyll-notion/notion_page.rb
124
+ - lib/jekyll-notion/page_without_a_file.rb
120
125
  - lib/jekyll-notion/version.rb
121
126
  homepage: https://github.com/emoriarty/jekyll-notion
122
127
  licenses:
@@ -1,15 +0,0 @@
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,17 +0,0 @@
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
@@ -1,13 +0,0 @@
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