jekyll-notion 2.4.0 → 2.4.1

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: a99d9e0d1e2b47634401803cdd361f608540db56b02d8599a1723da1d8be635d
4
- data.tar.gz: eb0c99a5c4d9f90e54c2b1c5111d3ae916cc92775c550760e82f87765e31011f
3
+ metadata.gz: 823cd1e40e6efc0003a0829807361ef7e9aef85d13e7a5a83236be1ea48312b0
4
+ data.tar.gz: 729882137bd7597ce87f2ba66d8f79df57b794262cd19950b5288f952a8f6c13
5
5
  SHA512:
6
- metadata.gz: 06f5e378e96a41cf66bdf21e751165be504fdec9d3263b6a1db6a6a30e7c082d3988310d74bab49b35f2f330a1db244e42ce9fc31308fa42ee4c41a88e09a023
7
- data.tar.gz: 7c4c1f8f39d728d3a830d6b3aa7ebfb96483a4823f14756ec40b388d0b2e79b7aba68371c1f5ae9feea3070f8d1e8a8265ef526045b315d17370e7bbd2686237
6
+ metadata.gz: a32dc6d722f0692658969df2d7ebfd195e865503c47fda06ed2556f8b7c005968a2c08f96dfe4a5188926fc192094494d53423d107b67ca93a9717952a05f2e4
7
+ data.tar.gz: 3b8b5b61aa56e48e2823f58c00ddc67af8a9bdc5b892aedd7d13863aea25ecf14cf2def9b64cc1259170974527d00d250b8468b053d38a14e1957037d13f1fd3
data/README.md CHANGED
@@ -42,7 +42,7 @@ notion:
42
42
  - id: 5cfed4de3bdc4f43ae8ba653a7a2219b
43
43
  ```
44
44
 
45
- By default, the notion pages contained in the database will be loaded into the `posts` collection.
45
+ By default, the notion pages in the database will be loaded into the `posts` collection.
46
46
 
47
47
  We can also define __multiple databases__ as follows.
48
48
 
@@ -80,6 +80,12 @@ notion:
80
80
  sorts: [{ "timestamp": "created_time", "direction": "ascending" }]
81
81
  ```
82
82
 
83
+ #### Posts date
84
+
85
+ The `created_time` property of a notion page is used to set the date in the post filename. This is the date used for the `date` variable of the [predefined variables for posts](https://jekyllrb.com/docs/front-matter/#predefined-variables-for-posts).
86
+
87
+ It's important to note that the `created_time` cannot be modifed. However, if you wish to change the date of a post, you can create a new page property named "date" (or "Date"). This way, the posts collection will use the `date` property for the post date variable instead of the `created_time`.
88
+
83
89
  ### Pages
84
90
 
85
91
  Individual Notion pages can also be loaded into Jekyll. Just define the `page` property as follows.
@@ -26,16 +26,8 @@ module JekyllNotion
26
26
  end
27
27
  end
28
28
 
29
- def database_query(*args)
30
- VCR.use_cassette((args[0][:database_id]).to_s) { super(*args) }
31
- end
32
-
33
- def block_children(*args)
34
- VCR.use_cassette((args[0][:block_id]).to_s) { super(*args) }
35
- end
36
-
37
- def page(*args)
38
- VCR.use_cassette((args[0][:page_id]).to_s) { super(*args) }
29
+ def generate(*args)
30
+ VCR.use_cassette(resource_id) { super(*args) }
39
31
  end
40
32
  end
41
33
  end
@@ -99,7 +99,9 @@ module JekyllNotion
99
99
  # Cache Notion API responses
100
100
  if ENV["JEKYLL_ENV"] != "test" && cache?
101
101
  JekyllNotion::Cacheable.setup(config["cache_dir"])
102
- Notion::Client.prepend JekyllNotion::Cacheable
102
+ JekyllNotion::CollectionGenerator.prepend(JekyllNotion::Cacheable)
103
+ JekyllNotion::PageGenerator.prepend(JekyllNotion::Cacheable)
104
+ JekyllNotion::DataGenerator.prepend(JekyllNotion::Cacheable)
103
105
  end
104
106
  end
105
107
 
@@ -11,5 +11,9 @@ module JekyllNotion
11
11
  def generate
12
12
  raise "Do not use the AbstractGenerator class. Implement the generate method in a subclass."
13
13
  end
14
+
15
+ def resource_id
16
+ @notion_resource.id
17
+ end
14
18
  end
15
19
  end
@@ -40,10 +40,9 @@ module JekyllNotion
40
40
 
41
41
  def make_filename(page)
42
42
  if @notion_resource.collection_name == "posts"
43
- "#{page.created_time.to_date}-#{Jekyll::Utils.slugify(page.title,
44
- :mode => "latin")}.md"
43
+ "#{date_for(page)}-#{Jekyll::Utils.slugify(page.title, :mode => "latin")}.md"
45
44
  else
46
- "#{page.title.downcase.parameterize}.md"
45
+ "#{Jekyll::Utils.slugify(page.title, :mode => "latin")}.md"
47
46
  end
48
47
  end
49
48
 
@@ -61,5 +60,15 @@ module JekyllNotion
61
60
  end
62
61
  Jekyll.logger.debug("", "Props => #{collection.docs.last.data.keys.inspect}")
63
62
  end
63
+
64
+ def date_for(page)
65
+ # The "date" property overwrites the Jekyll::Document#data["date"] key
66
+ # which is the date used by Jekyll to set the post date.
67
+ DateTime.parse(page.props["date"]).to_date
68
+ rescue TypeError, NoMethodError
69
+ # Because the "date" property is not required,
70
+ # it fallbacks to the created_time which is always present.
71
+ page.created_time.to_date
72
+ end
64
73
  end
65
74
  end
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module JekyllNotion
4
- VERSION = "2.4.0"
4
+ VERSION = "2.4.1"
5
5
  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: 2.4.0
4
+ version: 2.4.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Enrique Arias
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2023-09-06 00:00:00.000000000 Z
11
+ date: 2023-10-14 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: jekyll