jekyll-notion 2.4.0 → 2.4.2

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: a99d9e0d1e2b47634401803cdd361f608540db56b02d8599a1723da1d8be635d
4
- data.tar.gz: eb0c99a5c4d9f90e54c2b1c5111d3ae916cc92775c550760e82f87765e31011f
3
+ metadata.gz: '088ab1c8e851aa22893826c0ad7c23b54bf6272595b58371b341d9073e3c8808'
4
+ data.tar.gz: 712a657a2093e556dffdada517ddcb6374254e191e9be84582d4393a69359268
5
5
  SHA512:
6
- metadata.gz: 06f5e378e96a41cf66bdf21e751165be504fdec9d3263b6a1db6a6a30e7c082d3988310d74bab49b35f2f330a1db244e42ce9fc31308fa42ee4c41a88e09a023
7
- data.tar.gz: 7c4c1f8f39d728d3a830d6b3aa7ebfb96483a4823f14756ec40b388d0b2e79b7aba68371c1f5ae9feea3070f8d1e8a8265ef526045b315d17370e7bbd2686237
6
+ metadata.gz: 776ff09d46941bc596613d3968bd940d5be6d0f2a3d523d3825a055a8ffa92206c87e1a3e44ba7e4f541fae137e62a0f1e786b8a727bba3cc12936511747111c
7
+ data.tar.gz: 0fe8e951359b66becc5515f4c9f30e3060ba60b8d7e4d328f7af3aeed9484bbd9921dccce105c420509511fee486b6484b05533b56840706c905aaf63811d6ba
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.2"
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.2
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-12-14 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: jekyll
@@ -36,42 +36,48 @@ dependencies:
36
36
  requirements:
37
37
  - - "~>"
38
38
  - !ruby/object:Gem::Version
39
- version: '1.0'
39
+ version: 1.2.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: '1.0'
46
+ version: 1.2.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
+ - !ruby/object:Gem::Version
53
+ version: '2.0'
54
+ - - "<"
52
55
  - !ruby/object:Gem::Version
53
- version: '2.2'
56
+ version: '2.4'
54
57
  type: :runtime
55
58
  prerelease: false
56
59
  version_requirements: !ruby/object:Gem::Requirement
57
60
  requirements:
58
- - - "~>"
61
+ - - ">="
62
+ - !ruby/object:Gem::Version
63
+ version: '2.0'
64
+ - - "<"
59
65
  - !ruby/object:Gem::Version
60
- version: '2.2'
66
+ version: '2.4'
61
67
  - !ruby/object:Gem::Dependency
62
68
  name: vcr
63
69
  requirement: !ruby/object:Gem::Requirement
64
70
  requirements:
65
71
  - - "~>"
66
72
  - !ruby/object:Gem::Version
67
- version: '6.2'
73
+ version: 6.2.0
68
74
  type: :runtime
69
75
  prerelease: false
70
76
  version_requirements: !ruby/object:Gem::Requirement
71
77
  requirements:
72
78
  - - "~>"
73
79
  - !ruby/object:Gem::Version
74
- version: '6.2'
80
+ version: 6.2.0
75
81
  - !ruby/object:Gem::Dependency
76
82
  name: bundler
77
83
  requirement: !ruby/object:Gem::Requirement