Skip to content

Commit

Permalink
support pin
Browse files Browse the repository at this point in the history
  • Loading branch information
zhgchgli0718 committed Aug 10, 2023
1 parent f616a46 commit 7fd5d5b
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 2 deletions.
2 changes: 1 addition & 1 deletion ZMediumToMarkdown.gemspec
Original file line number Diff line number Diff line change
Expand Up @@ -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"

Expand Down
4 changes: 4 additions & 0 deletions lib/Helper.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
7 changes: 6 additions & 1 deletion lib/Post.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down Expand Up @@ -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

0 comments on commit 7fd5d5b

Please sign in to comment.