jekyll-notion 0.0.0.beta → 0.0.0.beta.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +27 -5
- data/lib/jekyll-notion/document_without_a_file.rb +3 -3
- data/lib/jekyll-notion/generator.rb +19 -16
- data/lib/jekyll-notion/notion_database.rb +4 -4
- data/lib/jekyll-notion/notion_page.rb +2 -2
- data/lib/jekyll-notion/version.rb +1 -1
- metadata +3 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 1a2d58cc88c6a7012d3efc3eb431e9030f6287feec5b1307d731fb2b8a78a6e5
|
4
|
+
data.tar.gz: 939b5e04a4b019fd7a295dfba5c765e4f5fb5bf0f41e1b3527b01d84bf02a2cf
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: bf6461f39325a08b18dfdd18ac9413e50991bc7c18032c30e59bba013ae00f77cab5b79ddcbf44100d4248cc957b98ccfd0538ddf323e3881f408e7ff5c46762
|
7
|
+
data.tar.gz: d451dfcbe921c165c232fa7a6195471f7da133ab6ddb46feadcc2705771cbc6092462e8ec29fa128b7d1c14db816b77ce84d07c05d2287eb53e93e4da9e7c06c
|
data/README.md
CHANGED
@@ -39,21 +39,43 @@ notion:
|
|
39
39
|
database:
|
40
40
|
id: b91d5...
|
41
41
|
collection: posts
|
42
|
-
layout: post
|
43
42
|
filter: { "property": "Published", "checkbox": { "equals": true } }
|
44
43
|
sort: { "propery": "Last ordered", "direction": "ascending" }
|
45
44
|
frontmatter:
|
46
|
-
|
47
|
-
prop_2: albalb
|
45
|
+
layout: post
|
48
46
|
```
|
49
47
|
|
50
48
|
The other properties are:
|
51
49
|
* `collection`: what collection each page belongs to,
|
52
|
-
* `layout`: the collection layout,
|
53
50
|
* `filter`: the database query filter,
|
54
51
|
* `sort`: the database query sort,
|
55
|
-
* `frontmatter`:
|
52
|
+
* `frontmatter`: additional frontmatter to append to each page in the collection.
|
56
53
|
|
57
54
|
Note: Only one database is available.
|
58
55
|
|
59
56
|
And that's all. Each page in the notion database will be included in the selected collection.
|
57
|
+
|
58
|
+
## Notion properties
|
59
|
+
|
60
|
+
Below, page notion default properties are set in each page frontmatter.
|
61
|
+
|
62
|
+
```
|
63
|
+
---
|
64
|
+
id: id
|
65
|
+
title: properties > Name > title > plain_text
|
66
|
+
cover: cover > external > url
|
67
|
+
date: created_time
|
68
|
+
---
|
69
|
+
```
|
70
|
+
|
71
|
+
## Page filename
|
72
|
+
|
73
|
+
There are two kinds of collections: posts and others.
|
74
|
+
|
75
|
+
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).
|
76
|
+
|
77
|
+
```
|
78
|
+
YEAR-MONTH-DAY-title.MARKUP
|
79
|
+
```
|
80
|
+
|
81
|
+
Any other collection, the filename is the page title.
|
@@ -2,11 +2,11 @@
|
|
2
2
|
|
3
3
|
module JekyllNotion
|
4
4
|
class DocumentWithoutAFile < Jekyll::Document
|
5
|
-
def read_content(
|
5
|
+
def read_content(_new_content, **_opts)
|
6
6
|
if content =~ YAML_FRONT_MATTER_REGEXP
|
7
|
-
self.content =
|
7
|
+
self.content = Regexp.last_match.post_match
|
8
8
|
data_file = SafeYAML.load(Regexp.last_match(1))
|
9
|
-
merge_data!(data_file, :
|
9
|
+
merge_data!(data_file, source: 'YAML front matter') if data_file
|
10
10
|
end
|
11
11
|
end
|
12
12
|
end
|
@@ -4,10 +4,6 @@ module JekyllNotion
|
|
4
4
|
class Generator < Jekyll::Generator
|
5
5
|
attr_reader :current_page
|
6
6
|
|
7
|
-
def initialize(plugin)
|
8
|
-
super(plugin)
|
9
|
-
end
|
10
|
-
|
11
7
|
def generate(site)
|
12
8
|
@site = site
|
13
9
|
|
@@ -28,7 +24,7 @@ module JekyllNotion
|
|
28
24
|
|
29
25
|
def make_page
|
30
26
|
new_post = DocumentWithoutAFile.new(
|
31
|
-
"#{Dir.pwd}/_#{
|
27
|
+
"#{Dir.pwd}/_#{collection_name}/#{make_filename}",
|
32
28
|
{ site: @site, collection: collection }
|
33
29
|
)
|
34
30
|
new_post.content = "#{make_frontmatter}\n\n#{make_md}"
|
@@ -41,27 +37,34 @@ module JekyllNotion
|
|
41
37
|
end
|
42
38
|
|
43
39
|
def make_frontmatter
|
44
|
-
|
45
|
-
#{config.dig('database', 'frontmatter').to_yaml}
|
46
|
-
id: #{current_page.id}
|
47
|
-
|
48
|
-
|
49
|
-
|
50
|
-
|
51
|
-
---
|
40
|
+
<<~CONTENT
|
41
|
+
#{config.dig('database', 'frontmatter').to_yaml}
|
42
|
+
id: #{current_page.id}
|
43
|
+
title: #{current_page.title}
|
44
|
+
date: #{current_page.created_datetime}
|
45
|
+
cover: #{current_page.cover}
|
46
|
+
---
|
52
47
|
CONTENT
|
53
48
|
end
|
54
49
|
|
55
50
|
def make_filename
|
56
|
-
|
51
|
+
if collection_name == 'posts'
|
52
|
+
"#{current_page.created_date}-#{current_page.title.downcase.parameterize}.md"
|
53
|
+
else
|
54
|
+
"#{current_page.title.downcase.parameterize}.md"
|
55
|
+
end
|
56
|
+
end
|
57
|
+
|
58
|
+
def collection_name
|
59
|
+
config.dig('database', 'collection')
|
57
60
|
end
|
58
61
|
|
59
62
|
def collection
|
60
|
-
@site.send(
|
63
|
+
@site.send(collection_name.to_sym)
|
61
64
|
end
|
62
65
|
|
63
66
|
def config
|
64
|
-
@config ||= @site.config[
|
67
|
+
@config ||= @site.config['notion'] || {}
|
65
68
|
end
|
66
69
|
|
67
70
|
def notion_token?
|
@@ -7,14 +7,14 @@ module JekyllNotion
|
|
7
7
|
@config = config
|
8
8
|
end
|
9
9
|
|
10
|
-
def pages
|
10
|
+
def pages(&block)
|
11
11
|
@pages ||= @notion.database_query(query)[:results].map do |page|
|
12
12
|
NotionPage.new(page: page, layout: config['layout'])
|
13
13
|
end
|
14
|
-
|
14
|
+
|
15
15
|
return @pages unless block_given?
|
16
16
|
|
17
|
-
@pages.each
|
17
|
+
@pages.each(&block)
|
18
18
|
end
|
19
19
|
|
20
20
|
private
|
@@ -35,7 +35,7 @@ module JekyllNotion
|
|
35
35
|
@config.dig('database', 'id')
|
36
36
|
end
|
37
37
|
|
38
|
-
def query
|
38
|
+
def query
|
39
39
|
{ id: id, filter: filter, sort: sort }
|
40
40
|
end
|
41
41
|
end
|
@@ -32,7 +32,7 @@ module JekyllNotion
|
|
32
32
|
end
|
33
33
|
|
34
34
|
def created_datetime
|
35
|
-
DateTime.parse(page[
|
35
|
+
DateTime.parse(page['created_time'])
|
36
36
|
end
|
37
37
|
|
38
38
|
def updated_date
|
@@ -40,7 +40,7 @@ module JekyllNotion
|
|
40
40
|
end
|
41
41
|
|
42
42
|
def updated_datetime
|
43
|
-
DateTime.parse(page[
|
43
|
+
DateTime.parse(page['last_edited_time'])
|
44
44
|
end
|
45
45
|
|
46
46
|
def url
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: jekyll-notion
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.0.beta
|
4
|
+
version: 0.0.0.beta.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Enrique Arias
|
@@ -45,7 +45,7 @@ dependencies:
|
|
45
45
|
- !ruby/object:Gem::Version
|
46
46
|
version: '5.0'
|
47
47
|
- !ruby/object:Gem::Dependency
|
48
|
-
name:
|
48
|
+
name: notion-ruby-client
|
49
49
|
requirement: !ruby/object:Gem::Requirement
|
50
50
|
requirements:
|
51
51
|
- - "~>"
|
@@ -59,7 +59,7 @@ dependencies:
|
|
59
59
|
- !ruby/object:Gem::Version
|
60
60
|
version: '0'
|
61
61
|
- !ruby/object:Gem::Dependency
|
62
|
-
name:
|
62
|
+
name: notion_to_md
|
63
63
|
requirement: !ruby/object:Gem::Requirement
|
64
64
|
requirements:
|
65
65
|
- - "~>"
|