jekyll-notion 0.0.1 → 0.1.2
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 +4 -4
- data/README.md +44 -5
- data/lib/jekyll-notion/generator.rb +5 -10
- data/lib/jekyll-notion/notion_page.rb +69 -0
- data/lib/jekyll-notion/version.rb +1 -1
- data/lib/jekyll-notion.rb +1 -0
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: ad5bd5565352088d6d5d4048155a6abfb38bb0136437159ed7fdfd7d0aaf27a1
|
4
|
+
data.tar.gz: 57d4da4ceec1869150d33c9bdc10825a636de18409798725bf1ae891d1459b50
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 5749b831d1884f5d88b344d92ff924dc474813098b05dedfc0862a38dceada9ac8e31c9fd5a80ff418a3974d8ff61fd8879a2c7522dfb1bff2c02b133e82d83f
|
7
|
+
data.tar.gz: c10de414ceb372b5e2c2a29ba06878f69aaa6f01cc7d37b0a1a8f50078a55b92d4d63a2709e963f2da625ac73878008ae33a0c74c375ecf06f67b5b08c02a0cc
|
data/README.md
CHANGED
@@ -40,7 +40,7 @@ notion:
|
|
40
40
|
id: b91d5...
|
41
41
|
collection: posts
|
42
42
|
filter: { "property": "Published", "checkbox": { "equals": true } }
|
43
|
-
sort: { "
|
43
|
+
sort: { "property": "Last ordered", "direction": "ascending" }
|
44
44
|
frontmatter:
|
45
45
|
layout: post
|
46
46
|
```
|
@@ -59,17 +59,56 @@ And that's all. Each page in the notion database will be included in the selecte
|
|
59
59
|
|
60
60
|
Below, page notion default properties are set in each page frontmatter.
|
61
61
|
|
62
|
+
Default properties include `title`, created_time`, `last_edited_time`, `icon` and `cover.
|
63
|
+
|
62
64
|
```
|
63
65
|
---
|
64
|
-
id:
|
65
|
-
title:
|
66
|
-
cover:
|
67
|
-
date:
|
66
|
+
id: b2998...
|
67
|
+
title: A title
|
68
|
+
cover: https://img.bank.sh/an_image.jpg
|
69
|
+
date: 2022-01-23T12:31:00.000Z
|
70
|
+
icon: \U0001F4A5
|
68
71
|
---
|
69
72
|
```
|
70
73
|
|
71
74
|
Any property provided in the frontmatter config that matches a default property will be overwritten by the default value.
|
72
75
|
|
76
|
+
### Custom properties
|
77
|
+
|
78
|
+
In addition to default properties, custom properties are also supported.
|
79
|
+
|
80
|
+
Custom properties are appended to page frontmatter by default. Every property name is snake-cased.
|
81
|
+
For example, two properties named `Multiple Options` and `Tags` will be transformed to `multiple_options` and `tags`, respectively.
|
82
|
+
|
83
|
+
```
|
84
|
+
---
|
85
|
+
id: b2998...
|
86
|
+
title: A title
|
87
|
+
cover: https://img.bank.sh/an_image.jpg
|
88
|
+
date: 2022-01-23T12:31:00.000Z
|
89
|
+
icon: \U0001F4A5
|
90
|
+
tags: tag1, tag2, tag3
|
91
|
+
multiple_options: option1, option2
|
92
|
+
---
|
93
|
+
```
|
94
|
+
|
95
|
+
The supported properties are:
|
96
|
+
|
97
|
+
* `number`
|
98
|
+
* `select`
|
99
|
+
* `multi_select`
|
100
|
+
* `date`
|
101
|
+
* `people`
|
102
|
+
* `files`
|
103
|
+
* `checkbox`
|
104
|
+
* `url`
|
105
|
+
* `email`
|
106
|
+
* `phone_number`
|
107
|
+
|
108
|
+
`created_by`, `last_edited_by`, `rich_text` as advanced types like `formula`, `relation` and `rollup` are not supported.
|
109
|
+
|
110
|
+
Check notion documentation about [property values](https://developers.notion.com/reference/property-value-object#all-property-values).
|
111
|
+
|
73
112
|
## Page filename
|
74
113
|
|
75
114
|
There are two kinds of collections: posts and others.
|
@@ -36,22 +36,17 @@ module JekyllNotion
|
|
36
36
|
end
|
37
37
|
|
38
38
|
def make_frontmatter
|
39
|
-
data = Jekyll::Utils.deep_merge_hashes(config_frontmatter,
|
40
|
-
|
39
|
+
data = Jekyll::Utils.deep_merge_hashes(config_frontmatter, page_frontmatter)
|
40
|
+
frontmatter = data.to_a.map { |k, v| "#{k}: #{v}" }.join("\n")
|
41
41
|
<<~CONTENT
|
42
42
|
---
|
43
|
-
#{
|
43
|
+
#{frontmatter}
|
44
44
|
---
|
45
45
|
CONTENT
|
46
46
|
end
|
47
47
|
|
48
|
-
def
|
49
|
-
|
50
|
-
:id => current_page.id,
|
51
|
-
:title => current_page.title,
|
52
|
-
:date => current_page.created_datetime,
|
53
|
-
:cover => current_page.cover,
|
54
|
-
}
|
48
|
+
def page_frontmatter
|
49
|
+
Jekyll::Utils.deep_merge_hashes(current_page.custom_props, current_page.default_props)
|
55
50
|
end
|
56
51
|
|
57
52
|
def config_frontmatter
|
@@ -46,5 +46,74 @@ module JekyllNotion
|
|
46
46
|
def url
|
47
47
|
page[:url]
|
48
48
|
end
|
49
|
+
|
50
|
+
def custom_props
|
51
|
+
@custom_props ||= page.properties.each_with_object({}) do |prop, memo|
|
52
|
+
name = prop.first
|
53
|
+
value = prop.last # Notion::Messages::Message
|
54
|
+
type = value.type
|
55
|
+
|
56
|
+
next memo unless CustomProperty.respond_to?(type.to_sym)
|
57
|
+
|
58
|
+
memo[name.parameterize.underscore] = CustomProperty.send(type, value)
|
59
|
+
end.reject { |_k, v| v.presence.nil? }
|
60
|
+
end
|
61
|
+
|
62
|
+
def default_props
|
63
|
+
@default_props ||= {
|
64
|
+
:id => id,
|
65
|
+
:title => title,
|
66
|
+
:date => created_datetime,
|
67
|
+
:cover => cover,
|
68
|
+
:icon => icon,
|
69
|
+
:updated_date => updated_datetime,
|
70
|
+
}
|
71
|
+
end
|
72
|
+
|
73
|
+
class CustomProperty
|
74
|
+
class << self
|
75
|
+
def multi_select(prop)
|
76
|
+
multi_select = prop.multi_select.map(&:name).join(", ")
|
77
|
+
"[#{multi_select}]"
|
78
|
+
end
|
79
|
+
|
80
|
+
def select(prop)
|
81
|
+
prop["select"].name
|
82
|
+
end
|
83
|
+
|
84
|
+
def people(prop)
|
85
|
+
people = prop.people.map(&:name).join(", ")
|
86
|
+
"[#{people}]"
|
87
|
+
end
|
88
|
+
|
89
|
+
def files(prop)
|
90
|
+
files = prop.files.map { |f| f.file.url }.join(", ")
|
91
|
+
"[#{files}]"
|
92
|
+
end
|
93
|
+
|
94
|
+
def phone_number(prop)
|
95
|
+
prop.phone_number
|
96
|
+
end
|
97
|
+
|
98
|
+
def number(prop)
|
99
|
+
prop.number
|
100
|
+
end
|
101
|
+
|
102
|
+
def email(prop)
|
103
|
+
prop.email
|
104
|
+
end
|
105
|
+
|
106
|
+
def checkbox(prop)
|
107
|
+
prop.checkbox.to_s
|
108
|
+
end
|
109
|
+
|
110
|
+
# date type properties not supported:
|
111
|
+
# - end
|
112
|
+
# - time_zone
|
113
|
+
def date(prop)
|
114
|
+
prop.date.start
|
115
|
+
end
|
116
|
+
end
|
117
|
+
end
|
49
118
|
end
|
50
119
|
end
|
data/lib/jekyll-notion.rb
CHANGED
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.
|
4
|
+
version: 0.1.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: 2022-01-
|
11
|
+
date: 2022-01-26 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: activesupport
|