yass 0.7.0 → 0.8.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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 649645d7b796ba02544a816464ff18efb5fdac5c3e914f16ce39ebde71337a37
4
- data.tar.gz: e6e2268d8733f20efb0f03f7b29c2a5a58e8e0deac5a0a4d796db3ca2ae78971
3
+ metadata.gz: 56e665858452753381b536e074b6274703fd300fa17d632db1c5ff483200534f
4
+ data.tar.gz: bf41608fb07a38904412bc128a3c02a5cb5688798bb3f60402f905c553b601f6
5
5
  SHA512:
6
- metadata.gz: e0eae7b97dbf4cc49a7e37812f867d0734e249058f560e58067be91d69abd4c2ce3e3a4e37eb5203555bc2135fc958a7c30c80cac67e1cd6c0551e44548c0c10
7
- data.tar.gz: df0d5bf462455417fed28d9725fee69bba326284e20e57532fb6a27a142363e8c91d4f670735f71d72a82a670dd2ec1a67d468829d043ef82304f336701b2690
6
+ metadata.gz: 1f9cd5d5c10817e729ba035c31af5afed41c5db07311b186226d48a698f8d72ee06844363fda9a1abc9e8942a07684ace5c6a6ed43404492d26b99041c6439ba
7
+ data.tar.gz: 24708d754b8835a1c86b5d004343cba13e6c166dfd6a1565ff4092924c31d140ff7a43db338ae07e7870c14475a524e05b37a0bbe481f079a98cc94ac1de7899
data/README.md CHANGED
@@ -32,16 +32,16 @@ The built site will be placed into `dist`.
32
32
  yass build
33
33
  ```
34
34
 
35
- NOTE If you're building for webserverless, local viewing, and using the `skip_index` filter anywhere, use the `--no-skip-index` option.
35
+ NOTE If you're building for webserverless, local viewing, and using the `strip_index` filter anywhere, use the `--no-strip-index` option.
36
36
 
37
37
  ```bash
38
- yass build --no-skip-index
38
+ yass build --no-strip-index
39
39
  ```
40
40
 
41
41
  Use the `watch` command to continually build your site as files change.
42
42
 
43
43
  ```bash
