notion_to_html 1.0.0 → 1.1.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +2 -2
- data/lib/notion_to_html/service.rb +35 -5
- data/lib/notion_to_html/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: e8b2e153b0b624a12c3e95c08cbfa4bc6f2eb42f9b992c30bd659ed26b842749
|
4
|
+
data.tar.gz: 800ed54707f93d1e0a64d0cba16eb1cc0e49cb7cc8323b11796e342416aa5297
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 94aac5fd5dbc4d236421de6ad7ec7380e8132d6a0ce77293a75e860bb047321e168993d2d0e712dc7a3fa75a2631447b5536725f93dec9b75efccc932b092453
|
7
|
+
data.tar.gz: 564a7dbfcd60d118023e5103e1a63fdf1c0343e4669e155333b5131bce69d51d2d19ffcbf40780b3d0a02d75c59367990cec70e836725f65b30afbf82aa08735
|
data/README.md
CHANGED
@@ -50,7 +50,7 @@ gem install notion_to_html
|
|
50
50
|
```
|
51
51
|
## Dependencies
|
52
52
|
NotionToHtml uses [tailwindcss](https://tailwindcss.com/) classes to define a default styling that mimics Notion's own styling, so make sure to inlcude it in your application.
|
53
|
-
If you wish to use something else you can always override the default styling provided, see []() for more details.
|
53
|
+
If you wish to use something else you can always override the default styling provided, see [Customizing styles](#customizing-styles) for more details.
|
54
54
|
|
55
55
|
## Setup
|
56
56
|
This gem is currently very opinionated on how it expects the Notion database to be defined. If you wish to customize this you can override the methods defined in [NotionToHtml::Service](./lib/notion_to_html/service.rb).
|
@@ -194,7 +194,7 @@ To install this gem onto your local machine, run `bundle exec rake install`. To
|
|
194
194
|
|
195
195
|
## Contributing
|
196
196
|
|
197
|
-
Bug reports and pull requests are welcome on
|
197
|
+
Bug reports and pull requests are welcome on [Github](https://github.com/guillermoap/notion_to_html). This project is intended to be a safe, welcoming space for collaboration, and contributors are expected to adhere to the [code of conduct](/CODE_OF_CONDUCT.md).
|
198
198
|
|
199
199
|
## License
|
200
200
|
|
@@ -10,10 +10,12 @@ module NotionToHtml
|
|
10
10
|
class Service
|
11
11
|
class << self
|
12
12
|
# Generates the default query for fetching pages
|
13
|
+
# @param name [String, nil] The name to filter pages by, or nil to not filter
|
14
|
+
# @param description [String, nil] The description to filter pages by, or nil not filter
|
13
15
|
# @param tag [String, nil] The tag to filter pages by, or nil to include all tags
|
14
16
|
# @param slug [String, nil] The slug to filter pages by, or nil to include all slugs
|
15
17
|
# @return [Array<Hash>] The default query to be used in the database query
|
16
|
-
def default_query(tag: nil, slug: nil)
|
18
|
+
def default_query(name: nil, description: nil, tag: nil, slug: nil)
|
17
19
|
query = [
|
18
20
|
{
|
19
21
|
property: 'public',
|
@@ -32,6 +34,24 @@ module NotionToHtml
|
|
32
34
|
})
|
33
35
|
end
|
34
36
|
|
37
|
+
if name
|
38
|
+
query.push({
|
39
|
+
property: 'name',
|
40
|
+
rich_text: {
|
41
|
+
contains: name
|
42
|
+
}
|
43
|
+
})
|
44
|
+
end
|
45
|
+
|
46
|
+
if description
|
47
|
+
query.push({
|
48
|
+
property: 'description',
|
49
|
+
rich_text: {
|
50
|
+
contains: description
|
51
|
+
}
|
52
|
+
})
|
53
|
+
end
|
54
|
+
|
35
55
|
if tag
|
36
56
|
query.push({
|
37
57
|
property: 'tags',
|
@@ -54,12 +74,20 @@ module NotionToHtml
|
|
54
74
|
end
|
55
75
|
|
56
76
|
# Fetches a list of pages from Notion based on provided filters
|
77
|
+
# @param name [String, nil] The name to filter pages by, or nil to not filter
|
78
|
+
# @param description [String, nil] The description to filter pages by, or nil not filter
|
57
79
|
# @param tag [String, nil] The tag to filter pages by, or nil to include all tags
|
58
80
|
# @param slug [String, nil] The slug to filter pages by, or nil to include all slugs
|
59
81
|
# @param page_size [Integer] The number of pages to fetch per page
|
60
82
|
# @return [Array<NotionToHtml::BasePage>] The list of pages as BasePage objects
|
61
|
-
def get_pages(tag: nil, slug: nil, page_size: 10)
|
62
|
-
__get_pages(
|
83
|
+
def get_pages(name: nil, description: nil, tag: nil, slug: nil, page_size: 10)
|
84
|
+
__get_pages(
|
85
|
+
name: name,
|
86
|
+
description: description,
|
87
|
+
tag: tag,
|
88
|
+
slug: slug,
|
89
|
+
page_size: page_size
|
90
|
+
)['results'].map do |page|
|
63
91
|
NotionToHtml::BasePage.new(page)
|
64
92
|
end
|
65
93
|
end
|
@@ -123,18 +151,20 @@ module NotionToHtml
|
|
123
151
|
end
|
124
152
|
|
125
153
|
# Retrieves pages from Notion using the client
|
154
|
+
# @param name [String, nil] The name to filter pages by, or nil to not filter
|
155
|
+
# @param description [String, nil] The description to filter pages by, or nil not filter
|
126
156
|
# @param tag [String, nil] The tag to filter pages by
|
127
157
|
# @param slug [String, nil] The slug to filter pages by
|
128
158
|
# @param page_size [Integer] The number of pages to fetch per page
|
129
159
|
# @return [Hash] The response from the Notion API containing pages
|
130
|
-
def __get_pages(tag: nil, slug: nil, page_size: 10)
|
160
|
+
def __get_pages(name: nil, description: nil, tag: nil, slug: nil, page_size: 10)
|
131
161
|
client.database_query(
|
132
162
|
database_id: NotionToHtml.config.notion_database_id,
|
133
163
|
sorts: [
|
134
164
|
default_sorting
|
135
165
|
],
|
136
166
|
filter: {
|
137
|
-
'and': default_query(tag: tag, slug: slug)
|
167
|
+
'and': default_query(name: name, description: description, tag: tag, slug: slug)
|
138
168
|
},
|
139
169
|
page_size: page_size
|
140
170
|
)
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: notion_to_html
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.
|
4
|
+
version: 1.1.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Guillermo Aguirre
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2024-
|
11
|
+
date: 2024-11-03 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: actionview
|
@@ -115,7 +115,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
115
115
|
- !ruby/object:Gem::Version
|
116
116
|
version: '0'
|
117
117
|
requirements: []
|
118
|
-
rubygems_version: 3.5.
|
118
|
+
rubygems_version: 3.5.16
|
119
119
|
signing_key:
|
120
120
|
specification_version: 4
|
121
121
|
summary: Notion HTML renderer for Ruby
|