notion_to_html 1.0.0 → 1.1.1
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 +2 -2
- data/lib/notion_to_html/service.rb +33 -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: 24f573a8d18785478aca2c6c7cb78586bcb6a70aa17bc5a28987cb6eaf968239
|
4
|
+
data.tar.gz: 83d3f01bbce28ad2b8597e48ad4f013660099c7e72907b76cfbd12750ddea2b1
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 174d02c86596ba17a4a1c0f4fed2cc8dc543ea95ebe262a3eab7eecd85ea2b1f98d590c64f748eb781bbad66ac00f04c44070dd75e28cc148c9fc8a5c4fea9fc
|
7
|
+
data.tar.gz: a82b7902bfae05f335d1f78d5f3e5bca1e27416be34babef6dd74c1a05ba8550008e0cdc833f5ba96ba78e0610f094f63357fe36f049998f92d6d2217a61683a
|
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,22 @@ module NotionToHtml
|
|
32
34
|
})
|
33
35
|
end
|
34
36
|
|
37
|
+
if name
|
38
|
+
query.push({
|
39
|
+
property: 'name',
|
40
|
+
contains: name
|
41
|
+
})
|
42
|
+
end
|
43
|
+
|
44
|
+
if description
|
45
|
+
query.push({
|
46
|
+
property: 'description',
|
47
|
+
rich_text: {
|
48
|
+
contains: description
|
49
|
+
}
|
50
|
+
})
|
51
|
+
end
|
52
|
+
|
35
53
|
if tag
|
36
54
|
query.push({
|
37
55
|
property: 'tags',
|
@@ -54,12 +72,20 @@ module NotionToHtml
|
|
54
72
|
end
|
55
73
|
|
56
74
|
# Fetches a list of pages from Notion based on provided filters
|
75
|
+
# @param name [String, nil] The name to filter pages by, or nil to not filter
|
76
|
+
# @param description [String, nil] The description to filter pages by, or nil not filter
|
57
77
|
# @param tag [String, nil] The tag to filter pages by, or nil to include all tags
|
58
78
|
# @param slug [String, nil] The slug to filter pages by, or nil to include all slugs
|
59
79
|
# @param page_size [Integer] The number of pages to fetch per page
|
60
80
|
# @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(
|
81
|
+
def get_pages(name: nil, description: nil, tag: nil, slug: nil, page_size: 10)
|
82
|
+
__get_pages(
|
83
|
+
name: name,
|
84
|
+
description: description,
|
85
|
+
tag: tag,
|
86
|
+
slug: slug,
|
87
|
+
page_size: page_size
|
88
|
+
)['results'].map do |page|
|
63
89
|
NotionToHtml::BasePage.new(page)
|
64
90
|
end
|
65
91
|
end
|
@@ -123,18 +149,20 @@ module NotionToHtml
|
|
123
149
|
end
|
124
150
|
|
125
151
|
# Retrieves pages from Notion using the client
|
152
|
+
# @param name [String, nil] The name to filter pages by, or nil to not filter
|
153
|
+
# @param description [String, nil] The description to filter pages by, or nil not filter
|
126
154
|
# @param tag [String, nil] The tag to filter pages by
|
127
155
|
# @param slug [String, nil] The slug to filter pages by
|
128
156
|
# @param page_size [Integer] The number of pages to fetch per page
|
129
157
|
# @return [Hash] The response from the Notion API containing pages
|
130
|
-
def __get_pages(tag: nil, slug: nil, page_size: 10)
|
158
|
+
def __get_pages(name: nil, description: nil, tag: nil, slug: nil, page_size: 10)
|
131
159
|
client.database_query(
|
132
160
|
database_id: NotionToHtml.config.notion_database_id,
|
133
161
|
sorts: [
|
134
162
|
default_sorting
|
135
163
|
],
|
136
164
|
filter: {
|
137
|
-
'and': default_query(tag: tag, slug: slug)
|
165
|
+
'and': default_query(name: name, description: description, tag: tag, slug: slug)
|
138
166
|
},
|
139
167
|
page_size: page_size
|
140
168
|
)
|
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.1
|
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
|