jekyll-notion 1.1.1 → 2.1.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: d06d0e87707f04d3125126bc7b801c38b6d25aa047ccea5074c567de5504c166
4
- data.tar.gz: cb581ec500f718c21156eacdffbd3b77368254573de4bfc891f5e074aea8d811
3
+ metadata.gz: d730d8b3c38a4857f9a506b6219aeba97b31f9257fb6c6ecfefe5fe2c30e921c
4
+ data.tar.gz: 7ce7ce2738857027a3b2f48fc5b237b1e4725963d9a2a5273a12c92ba41477f0
5
5
  SHA512:
6
- metadata.gz: d4acb7a0293e3136b7ef128e3881c2683dc81c9daa56ce1f5659fdae146b117014a25660c394b692995d7b86bc0d06f2b2aeeccc1179c4571d035cbeb232c868
7
- data.tar.gz: fd462f54aaebbbf8fdfa925653b74b2443603ff10a7fb8c25b38dc63bea4f13fb261fcfb619c8e0f84d7974c1e2f5ae3a69ff0489bf817c2bacc7dd71a094381
6
+ metadata.gz: cc4d474362dd91a1308a917654d725151877f81f348c768211aa272a265233e3af82119d47e75209e3aaeb205207a15a325a8795e18d2a4fd8c27ead79f947d8
7
+ data.tar.gz: bcf4276e64b3d2176a015b8ab81ced2d4f4e3cc2e8a2755f4a54502d1b0b28c6d43ca234b55d55765572d7c36ee69986f132475c4c200a052c2b0171538cf72a
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 jekyll.
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,46 +53,93 @@ 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.
63
+ After running `jekyll build` (or `serve`) command, the `posts`, `recipes` and `films` collections will be loaded with pages from the notion databases.
64
64
 
65
- ### data
65
+ #### Database options
66
66
 
