foresite 1.1.3 → 1.2.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/README.md +4 -2
- data/lib/foresite/cli.rb +3 -2
- data/lib/foresite/version.rb +1 -1
- data/lib/foresite.rb +2 -1
- data/lib/skeleton/wrapper.html.erb +4 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 5f29318fc927950483a0152c49fe8e735c37ff973b4d149a51b6ce005f7f6207
|
4
|
+
data.tar.gz: 152396f93cb282709e9f455429a4ecaf079a4e3ba7fdb7386e18297998d359df
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: f78b29800c68377c4d92c8da49c75cae51ae1a991b8a596bfede5e40fc2d4e592f9c07fe9f9e7d34799f87cf00648be7654cfc0bf9118ad6c9f9901615aee549
|
7
|
+
data.tar.gz: 5b5c3d8d13eabca810587354b17a16ac01573548f89436b3a91bd0f3b16a25a4165c42302d3684665804f8c714fe25cd8adc35b03fb16fb4b80fd96d58a6dc9c
|
data/README.md
CHANGED
@@ -77,7 +77,7 @@ Some facts:
|
|
77
77
|
|
78
78
|
`post.md.erb` is used to when running `foresite touch` for the default markdown content. It has two variables, `@title` for the post title and `@date_ymd` for the created date in ISO 8601 `YYYY-MM-DD` format. Modify to have different defaults when running `foresite touch`.
|
79
79
|
|
80
|
-
`wrapper.html.erb` wraps all of your markdown.
|
80
|
+
`wrapper.html.erb` wraps all of your markdown. It has two variables, `@title` for the post title that will populate the `<title>` tag, and `@content` for a given post's HTML (converted from markdown). For the `index.html` file, `@title` will be `nil`, and `@content` will be an list of links to all posts in reverse-chronological order. Modify to have different overall page structure, or to add `<style>` etc.
|
81
81
|
|
82
82
|
`_list.html.erb` is used to generate the `<ul>` list of posts on the `index.html` file. Modify to show posts in a different way.
|
83
83
|
|
@@ -103,7 +103,7 @@ In this example, the `index.html` will contain:
|
|
103
103
|
|
104
104
|
```html
|
105
105
|
<ul>
|
106
|
-
<li>2023-01-15 <a href="2023-01-15-welcome-to-my-site.html">Welcome to my site</a></li>
|
106
|
+
<li>2023-01-15 <a href="post/2023-01-15-welcome-to-my-site.html">Welcome to my site</a></li>
|
107
107
|
</ul>
|
108
108
|
```
|
109
109
|
|
@@ -123,6 +123,8 @@ Bug reports and pull requests are welcome. The goals of Foresite are:
|
|
123
123
|
* Simple to use & understand
|
124
124
|
* Minimal features
|
125
125
|
|
126
|
+
Read more in the [blog post introducing Foresite](https://carlwiedemann.github.io/post/2023-01-17-introducing-foresite.html)
|
127
|
+
|
126
128
|
## License
|
127
129
|
|
128
130
|
The gem is available as open source under the terms of the [MIT License](https://opensource.org/licenses/MIT).
|
data/lib/foresite/cli.rb
CHANGED
@@ -93,11 +93,12 @@ module Foresite
|
|
93
93
|
|
94
94
|
links = markdown_paths.map do |markdown_path|
|
95
95
|
markdown_content = File.read(markdown_path)
|
96
|
+
title = markdown_content.split("\n").first { |line| /^# [a-z]/i =~ line }.gsub(/^#/, "").strip
|
96
97
|
|
97
98
|
filename_markdown = File.basename(markdown_path)
|
98
99
|
html_path = Foresite.get_path_to_out_file(filename_markdown.gsub(/\.md$/, ".html"))
|
99
100
|
|
100
|
-
File.write(html_path, Foresite.render_wrapped(markdown_content))
|
101
|
+
File.write(html_path, Foresite.render_wrapped(title, markdown_content))
|
101
102
|
$stdout.puts("Created #{Foresite.relative_path(html_path)}")
|
102
103
|
|
103
104
|
# Extract date if it exists.
|
@@ -106,7 +107,7 @@ module Foresite
|
|
106
107
|
{
|
107
108
|
date_ymd: match_data.nil? ? "" : match_data[0],
|
108
109
|
href: Foresite.relative_path(html_path),
|
109
|
-
title:
|
110
|
+
title: title
|
110
111
|
}
|
111
112
|
end
|
112
113
|
|
data/lib/foresite/version.rb
CHANGED
data/lib/foresite.rb
CHANGED
@@ -82,8 +82,9 @@ module Foresite
|
|
82
82
|
})
|
83
83
|
end
|
84
84
|
|
85
|
-
def self.render_wrapped(markdown_content)
|
85
|
+
def self.render_wrapped(title, markdown_content)
|
86
86
|
render_erb_file(FILENAME_WRAPPER_HTML, {
|
87
|
+
title: title,
|
87
88
|
content: ::Kramdown::Document.new(markdown_content).to_html
|
88
89
|
})
|
89
90
|
end
|
@@ -1,8 +1,11 @@
|
|
1
|
+
<%
|
2
|
+
index_title = 'Another Foresite Blog'
|
3
|
+
-%>
|
1
4
|
<!DOCTYPE html>
|
2
5
|
<html lang="en">
|
3
6
|
<head>
|
4
7
|
<meta charset="utf-8">
|
5
|
-
<title
|
8
|
+
<title><%= @title ? "#{@title} - #{index_title}" : index_title %></title>
|
6
9
|
<style></style>
|
7
10
|
</head>
|
8
11
|
<body>
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: foresite
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.
|
4
|
+
version: 1.2.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Carl Wiedemann
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2023-
|
11
|
+
date: 2023-02-12 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: kramdown
|