From 7fd5d5baab06aa64d40ed8305a4b526784894988 Mon Sep 17 00:00:00 2001 From: zhgchgli Date: Thu, 10 Aug 2023 22:16:14 +0800 Subject: [PATCH] support pin --- ZMediumToMarkdown.gemspec | 2 +- lib/Helper.rb | 4 ++++ lib/Post.rb | 7 ++++++- 3 files changed, 11 insertions(+), 2 deletions(-) diff --git a/ZMediumToMarkdown.gemspec b/ZMediumToMarkdown.gemspec index 36c41ea..ae1879d 100644 --- a/ZMediumToMarkdown.gemspec +++ b/ZMediumToMarkdown.gemspec @@ -6,7 +6,7 @@ Gem::Specification.new do |gem| gem.files = Dir['lib/**/*.*'] gem.executables = ['ZMediumToMarkdown'] gem.name = 'ZMediumToMarkdown' - gem.version = '2.2.0' + gem.version = '2.3.0' gem.license = "MIT" diff --git a/lib/Helper.rb b/lib/Helper.rb index 75f6475..2014658 100644 --- a/lib/Helper.rb +++ b/lib/Helper.rb @@ -115,6 +115,10 @@ def self.createPostInfo(postInfo, isForJekyll) result += "image:\r\n" result += " path: /#{postInfo.previewImage}\r\n" end + if !postInfo.pinnedByCreatorAt.nil? && pinnedByCreatorAt > 0 + result += "pin: true\r\n" + end + if isForJekyll result += "render_with_liquid: false\n" end diff --git a/lib/Post.rb b/lib/Post.rb index 425de51..ee26b02 100644 --- a/lib/Post.rb +++ b/lib/Post.rb @@ -11,7 +11,7 @@ class Post class PostInfo - attr_accessor :title, :tags, :creator, :firstPublishedAt, :latestPublishedAt, :collectionName, :description, :previewImage + attr_accessor :title, :tags, :creator, :firstPublishedAt, :latestPublishedAt, :pinnedByCreatorAt, :collectionName, :description, :previewImage end def self.getPostIDFromPostURLString(postURLString) @@ -103,6 +103,11 @@ def self.parsePostInfoFromPostContent(content, postID, pathPolicy) postInfo.latestPublishedAt = Time.at(0, latestPublishedAt, :millisecond) end + pinnedByCreatorAt = content&.dig("Post:#{postID}", "pinnedByCreatorAt") + if !pinnedByCreatorAt.nil? + postInfo.pinnedByCreatorAt = Time.at(0, pinnedByCreatorAt, :millisecond) + end + postInfo end end \ No newline at end of file