jekyll-notion 0.1.1 → 0.1.5

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: ea3659b155864441e1d6eb08111597ce11ffec1891011ed9f7c7724dcbc7d186
4
- data.tar.gz: 2e6ecac50f3d6aaae6e3af587d362f5470054452552e2dc1691d25e1abead605
3
+ metadata.gz: e46b38a04459bcc270b3dd99729eb34e4c7275393c3097cf92af526845e6f94e
4
+ data.tar.gz: 100eb193c3ee037ca004a8e6b1a3b2bd2a52e2d727484f557edc2a2a0b1edd04
5
5
  SHA512:
6
- metadata.gz: 5698ea2735469d130cbec72aee61facd213589f1e349dd7d29588214896f931d2d8c740a36f5d7d2f36d83ca9a9b5fd976806c3c135eca7e201eac13f4b98d97
7
- data.tar.gz: 7cad325c6ce2cf4e3216f086693b40ead4cc7b176826c1f26efb33b98e342d92ee285d9ed22f9d84b6e4eced090a227ef88bbf5139dc662c2067c9bec79f08f0
6
+ metadata.gz: 25b24f800326c681fb40e28111f6b7662924679418b37d3e2113327061cddc2171a57d46abf2c3fbfaa42228a8f828106aa0ad2fa69f68df507a63c8f5d6cbbb
7
+ data.tar.gz: d6fdce97c3cd46102b7e493787ee90b057f7c3ee254308f6cf97b9d7fe1e2f975c6969e73b1dd8426fb0d6436aa89446eb918f4b57ffeddcc4717074c9e95926
data/README.md CHANGED
@@ -36,6 +36,7 @@ Once your notion database has been shared, specify the `id` in your `_config.yml
36
36
 
37
37
  ```yml
38
38
  notion:
39
+ fetch_on_watch: false
39
40
  database:
40
41
  id: b91d5...
41
42
  collection: posts
@@ -45,13 +46,16 @@ notion:
45
46
  layout: post
46
47
  ```
47
48
 
48
- The other properties are:
49
+ `fetch_on_watch` when set to `true` it allows fetching notion pages on each rebuild. By default is off, pages are only retrieved in the first build.
50
+
51
+ `database` properties are:
52
+ * `id`: the notion database unique identifier,
49
53
  * `collection`: the collection each page belongs to (posts by default),
50
54
  * `filter`: the database query filter,
51
55
  * `sort`: the database query sort,
52
56
  * `frontmatter`: additional frontmatter to append to each page in the collection.
53
57
 
54
- Note: Only one database is available.
58
+ Note: Only one notion database is available.
55
59
 
56
60
  And that's all. Each page in the notion database will be included in the selected collection.
57
61
 
@@ -59,6 +63,8 @@ And that's all. Each page in the notion database will be included in the selecte
59
63
 
60
64
  Below, page notion default properties are set in each page frontmatter.
61
65
 
66
+ Default properties include `title`, created_time`, `last_edited_time`, `icon` and `cover.
67
+
62
68
  ```
63
69
  ---
64
70
  id: b2998...
@@ -103,7 +109,7 @@ The supported properties are:
103
109
  * `email`
104
110
  * `phone_number`
105
111
 
106
- `created_time`, `last_edited_time`, `created_by`, `last_edited_by`, `title`, `rich_text` as advanced types like `formula`, `relation` and `rollup` are not supported.
112
+ `created_by`, `last_edited_by`, `rich_text` as advanced types like `formula`, `relation` and `rollup` are not supported.
107
113
 
108
114
  Check notion documentation about [property values](https://developers.notion.com/reference/property-value-object#all-property-values).
109
115
 
@@ -9,7 +9,11 @@ module JekyllNotion
9
9
 
10
10
  return unless notion_token? && config?
11
11
 
12
- read_notion_database
12
+ if fetch_on_watch? || docs.empty?
13
+ read_notion_database
14
+ else
15
+ collection.docs = docs
16
+ end
13
17
  end
14
18
 
15
19
  def read_notion_database
@@ -19,6 +23,11 @@ module JekyllNotion
19
23
  collection.docs << make_page
20
24
  Jekyll.logger.info("Jekyll Notion:", "New notion page at #{collection.docs.last.path}")
21
25
  end
26
+ @docs = collection.docs
27
+ end
28
+
29
+ def docs
30
+ @docs ||= []
22
31
  end
23
32
 
24
33
  def make_page
@@ -55,7 +64,8 @@ module JekyllNotion
55
64
 
56
65
  def make_filename
57
66
  if collection_name == "posts"
58
- "#{current_page.created_date}-#{current_page.title.downcase.parameterize}.md"
67
+ "#{current_page.created_date}-#{Jekyll::Utils.slugify(current_page.title,
68
+ :mode => "latin")}.md"
59
69
  else
60
70
  "#{current_page.title.downcase.parameterize}.md"
61
71
  end
@@ -66,13 +76,17 @@ module JekyllNotion
66
76
  end
67
77
 
68
78
  def collection
69
- @collection ||= @site.collections[collection_name]
79
+ @site.collections[collection_name]
70
80
  end
71
81
 
72
82
  def config
73
83
  @config ||= @site.config["notion"] || {}
74
84
  end
75
85
 
86
+ def fetch_on_watch?
87
+ config["fetch_on_watch"].present?
88
+ end
89
+
76
90
  def notion_token?
77
91
  if ENV["NOTION_TOKEN"].nil? || ENV["NOTION_TOKEN"].empty?
78
92
  Jekyll.logger.warn("Jekyll Notion:", "NOTION_TOKEN not provided. Cannot read from Notion.")
@@ -43,7 +43,7 @@ module JekyllNotion
43
43
  end
44
44
 
45
45
  def query
46
- { :id => id, :filter => filter, :sort => sort }
46
+ { :id => id, :filter => filter, :sort => sort }.compact
47
47
  end
48
48
  end
49
49
  end
@@ -73,7 +73,8 @@ module JekyllNotion
73
73
  class CustomProperty
74
74
  class << self
75
75
  def multi_select(prop)
76
- prop.multi_select.map(&:name).join(", ")
76
+ multi_select = prop.multi_select.map(&:name).join(", ")
77
+ "[#{multi_select}]"
77
78
  end
78
79
 
79
80
  def select(prop)
@@ -81,11 +82,13 @@ module JekyllNotion
81
82
  end
82
83
 
83
84
  def people(prop)
84
- prop.people.map(&:name).join(", ")
85
+ people = prop.people.map(&:name).join(", ")
86
+ "[#{people}]"
85
87
  end
86
88
 
87
89
  def files(prop)
88
- prop.files.map { |f| f.file.url }.join(", ")
90
+ files = prop.files.map { |f| f.file.url }.join(", ")
91
+ "[#{files}]"
89
92
  end
90
93
 
91
94
  def phone_number(prop)
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module JekyllNotion
4
- VERSION = "0.1.1"
4
+ VERSION = "0.1.5"
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: 0.1.1
4
+ version: 0.1.5
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-01-25 00:00:00.000000000 Z
11
+ date: 2022-02-03 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: activesupport