hugo-notion 0.1.0.pre.alpha.1 → 0.1.0.pre.alpha.3

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: a6bd4925e3b3a59530ce6240621fffc48526af50e7437d8fa1c412920a247a72
4
- data.tar.gz: 3ce5c9c0170acaddade872e954566180a4b8bb5d0b29be542ac836e0d8ad6f15
3
+ metadata.gz: 998722740c86d07e77edb0bcfa625cf6cd9c956f90a525cf1146604324ed26bd
4
+ data.tar.gz: 596a6adb5d21930ea0a46beb2a4cd7e1a3d309d18f2dd2ade153e9d8414f70e5
5
5
  SHA512:
6
- metadata.gz: dbe275da44f5a7bde42180a20e889338935e1c3299c20bfc96860521220f0f394c887201c60bea65427b34ef224696329b49c017aaa1562f0e4994e9e9513f25
7
- data.tar.gz: 87aa5d782b3461a21b95ac0e30a702f6b91fc7dadc7a8c779ce88ad6a07a37e7d408aad6ec02c824a32434539434afc02e21f752b408f7198a19a03a0d9bf4de
6
+ metadata.gz: d44e9c969c40cdcbabcfd0442aa7577b54c31865910dc4cf51a268545f8fd1c76e705c64540e6e678284e48782227cf17dd048ccffd7793d17171b5222ea9f84
7
+ data.tar.gz: 6269bf536477e430f23912f0cc23e1b5a4a4eeb184e64afb38a918efbd602eb678b0d5776dbb383e960cd42f8d607f11caf703a76be26e62ea253c0fb323d423
data/bin/huno ADDED
@@ -0,0 +1,32 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ require_relative '../lib/hugo_notion/synchronizer'
4
+
5
+ def do_exit
6
+ puts 'Exiting...'
7
+ exit
8
+ end
9
+ Signal.trap("TERM") { do_exit }
10
+ Signal.trap("INT") { do_exit }
11
+
12
+ if !ARGV[0]
13
+ puts "Please provide the URL of the Notion page you'd like to sync as the first argument"
14
+ end
15
+ notion_page_url = ARGV[0]
16
+ notion_page_id = URI(notion_page_url).path.match(/-(?<page_id>.*)\z/)['page_id']
17
+
18
+ destination_dir = File.join(Dir.pwd, 'content')
19
+ if ARGV[1]
20
+ if Pathname.new(ARGV[1]).absolute?
21
+ destination_dir = ARGV[1]
22
+ else
23
+ destination_dir = File.join(Dir.pwd, ARGV[1])
24
+ end
25
+ end
26
+
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.expand_path('../../.env', File.dirname(__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 = notion_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 block.dig('properties', 'date', 'date', 'start')
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 block.dig('properties', 'Name', 'title', 0, 'plain_text')
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(notion_page_id: notion_block_id, token: NOTION_TOKEN)
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
  ---
@@ -1,3 +1,3 @@
1
1
  class HugoNotion
2
- VERSION = '0.1.0-alpha.1'
2
+ VERSION = '0.1.0-alpha.3'
3
3
  end
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.1
4
+ version: 0.1.0.pre.alpha.3
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-15 00:00:00.000000000 Z
11
+ date: 2024-04-16 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: httparty
@@ -69,11 +69,13 @@ dependencies:
69
69
  description: Write in Notion. Publish with Hugo.
70
70
  email:
71
71
  - nisanth074@gmail.com
72
- executables: []
72
+ executables:
73
+ - huno
73
74
  extensions: []
74
75
  extra_rdoc_files: []
75
76
  files:
76
77
  - README.md
78
+ - bin/huno
77
79
  - lib/hugo_notion/synchronizer.rb
78
80
  - lib/hugo_notion/version.rb
79
81
  homepage: https://github.com/nisanthchunduru/hugo-notion