67
- Instead of storing notion pages in a collection, you can also map to the data object. Declare the data property as follows.
67
+ Each dabatase support the following options.
68
+
69
+ * `id`: the notion database unique identifier,
70
+ * `collection`: the collection each page belongs to (posts by default),
71
+ * `filter`: the database [filter property](https://developers.notion.com/reference/post-database-query-filter),
72
+ * `sorts`: the database [sorts criteria](https://developers.notion.com/reference/post-database-query-sort),
68
73
 
69
74
  ```yml
70
75
  notion:
71
76
  database:
72
- id: e42383cd-4975-4897-b967-ce453760499f
73
- data: films
77
+ id: e42383cd49754897b967ce453760499f
78
+ collection: posts
79
+ filter: { "property": "Published", "checkbox": { "equals": true } }
80
+ sorts: [{ "timestamp": "created_time", "direction": "ascending" }]
74
81
  ```
75
82
 
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.
83
+ ### Pages
77
84
 
78
- ### Database options
85
+ Individual Notion pages can also be loaded into Jekyll. Just define the `page` property as follows.
79
86
 
80
- Each dabatase support the following options.
87
+ ```yml
88
+ notion:
89
+ page:
90
+ id: 5cfed4de3bdc4f43ae8ba653a7a2219b
91
+ ```
81
92
 
82
- * `id`: the notion database unique identifier,
83
- * `collection`: the collection each page belongs to (posts by default),
84
- * `filter`: the database query filter,
85
- * `sort`: the database query sort,
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.
86
110
 
87
111
  ```yml
88
112
  notion:
89
- database:
90
- id: e42383cd-4975-4897-b967-ce453760499f
91
- collection: posts
92
- filter: { "property": "Published", "checkbox": { "equals": true } }
93
- sort: { "property": "Last ordered", "direction": "ascending" }
113
+ databases:
114
+ - id: b0e688e199af4295ae80b67eb52f2e2f
115
+ - id: e42383cd49754897b967ce453760499f
116
+ data: films
117
+ pages:
118
+ - id: e42383cd49754897b967ce453760499f
119
+ - id: b0e688e199af4295ae80b67eb52f2e2f
120
+ data: about
94
121
  ```
95
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,18 +9,24 @@ module JekyllNotion
9
9
 
10
10
  return unless notion_token? && config?
11
11
 
12
- if fetch_on_watch? || collections_and_data_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 }
16
17
  data.each_pair { |key, val| @site.data[key] = val }
18
+ pages.each { |page| @site.pages << page }
17
19
  end
18
20
  end
19
21
 
20
- def databases
22
+ def config_databases
21
23
  config["databases"] || [config["database"]]
22
24
  end
23
25
 
26
+ def config_pages
27
+ config["pages"] || [config["page"]]
28
+ end
29
+
24
30
  def collections
25
31
  @collections ||= {}
26
32
  end
@@ -29,16 +35,27 @@ module JekyllNotion
29
35
  @data ||= {}
30
36
  end
31
37
 
38
+ def pages
39
+ @pages ||= []
40
+ end
41
+
32
42
  protected
33
43
 
34
- def collections_and_data_empty?
35
- collections.empty? && data.empty?
44
+ def cache_empty?
45
+ collections.empty? && pages.empty? && data.empty?
36
46
  end
37
47
 
38
- def read_notion_database
39
- databases.each do |db_config|
48
+ def read_notion_databases
49
+ config_databases.each do |db_config|
40
50
  db = NotionDatabase.new(:config => db_config)
41
- 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
42
59
  end
43
60
  end
44
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,57 +1,39 @@
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(:block_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
25
17
 
26
- def sort
27
- config["sort"]
28
- end
29
-
30
- def id
31
- config["id"]
18
+ def sorts
19
+ if config["sort"]
20
+ Jekyll.logger.warn("Jekyll Notion:", "sort property will be deprecated, use sorts instead")
21
+ end
22
+ config["sorts"] || config["sort"]
32
23
  end
33
24
 
34
- def collection
25
+ def collection_name
35
26
  config["collection"] || "posts"
36
27
  end
37
28
 
38
- def data
29
+ def data_name
39
30
  config["data"]
40
31
  end
41
32
 
42
33
  private
43
34
 
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
35
  def query
54
- { :id => id, :filter => filter, :sort => sort }.compact
36
+ { :database_id => id, :filter => filter, :sorts => sorts }.compact
55
37
  end
56
38
  end
57
39
  end
@@ -0,0 +1,21 @@
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({ :page_id => id }),
10
+ :blocks => @notion.block_children({ :block_id => id }))
11
+ end
12
+
13
+ def data_name
14
+ config["data"]
15
+ end
16
+
17
+ def collection_name
18
+ nil
19
+ end
20
+ end
21
+ 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.1"
4
+ VERSION = "2.1.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.1
4
+ version: 2.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-28 00:00:00.000000000 Z
11
+ date: 2022-04-05 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: jekyll
@@ -36,28 +36,28 @@ dependencies:
36
36
  requirements:
37
37
  - - "~>"
38
38
  - !ruby/object:Gem::Version
39
- version: '0'
39
+ version: 1.0.0
40
40
  type: :runtime
41
41
  prerelease: false
42
42
  version_requirements: !ruby/object:Gem::Requirement
43
43
  requirements:
44
44
  - - "~>"
45
45
  - !ruby/object:Gem::Version
46
- version: '0'
46
+ version: 1.0.0
47
47
  - !ruby/object:Gem::Dependency
48
48
  name: notion_to_md
49
49
  requirement: !ruby/object:Gem::Requirement
50
50
  requirements:
51
51
  - - "~>"
52
52
  - !ruby/object:Gem::Version
53
- version: '0'
53
+ version: 1.2.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.2.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:
@@ -137,8 +142,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
137
142
  - !ruby/object:Gem::Version
138
143
  version: '0'
139
144
  requirements: []
140
- rubyforge_project:
141
- rubygems_version: 2.7.3
145
+ rubygems_version: 3.1.6
142
146
  signing_key:
143
147
  specification_version: 4
144
148
  summary: A Jekyll plugin to generate pages from Notion
@@ -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,25 +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
- log_pages
10
- end
11
-
12
- private
13
-
14
- def data
15
- @data ||= @db.pages.map(&:props)
16
- end
17
-
18
- def log_pages
19
- @db.pages.each do |page|
20
- Jekyll.logger.info("Jekyll Notion:", "Page => #{page.title}")
21
- Jekyll.logger.debug("", "Props => #{page.props.keys.inspect}")
22
- end
23
- end
24
- end
25
- 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