hugo-notion 0.1.0.pre.alpha.2 → 0.1.0.pre.alpha.4
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 +52 -0
- data/bin/huno +7 -10
- data/lib/hugo_notion/synchronizer.rb +5 -5
- data/lib/hugo_notion/version.rb +1 -1
- metadata +5 -4
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: a01cd4d000a8b5bbd92c8dace6bb7d74a251fd218e9bdc301989edabd746f85e
|
4
|
+
data.tar.gz: 66bf11b69e4282460933c7932be0c91842f43b01882d8605821fd04a2d4d82a9
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: c591d6f8e60da2199d8a39dc8c0bb87e89009d394f2b1cbf066576ef8e99d8f0b8923769aec24ca4a6cab7ccc8e1382786c61c612f01983929c7562462bcd8ba
|
7
|
+
data.tar.gz: bcfe59b27d295ba72b0c62e0d6b0dc67a53f66d20a23f09259c3d435c2c1c6fa25d4c17191a108c3117255ab23b0fdef0ff01c86aaa092674dc2af84715bf89f
|
data/README.md
CHANGED
@@ -1,3 +1,55 @@
|
|
1
1
|
# hugo-notion
|
2
2
|
|
3
3
|
Write in Notion. Publish with Hugo.
|
4
|
+
|
5
|
+
## Installation
|
6
|
+
|
7
|
+
```
|
8
|
+
gem install hugo-notion --prerelease
|
9
|
+
```
|
10
|
+
|
11
|
+
Installing the `hugo-notion` ruby gem will install the `huno` command.
|
12
|
+
|
13
|
+
## Usage
|
14
|
+
|
15
|
+
First, create a Notion integration, generate a secret and connect that integration to the Notion page https://developers.notion.com/docs/create-a-notion-integration#getting-started
|
16
|
+
|
17
|
+
Go to your Hugo site directory and run
|
18
|
+
|
19
|
+
```
|
20
|
+
NOTION_TOKEN=your_notion_secret huno your_notion_page_url
|
21
|
+
```
|
22
|
+
|
23
|
+
`huno` will sync your Notion page and its children pages to the `content` directory.
|
24
|
+
|
25
|
+
If you're yet to move your Hugo pages to Notion, you can use my "blog_content" Notion page as a template https://www.notion.so/blog_content-0f1b55769779411a95df1ee9b4b070c9
|
26
|
+
|
27
|
+
## Tips
|
28
|
+
|
29
|
+
If you'd like `huno` to sync Notion pages to a different directory, you can do that too
|
30
|
+
|
31
|
+
```
|
32
|
+
NOTION_TOKEN=your_notion_secret huno your_notion_page_url site_content/
|
33
|
+
```
|
34
|
+
|
35
|
+
To avoid having to provide the `NOTION_TOKEN` env var again and again, you can create a `.env` file
|
36
|
+
|
37
|
+
```
|
38
|
+
echo 'NOTION_TOKEN=your_notion_secret' > .env
|
39
|
+
```
|
40
|
+
|
41
|
+
To run `huno` say, every 15 seconds, use the `watch` command
|
42
|
+
|
43
|
+
```
|
44
|
+
watch -n15 huno your_notion_page_url
|
45
|
+
```
|
46
|
+
|
47
|
+
If you're on MacOS and don't have the `watch` command installed, you can use Homebrew to install it
|
48
|
+
|
49
|
+
```
|
50
|
+
brew install watch
|
51
|
+
```
|
52
|
+
|
53
|
+
## Bug Reports
|
54
|
+
|
55
|
+
If you'd like to report a bug (if there are any, please do), please create a GitHub issue
|
data/bin/huno
CHANGED
@@ -15,7 +15,7 @@ end
|
|
15
15
|
notion_page_url = ARGV[0]
|
16
16
|
notion_page_id = URI(notion_page_url).path.match(/-(?<page_id>.*)\z/)['page_id']
|
17
17
|
|
18
|
-
destination_dir = Dir.pwd
|
18
|
+
destination_dir = File.join(Dir.pwd, 'content')
|
19
19
|
if ARGV[1]
|
20
20
|
if Pathname.new(ARGV[1]).absolute?
|
21
21
|
destination_dir = ARGV[1]
|
@@ -24,12 +24,9 @@ if ARGV[1]
|
|
24
24
|
end
|
25
25
|
end
|
26
26
|
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
puts "Done."
|
34
|
-
sleep 10
|
35
|
-
end
|
27
|
+
puts "Syncing posts from Notion..."
|
28
|
+
Synchronizer.run(
|
29
|
+
notion_page_id: notion_page_id,
|
30
|
+
destination_dir: destination_dir
|
31
|
+
)
|
32
|
+
puts "Done."
|
@@ -1,4 +1,4 @@
|
|
1
|
-
env_file_path = File.
|
1
|
+
env_file_path = File.join(Dir.pwd, '.env')
|
2
2
|
if File.exist?(env_file_path)
|
3
3
|
require 'dotenv'
|
4
4
|
Dotenv.load(env_file_path)
|
@@ -62,7 +62,7 @@ class Synchronizer
|
|
62
62
|
existing_page_file_names = Dir.entries(destination_dir).select { |f| !File.directory? f }
|
63
63
|
page_file_names = []
|
64
64
|
notion_blocks.each do |notion_block|
|
65
|
-
notion_block_id =
|
65
|
+
notion_block_id = notion_block['id']
|
66
66
|
|
67
67
|
if notion_block['type'] == 'child_database'
|
68
68
|
notion_child_database_title = notion_block['child_database']['title']
|
@@ -79,11 +79,11 @@ class Synchronizer
|
|
79
79
|
'date' => Time.parse(notion_block['created_time'])
|
80
80
|
}
|
81
81
|
if notion_block['properties']
|
82
|
-
if
|
82
|
+
if notion_block.dig('properties', 'date', 'date', 'start')
|
83
83
|
page_front_matter['date'] = Time.parse(notion_block['properties']['date']['date']['start'])
|
84
84
|
end
|
85
85
|
|
86
|
-
if
|
86
|
+
if notion_block.dig('properties', 'Name', 'title', 0, 'plain_text')
|
87
87
|
page_front_matter['title'] = notion_block['properties']['Name']['title'][0]['plain_text']
|
88
88
|
end
|
89
89
|
end
|
@@ -107,7 +107,7 @@ class Synchronizer
|
|
107
107
|
end
|
108
108
|
|
109
109
|
page_front_matter_yaml = page_front_matter.to_yaml.chomp
|
110
|
-
page_markdown = NotionToMd.convert(
|
110
|
+
page_markdown = NotionToMd.convert(page_id: notion_block_id, token: NOTION_TOKEN)
|
111
111
|
page_content = <<-page_CONTENT
|
112
112
|
#{page_front_matter_yaml}
|
113
113
|
---
|
data/lib/hugo_notion/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: hugo-notion
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.0.pre.alpha.
|
4
|
+
version: 0.1.0.pre.alpha.4
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Nisanth Chunduru
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2024-04-
|
11
|
+
date: 2024-04-17 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: httparty
|
@@ -66,7 +66,7 @@ dependencies:
|
|
66
66
|
- - ">="
|
67
67
|
- !ruby/object:Gem::Version
|
68
68
|
version: '0'
|
69
|
-
description:
|
69
|
+
description: Use Notion as a CMS (Content Management System) for your Hugo site
|
70
70
|
email:
|
71
71
|
- nisanth074@gmail.com
|
72
72
|
executables:
|
@@ -79,7 +79,8 @@ files:
|
|
79
79
|
- lib/hugo_notion/synchronizer.rb
|
80
80
|
- lib/hugo_notion/version.rb
|
81
81
|
homepage: https://github.com/nisanthchunduru/hugo-notion
|
82
|
-
licenses:
|
82
|
+
licenses:
|
83
|
+
- MIT
|
83
84
|
metadata: {}
|
84
85
|
post_install_message:
|
85
86
|
rdoc_options: []
|