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
Display latest version in header #6676
Conversation
I don't like to have to update the config file manually at each release, any way to add this to our |
Lines 87 to 90 in 5ef2deb
|
@ashmaroli yeah I was thinking of something similar: a task that parses |
yes, that's the way to do it.. I just pointed you to where to add the code.. |
@ashmaroli as you like (I was going to try to learn how to parse a yml file in Ruby, but I 'm sure you'll be quicker at this). Thanks for your help. |
This is the updated block for above snippet.. I'll leave it to you to update the task name(s) and description and test locally .. 😉 😁 desc "Write the site latest_version.txt file"
task :version_file do
return if version =~ %r!(beta|rc|alpha)!i
config_file = File.join(docs_folder, "_config.yml")
contents = File.read(config_file)
File.write(config_file, contents.sub(/(?:version\s*:\s+)(.+)/, "version: #{version}"))
end |
@ashmaroli thanks, works like a charm 👍 |
rake/site.rake
Outdated
desc "Write the site latest_version.txt file" | ||
task :version_file do | ||
File.open("#{docs_folder}/latest_version.txt", "wb") { |f| f.puts(version) } unless version =~ %r!(beta|rc|alpha)!i | ||
desc "Write the site latest version" |
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.
How about..?
- "Write the site latest version"
+ "Write the latest Jekyll version used to generate the site"
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.
I kept the beginning of your suggestion to keep it short
8a31ccb
to
6ce7079
Compare
6ce7079
to
57b009a
Compare
okay.. I'll let the others review the changes.. desc "Write the latest Jekyll version"
task :latest_version do
return if version =~ %r!(beta|rc|alpha)!i
config_file = File.join(docs_folder, "_config.yml")
contents = File.read(config_file)
version_regex = /(?:version\s*:\s+)(.+)/
if contents =~ version_regex
File.write(config_file, contents.sub(version_regex, "version: #{version}"))
else
File.open(config_file, "a+") do |file|
file.puts <<-TXT
# latest docs version displayed in the header
# inserted and updated automatically by the following rake task(s)
# bundle exec rake site:preview
# bundle exec rake site:latest_version
version: #{version}"
TXT
end
end
end |
@jekyllbot: merge +site |
@DirtyF @ashmaroli ❤️ thanks for fixing this so quickly! require 'safe_yaml/load'
config = SafeYAML.load_file(config_file)
config["version"] = version
File.write(config_file, YAML.dump(config)) so we don't have to use a regex, but just a suggestion as it is already merged and works fine! |
@Crunch09 👍 that's exactly what I was thinking about, I like it DRY. I even thought we could use a Jekyll class to read the config file. Feel free to open a PR and I'll merge it 😄 |
Wow @Crunch09, That is sooo much better..!! ( Why didn't I think of that!! 😄 ) |
PR automatically created for @DirtyF.