New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Preserve excerpt #946
Preserve excerpt #946
Changes from 4 commits
069e70d
0113fea
2792e1e
654d598
951ee09
b10e06c
bcda51f
2b23878
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -19,10 +19,10 @@ def self.valid?(name) | |
end | ||
|
||
attr_accessor :site | ||
attr_accessor :data, :excerpt, :content, :output, :ext | ||
attr_accessor :data, :extracted_excerpt, :content, :output, :ext | ||
attr_accessor :date, :slug, :published, :tags, :categories | ||
|
||
attr_reader :name | ||
attr_reader :name, :excerpt | ||
|
||
# Initialize this Post instance. | ||
# | ||
|
@@ -80,10 +80,18 @@ def containing_dir(source, dir) | |
# Returns nothing. | ||
def read_yaml(base, name) | ||
super(base, name) | ||
self.excerpt = self.extract_excerpt | ||
self.extracted_excerpt = self.extract_excerpt | ||
self.data['layout'] = 'post' unless self.data.has_key?('layout') | ||
end | ||
|
||
# The post excerpt. This is either a custom excerpt | ||
# set in YAML front matter or the result of extract_excerpt. | ||
# | ||
# Returns excerpt string. | ||
def excerpt | ||
self.data['excerpt'] ? converter.convert(self.data['excerpt']) : self.extracted_excerpt | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Should I also move the conversion of There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Why are you converting There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. To allow basic markdown etc. (as in the first test) in the excerpt. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I'd do something like if self.data.has_key? "excerpt"
self.data['excerpt']
else
self.extracted_excerpt
end There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I don't think that's a good idea. I'd prefer not to convert the excerpt! The excerpt in your front-matter shouldn't be long or complex enough to warrant conversion. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Done! There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. We convert the extracted excerpt. Why not convert the excerpt that's in the On Thu, Apr 11, 2013 at 2:03 PM, maul-esel notifications@github.com wrote:
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. It will modify the current expected behaviour for one, and I feel like it shouldn't be so long as to require any sort of markdown format. The former reason is the reason I'm to stick with, though :) There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I could see people wanting to have a bit of emphasis on their extracted excerpt, but I don't feel strongly enough about it to be all like "no, we shouldn't merge this, we gotta have converted excerpts". We can just add it later if it gets asked for. 😀 |
||
end | ||
|
||
# Compares Post objects. First compares the Post date. If the dates are | ||
# equal, it compares the Post slugs. | ||
# | ||
|
@@ -117,7 +125,7 @@ def process(name) | |
# Returns nothing. | ||
def transform | ||
super | ||
self.excerpt = converter.convert(self.excerpt) | ||
self.extracted_excerpt = converter.convert(self.extracted_excerpt) | ||
end | ||
|
||
# The generated directory into which the post will be placed | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
--- | ||
layout: ~ | ||
excerpt: 'I can set a custom excerpt with *markdown*' | ||
--- | ||
|
||
This is not my excerpt. | ||
|
||
Neither is this. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this shouldn't be here if you have the method below, right? :)