44
- yass watch # also supports --no-skip-index
44
+ yass watch # also supports --no-strip-index
45
45
  ```
46
46
 
47
47
  ## License
@@ -16,6 +16,7 @@ An object representing the current page. Properties:
16
16
  * `filename` Name of file (e.g. *zorp.html* from *foo/bar/zorp.html*)
17
17
  * `extname` File extension (e.g. *.html* from *foo/bar/zorp.html*)
18
18
  * `filesize` Size of file in bytes
19
+ * `published` If the file is published or not
19
20
  * Any other value defined in the file's YAML front matter
20
21
 
21
22
  {% highlight html %}
@@ -24,7 +25,7 @@ An object representing the current page. Properties:
24
25
 
25
26
  ### files
26
27
 
27
- Any array of all files that will be written `dist/`. Same properties as `page`.
28
+ Any array of all (published) files that will be written `dist/`. Same properties as `page`.
28
29
 
29
30
  {% highlight html %}
30
31
  {% echo '{% assign css_files = files | where: "extname", ".css" %' %}}
@@ -69,6 +70,14 @@ Works like Liquid's built-it `where`, but accepts a regular expression.
69
70
  {% echo '{% assign posts = where_match: "path", "^posts/.+\.html$" %' %}}
70
71
  {% endhighlight %}
71
72
 
73
+ ### where_not
74
+
75
+ Works like Liquid's built-it `where`, but returns object that *don't* match.
76
+
77
+ {% highlight %}
78
+ {% echo '{% assign posts = where_not: "hidden", true %' %}}
79
+ {% endhighlight %}
80
+
72
81
  ## Tags
73
82
 
74
83
  ### highlight
@@ -3,7 +3,7 @@ layout: splash
3
3
  ---
4
4
  # What is Yass?
5
5
 
6
- Yass is an astonishingly un-opinionated static site generator. Your sites's structure is entirely up to you: organize static assets, `.html` files, `.md` ([Markdown](https://commonmark.org/)) files, and `.liquid` ([Liquid](https://shopify.github.io/liquid/)) templates however you want under `site/`. Liquid layouts, reusable templates, and YAML front matter are supported.
6
+ Yass is an astonishingly un-opinionated static site generator. Your sites's structure is entirely up to you: organize static assets, `.html` files, `.md` ([Markdown](https://github.github.com/gfm/)) files, and `.liquid` ([Liquid](https://shopify.github.io/liquid/)) templates however you want under `site/`. Liquid layouts, reusable templates, and YAML front matter are supported.
7
7
 
8
8
  The **one** opinion Yass holds is that **you** should decide everything. There's zero configuration and no conventions to learn!
9
9
 
@@ -43,18 +43,20 @@ $ yass build
43
43
 
44
44
  To preview your site on your computer, simply open `dist/index.html` with your browser 🤯. (This requires using relative links, but there are helpers for that.)
45
45
 
46
- If you're building for webserverless, local viewing, and using the `skip_index` filter anywhere, use the `--no-skip-index` option.
46
+ If you're building for webserverless, local viewing, and using the `strip_index` filter anywhere, use the `--no-strip-index` option.
47
47
 
48
48
  {% highlight bash %}
49
- $ yass build --no-skip-index
49
+ $ yass build --no-strip-index
50
50
  {% endhighlight %}
51
51
 
52
52
  The `watch` command will continuously build as you make changes in `site/`, `layouts/`, and `templates/`.
53
53
 
54
54
  {% highlight bash %}
55
- $ yass watch # --no-skip-index works here too
55
+ $ yass watch # --no-strip-index works here too
56
56
  {% endhighlight %}
57
57
 
58
+ Run `yass --help` for all options.
59
+
58
60
  ## Interested?
59
61
 
60
62
  Keep reading about [layouts, templates]({{ "layouts-templates/index.html" | relative | strip_index }}), and [helpers]({{ "helpers/index.html" | relative | strip_index }}), or check out the code on [Github](https://github.com/jhollinger/yass)!
@@ -1,14 +1,22 @@
1
1
  # Front Matter
2
2
 
3
- Any file under `site/` may prepend YAML front matter to override the auto-generated title, set a layout, or set arbitrary attributes on the page for use in Liquid.
3
+ Any file under `site/` may prepend YAML front matter to tweak how that file is rendered. All fields are optional.
4
4
 
5
5
  {% highlight yaml %}
6
6
  ---
7
+ # The default title is based on the filename
7
8
  title: My Title
8
- layout: foo
9
+ # Override the default layout, or disable the layout with false
10
+ layout: home
11
+ # If this file isn't ready yet, set to false
12
+ published: true
13
+
14
+ # Arbitrary values will be available on `page` and `files`
9
15
  my_val: bar
10
16
  ---
11
- # File contents go here
17
+ <!DOCTYPE html>
18
+ <html lang="en">
19
+ ...
12
20
  {% endhighlight %}
13
21
 
14
22
  # Layouts
@@ -49,6 +49,7 @@ yass <command> [path/to/dir] [options]
49
49
  ).strip
50
50
  opts.on("--clean", "Remove unknown files from dist/ when bulding") { config.clean = true }
51
51
  opts.on("--dest=DIR", "Build to a different directory") { |dir| config.dest = find_path(dir, cwd: Dir.pwd) }
52
+ opts.on("--drafts", "Include unpublished files in build") { config.include_drafts = true }
52
53
  opts.on("--no-strip-index", "Disable the strip_index Liquid filter") { config.strip_index = false }
53
54
  opts.on("--debug", "Print stack traces") { config.debug = true }
54
55
  opts.on("-h", "--help", "Prints this help") { config.stdout.puts opts; exit }
@@ -63,6 +64,7 @@ yass <command> [path/to/dir] [options]
63
64
  templates: "templates",
64
65
  dest: "dist",
65
66
  clean: false,
67
+ include_drafts: false,
66
68
  strip_index: true,
67
69
  stdin: $stdin,
68
70
  stdout: $stdout,
data/lib/yass/config.rb CHANGED
@@ -1,5 +1,5 @@
1
1
  module Yass
2
- Config = Struct.new(:cwd, :src, :dest, :layouts, :templates, :clean, :strip_index, :stdin, :stdout, :stderr, :debug, keyword_init: true) do
2
+ Config = Struct.new(:cwd, :src, :dest, :layouts, :templates, :clean, :include_drafts, :strip_index, :stdin, :stdout, :stderr, :debug, keyword_init: true) do
3
3
  def src_dir = @src_dir ||= get_dir(src)
4
4
  def dest_dir = @dest_dir ||= get_dir(dest)
5
5
  def template_dir = @template_dir ||= get_dir(templates)
@@ -23,6 +23,7 @@ module Yass
23
23
  .reject { |path| Dir.exist? path }
24
24
  .map { |path| Pathname.new path }
25
25
  .map { |path| Source.new(self, path) }
26
+ .select { |source| source.published? || include_drafts }
26
27
  end
27
28
 
28
29
  def liquid_env
@@ -27,7 +27,7 @@ module Yass
27
27
  def generate(source, outfile, content = source.content)
28
28
  case outfile.extname
29
29
  when ".md"
30
- content = Kramdown::Document.new(content).to_html
30
+ content = Kramdown::Document.new(content, input: "GFM").to_html
31
31
  return generate(source, outfile.sub(/\.md$/, ".html"), content)
32
32
  when ".liquid"
33
33
  template = LiquidTemplate.compile(config, source.src_path, content)
@@ -9,9 +9,8 @@ module Yass
9
9
  end
10
10
 
11
11
  def strip_index(url)
12
- path = Pathname.new(url)
13
- strip = path.basename.to_s == "index.html" && strip_index?
14
- strip ? path.dirname.to_s : path.to_s
12
+ path = strip_index? ? url.sub(%r'/?index\.html([\?#][^/]*)?$', '\1') : url
13
+ path == "" ? "." : path
15
14
  end
16
15
 
17
16
  def match(str, regex) = Regexp.new(regex).match? str
@@ -21,6 +20,8 @@ module Yass
21
20
  objects.select { |obj| regex =~ obj[field].to_s }
22
21
  end
23
22
 
23
+ def where_not(objects, field, value) = objects.reject { |obj| obj[field] == value }
24
+
24
25
  private
25
26
 
26
27
  def strip_index? = context.registers[:source].config.strip_index
@@ -37,6 +37,7 @@ module Yass
37
37
  "filename" => source.dest_path.basename.to_s,
38
38
  "extname" => source.dest_path.basename.extname,
39
39
  "filesize" => source.size,
40
+ "published" => source.published?,
40
41
  })
41
42
  end
42
43
 
data/lib/yass/source.rb CHANGED
@@ -17,8 +17,8 @@ module Yass
17
17
  @size = File.stat(path).size
18
18
 
19
19
  @front_matter, @content = parse_content
20
- @title = @front_matter.delete "title" if front_matter.key? "title"
21
- @layout_name = @front_matter.delete "layout" if front_matter.key? "layout"
20
+ @title = front_matter.delete "title" if front_matter.key? "title"
21
+ @layout_name = front_matter.delete "layout" if front_matter.key? "layout"
22
22
  end
23
23
 
24
24
  def layout
@@ -41,6 +41,8 @@ module Yass
41
41
 
42
42
  def content = @content ||= path.read
43
43
 
44
+ def published? = front_matter["published"].nil? ? true : !!front_matter["published"]
45
+
44
46
  private
45
47
 
46
48
  def dest_filename
data/lib/yass/version.rb CHANGED
@@ -1,3 +1,3 @@
1
1
  module Yass
2
- VERSION = "0.7.0".freeze
2
+ VERSION = "0.8.0".freeze
3
3
  end
data/lib/yass.rb CHANGED
@@ -1,7 +1,8 @@
1
1
  require 'pathname'
2
2
  require 'filewatcher'
3
+ require 'liquid' # MUST be loaded before kramdown-parser-gfm for some reason
3
4
  require 'kramdown'
4
- require 'liquid'
5
+ require 'kramdown-parser-gfm'
5
6
 
6
7
  module Yass
7
8
  autoload :CLI, 'yass/cli'
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: yass
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.7.0
4
+ version: 0.8.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Jordan Hollinger
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2025-05-13 00:00:00.000000000 Z
11
+ date: 2025-05-14 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: filewatcher
@@ -38,6 +38,20 @@ dependencies:
38
38
  - - "~>"
39
39
  - !ruby/object:Gem::Version
40
40
  version: '2.0'
41
+ - !ruby/object:Gem::Dependency
42
+ name: kramdown-parser-gfm
43
+ requirement: !ruby/object:Gem::Requirement
44
+ requirements:
45
+ - - "~>"
46
+ - !ruby/object:Gem::Version
47
+ version: '1.0'
48
+ type: :runtime
49
+ prerelease: false
50
+ version_requirements: !ruby/object:Gem::Requirement
51
+ requirements:
52
+ - - "~>"
53
+ - !ruby/object:Gem::Version
54
+ version: '1.0'
41
55
  - !ruby/object:Gem::Dependency
42
56
  name: liquid
43
57
  requirement: !ruby/object:Gem::Requirement