bridgetown-mdjs 1.0.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 +7 -0
- data/.gitignore +38 -0
- data/.rubocop.yml +21 -0
- data/CHANGELOG.md +5 -0
- data/Gemfile +12 -0
- data/LICENSE.txt +22 -0
- data/README.md +99 -0
- data/Rakefile +19 -0
- data/bridgetown-mdjs.gemspec +24 -0
- data/lib/bridgetown-mdjs.rb +4 -0
- data/lib/bridgetown-mdjs/builder.rb +39 -0
- data/lib/bridgetown-mdjs/version.rb +5 -0
- metadata +115 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA256:
|
3
|
+
metadata.gz: 1fe089448e5668972743ad5e0e876895b9041c0111e04d16629bb4e29562bfc8
|
4
|
+
data.tar.gz: 4cf16587c152448a5b7624f2bddbdbfa80013c891f36cf17f08b17dca1daff07
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: 9d0dc12d8d9462cefc8c32dedf079edce314a0f4cda7efdb9f021c8c646a215ddbcedc71a8c1b50b4d5318a18999b8b9badcf7f689d952f03ce836a5b1f5ae3b
|
7
|
+
data.tar.gz: 44b432ab46d7cda81d0466214e88141cdbf4c881cc94999e2da59198529c4cd04018ab531e72e55734e34829b661282b3724cd6d05d1c56e0a8b875cd223ba52
|
data/.gitignore
ADDED
@@ -0,0 +1,38 @@
|
|
1
|
+
/vendor
|
2
|
+
/.bundle/
|
3
|
+
/.yardoc
|
4
|
+
/Gemfile.lock
|
5
|
+
/_yardoc/
|
6
|
+
/coverage/
|
7
|
+
/doc/
|
8
|
+
/pkg/
|
9
|
+
/spec/reports/
|
10
|
+
/tmp/
|
11
|
+
*.bundle
|
12
|
+
*.so
|
13
|
+
*.o
|
14
|
+
*.a
|
15
|
+
mkmf.log
|
16
|
+
*.gem
|
17
|
+
Gemfile.lock
|
18
|
+
.bundle
|
19
|
+
.ruby-version
|
20
|
+
|
21
|
+
# Node
|
22
|
+
node_modules
|
23
|
+
.npm
|
24
|
+
.node_repl_history
|
25
|
+
|
26
|
+
# Yarn
|
27
|
+
yarn-error.log
|
28
|
+
yarn-debug.log*
|
29
|
+
.pnp/
|
30
|
+
.pnp.js
|
31
|
+
|
32
|
+
# Yarn Integrity file
|
33
|
+
.yarn-integrity
|
34
|
+
|
35
|
+
spec/dest
|
36
|
+
.bridgetown-metadata
|
37
|
+
.bridgetown-cache
|
38
|
+
.bridgetown-webpack
|
data/.rubocop.yml
ADDED
@@ -0,0 +1,21 @@
|
|
1
|
+
require: rubocop-bridgetown
|
2
|
+
|
3
|
+
inherit_gem:
|
4
|
+
rubocop-bridgetown: .rubocop.yml
|
5
|
+
|
6
|
+
AllCops:
|
7
|
+
TargetRubyVersion: 2.5
|
8
|
+
Include:
|
9
|
+
- lib/**/*.rb
|
10
|
+
|
11
|
+
Exclude:
|
12
|
+
- .gitignore
|
13
|
+
- .rubocop.yml
|
14
|
+
|
15
|
+
- Gemfile.lock
|
16
|
+
- CHANGELOG.md
|
17
|
+
- LICENSE.txt
|
18
|
+
- README.md
|
19
|
+
|
20
|
+
- script/**/*
|
21
|
+
- vendor/**/*
|
data/CHANGELOG.md
ADDED
data/Gemfile
ADDED
data/LICENSE.txt
ADDED
@@ -0,0 +1,22 @@
|
|
1
|
+
The MIT License (MIT)
|
2
|
+
|
3
|
+
Copyright (c) 2021-present Jared White and Bridgetown contributors
|
4
|
+
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining
|
6
|
+
a copy of this software and associated documentation files (the
|
7
|
+
"Software"), to deal in the Software without restriction, including
|
8
|
+
without limitation the rights to use, copy, modify, merge, publish,
|
9
|
+
distribute, sublicense, and/or sell copies of the Software, and to
|
10
|
+
permit persons to whom the Software is furnished to do so, subject to
|
11
|
+
the following conditions:
|
12
|
+
|
13
|
+
The above copyright notice and this permission notice shall be
|
14
|
+
included in all copies or substantial portions of the Software.
|
15
|
+
|
16
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
17
|
+
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
18
|
+
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
19
|
+
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
20
|
+
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
21
|
+
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
22
|
+
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
data/README.md
ADDED
@@ -0,0 +1,99 @@
|
|
1
|
+
# bridgetown-mdjs
|
2
|
+
|
3
|
+
A [Bridgetown](https://www.bridgetownrb.com) plugin to add Kramdown-based support for [Markdown JavaScript (mdjs)](https://rocket.modern-web.dev/docs/markdown-javascript/overview/).
|
4
|
+
|
5
|
+
|
6
|
+
|
7
|
+
## Installation
|
8
|
+
|
9
|
+
Run this command to add this plugin to your site's Gemfile:
|
10
|
+
|
11
|
+
```shell
|
12
|
+
$ bundle add bridgtown-mdjs -g bridgetown_plugins
|
13
|
+
```
|
14
|
+
|
15
|
+
Then add either a Liquid tag or Ruby helper to your default layout right below the main content.
|
16
|
+
|
17
|
+
```html
|
18
|
+
<!-- Liquid -->
|
19
|
+
<main>
|
20
|
+
{{ content }}
|
21
|
+
{% mdjs_script %}
|
22
|
+
</main>
|
23
|
+
|
24
|
+
<!-- ERB -->
|
25
|
+
<main>
|
26
|
+
<%= yield %>
|
27
|
+
<%= mdjs_script %>
|
28
|
+
</main>
|
29
|
+
```
|
30
|
+
|
31
|
+
## Usage
|
32
|
+
|
33
|
+
The plugin will perform the necessary extractions via the [kramdown-parser-gfm-extractions](https://github.com/bridgetownrb/kramdown-parser-gfm-extractions) add-on to any Markdown file in your Bridgetown site.
|
34
|
+
|
35
|
+
Here's an example Markdown file where you can see mdjs in action:
|
36
|
+
|
37
|
+
~~~markdown
|
38
|
+
# Introducing mdjs
|
39
|
+
|
40
|
+
Let's import some components from Skypack!
|
41
|
+
|
42
|
+
```js script
|
43
|
+
import SlIcon from "https://cdn.skypack.dev/@shoelace-style/shoelace/dist/components/icon/icon.js"
|
44
|
+
import SlIconButton from "https://cdn.skypack.dev/@shoelace-style/shoelace/dist/components/icon-button/icon-button.js"
|
45
|
+
import { setBasePath } from "https://cdn.skypack.dev/@shoelace-style/shoelace/dist/utilities/base-path.js"
|
46
|
+
|
47
|
+
setBasePath("https://cdn.skypack.dev/@shoelace-style/shoelace/dist")
|
48
|
+
```
|
49
|
+
|
50
|
+
## Hello from Shoelace!
|
51
|
+
|
52
|
+
<sl-icon-button name="emoji-smile" label="Yo!"></sl-icon-button>
|
53
|
+
|
54
|
+
And it's easy to change the DOM…
|
55
|
+
|
56
|
+
<aside id="hey-hey"></aside>
|
57
|
+
|
58
|
+
```js script
|
59
|
+
document.querySelector("#hey-hey").innerHTML = "<p>You you!</p>"
|
60
|
+
```
|
61
|
+
~~~
|
62
|
+
|
63
|
+
### Optional configuration options
|
64
|
+
|
65
|
+
By default, extraction tags (inert, using `template`) aren't included in the rendered output HTML. You can change those options inside the `kramdown` namespace in `bridgetown.config.yml`. See [kramdown-parser-gfm-extractions](https://github.com/bridgetownrb/kramdown-parser-gfm-extractions) README for further details.
|
66
|
+
|
67
|
+
## Testing
|
68
|
+
|
69
|
+
* Run `bundle exec rake test` to run the test suite
|
70
|
+
* Run `rubocop` to check for any style offenses.
|
71
|
+
|
72
|
+
## Releasing
|
73
|
+
|
74
|
+
* Run `bundle exec rake test_and_release` to verify rubocop and tests before releasing a new gem.
|
75
|
+
|
76
|
+
## Contributing
|
77
|
+
|
78
|
+
1. Fork it (https://github.com/bridgetownrb/bridgetown-mdjs/fork)
|
79
|
+
2. Clone the fork using `git clone` to your local development machine.
|
80
|
+
3. Create your feature branch (`git checkout -b my-new-feature`)
|
81
|
+
4. Commit your changes (`git commit -am 'Add some feature'`)
|
82
|
+
5. Push to the branch (`git push origin my-new-feature`)
|
83
|
+
6. Create a new Pull Request
|
84
|
+
|
85
|
+
----
|
86
|
+
|
87
|
+
## Releasing (you can delete this section in your own plugin repo)
|
88
|
+
|
89
|
+
To release a new version of the plugin, simply bump up the version number in both `version.rb` and
|
90
|
+
`package.json`, and then run `script/release`. This will require you to have a registered account
|
91
|
+
with both the [RubyGems.org](https://rubygems.org) and [NPM](https://www.npmjs.com) registries.
|
92
|
+
You can optionally remove the `package.json` and `frontend` folder if you don't need to package frontend
|
93
|
+
assets for Webpack.
|
94
|
+
|
95
|
+
If you run into any problems or need further guidance, please check out our [Bridgetown community resources](https://www.bridgetownrb.com/docs/community)
|
96
|
+
where friendly folks are standing by to help you build and release your plugin or theme.
|
97
|
+
|
98
|
+
**NOTE:** make sure you add the `bridgetown-plugin` [topic](https://github.com/topics/bridgetown-plugin) to your
|
99
|
+
plugin's GitHub repo so the plugin or theme will show up on [Bridgetown's official Plugin Directory](https://www.bridgetownrb.com/plugins)! (There may be a day or so delay before you see it appear.)
|
data/Rakefile
ADDED
@@ -0,0 +1,19 @@
|
|
1
|
+
require "bundler/gem_tasks"
|
2
|
+
require "rake/testtask"
|
3
|
+
require "rubocop/rake_task"
|
4
|
+
|
5
|
+
Rake::TestTask.new(:test) do |t|
|
6
|
+
t.libs << "test"
|
7
|
+
t.libs << "lib"
|
8
|
+
t.test_files = FileList["test/**/test_*.rb"]
|
9
|
+
t.warning = false
|
10
|
+
end
|
11
|
+
|
12
|
+
RuboCop::RakeTask.new
|
13
|
+
|
14
|
+
task :test_and_release => [:rubocop, :test] do |t|
|
15
|
+
# Release the gem if rubocop and tests pass
|
16
|
+
Rake::Task["release"].invoke
|
17
|
+
end
|
18
|
+
|
19
|
+
task :default => :test
|
@@ -0,0 +1,24 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require_relative "lib/bridgetown-mdjs/version"
|
4
|
+
|
5
|
+
Gem::Specification.new do |spec|
|
6
|
+
spec.name = "bridgetown-mdjs"
|
7
|
+
spec.version = BridgetownMdjs::VERSION
|
8
|
+
spec.author = "Bridgetown Team"
|
9
|
+
spec.email = "maintainers@bridgetownrb.com"
|
10
|
+
spec.summary = "Kramdown-based support for Markdown JavaScript (mdjs) in Bridgetown"
|
11
|
+
spec.homepage = "https://github.com/bridgetownrb/bridgetown-mdjs"
|
12
|
+
spec.license = "MIT"
|
13
|
+
|
14
|
+
spec.files = `git ls-files -z`.split("\x0").reject { |f| f.match(%r!^(test|script|spec|features)/!) }
|
15
|
+
spec.require_paths = ["lib"]
|
16
|
+
|
17
|
+
spec.required_ruby_version = ">= 2.5.0"
|
18
|
+
|
19
|
+
spec.add_dependency "bridgetown", ">= 0.21.0.beta1", "< 2.0"
|
20
|
+
spec.add_dependency "kramdown-parser-gfm-extractions", "~> 1.0"
|
21
|
+
|
22
|
+
spec.add_development_dependency "bundler"
|
23
|
+
spec.add_development_dependency "rubocop-bridgetown", "~> 0.2"
|
24
|
+
end
|
@@ -0,0 +1,39 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module BridgetownMdjs
|
4
|
+
class Builder < Bridgetown::Builder
|
5
|
+
def build
|
6
|
+
# Set the kramdown input to use the extractions parser
|
7
|
+
site.config.kramdown.input = "GFMExtractions"
|
8
|
+
|
9
|
+
# Obtain method as a proc and call it from within either the Liquid or Ruby helper contexts
|
10
|
+
method(:process_extractions).tap do |process_the|
|
11
|
+
liquid_tag "mdjs_script" do |_attributes, tag|
|
12
|
+
process_the.(tag.context.registers[:page][:markdown_extractions])
|
13
|
+
end
|
14
|
+
helper "mdjs_script", helpers_scope: true do
|
15
|
+
process_the.(view.page.data.markdown_extractions)
|
16
|
+
end
|
17
|
+
end
|
18
|
+
end
|
19
|
+
|
20
|
+
def process_extractions(extractions)
|
21
|
+
jscode = +""
|
22
|
+
|
23
|
+
extractions&.each do |extraction|
|
24
|
+
jscode << extraction.code if (extraction.lang == "js") && (extraction.meta == "script")
|
25
|
+
end
|
26
|
+
|
27
|
+
if jscode.present?
|
28
|
+
return <<~HTML
|
29
|
+
<script type="module">
|
30
|
+
#{jscode}</script>
|
31
|
+
HTML
|
32
|
+
end
|
33
|
+
|
34
|
+
jscode
|
35
|
+
end
|
36
|
+
end
|
37
|
+
end
|
38
|
+
|
39
|
+
BridgetownMdjs::Builder.register
|
metadata
ADDED
@@ -0,0 +1,115 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: bridgetown-mdjs
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 1.0.0
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Bridgetown Team
|
8
|
+
autorequire:
|
9
|
+
bindir: bin
|
10
|
+
cert_chain: []
|
11
|
+
date: 2021-04-26 00:00:00.000000000 Z
|
12
|
+
dependencies:
|
13
|
+
- !ruby/object:Gem::Dependency
|
14
|
+
name: bridgetown
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
16
|
+
requirements:
|
17
|
+
- - ">="
|
18
|
+
- !ruby/object:Gem::Version
|
19
|
+
version: 0.21.0.beta1
|
20
|
+
- - "<"
|
21
|
+
- !ruby/object:Gem::Version
|
22
|
+
version: '2.0'
|
23
|
+
type: :runtime
|
24
|
+
prerelease: false
|
25
|
+
version_requirements: !ruby/object:Gem::Requirement
|
26
|
+
requirements:
|
27
|
+
- - ">="
|
28
|
+
- !ruby/object:Gem::Version
|
29
|
+
version: 0.21.0.beta1
|
30
|
+
- - "<"
|
31
|
+
- !ruby/object:Gem::Version
|
32
|
+
version: '2.0'
|
33
|
+
- !ruby/object:Gem::Dependency
|
34
|
+
name: kramdown-parser-gfm-extractions
|
35
|
+
requirement: !ruby/object:Gem::Requirement
|
36
|
+
requirements:
|
37
|
+
- - "~>"
|
38
|
+
- !ruby/object:Gem::Version
|
39
|
+
version: '1.0'
|
40
|
+
type: :runtime
|
41
|
+
prerelease: false
|
42
|
+
version_requirements: !ruby/object:Gem::Requirement
|
43
|
+
requirements:
|
44
|
+
- - "~>"
|
45
|
+
- !ruby/object:Gem::Version
|
46
|
+
version: '1.0'
|
47
|
+
- !ruby/object:Gem::Dependency
|
48
|
+
name: bundler
|
49
|
+
requirement: !ruby/object:Gem::Requirement
|
50
|
+
requirements:
|
51
|
+
- - ">="
|
52
|
+
- !ruby/object:Gem::Version
|
53
|
+
version: '0'
|
54
|
+
type: :development
|
55
|
+
prerelease: false
|
56
|
+
version_requirements: !ruby/object:Gem::Requirement
|
57
|
+
requirements:
|
58
|
+
- - ">="
|
59
|
+
- !ruby/object:Gem::Version
|
60
|
+
version: '0'
|
61
|
+
- !ruby/object:Gem::Dependency
|
62
|
+
name: rubocop-bridgetown
|
63
|
+
requirement: !ruby/object:Gem::Requirement
|
64
|
+
requirements:
|
65
|
+
- - "~>"
|
66
|
+
- !ruby/object:Gem::Version
|
67
|
+
version: '0.2'
|
68
|
+
type: :development
|
69
|
+
prerelease: false
|
70
|
+
version_requirements: !ruby/object:Gem::Requirement
|
71
|
+
requirements:
|
72
|
+
- - "~>"
|
73
|
+
- !ruby/object:Gem::Version
|
74
|
+
version: '0.2'
|
75
|
+
description:
|
76
|
+
email: maintainers@bridgetownrb.com
|
77
|
+
executables: []
|
78
|
+
extensions: []
|
79
|
+
extra_rdoc_files: []
|
80
|
+
files:
|
81
|
+
- ".gitignore"
|
82
|
+
- ".rubocop.yml"
|
83
|
+
- CHANGELOG.md
|
84
|
+
- Gemfile
|
85
|
+
- LICENSE.txt
|
86
|
+
- README.md
|
87
|
+
- Rakefile
|
88
|
+
- bridgetown-mdjs.gemspec
|
89
|
+
- lib/bridgetown-mdjs.rb
|
90
|
+
- lib/bridgetown-mdjs/builder.rb
|
91
|
+
- lib/bridgetown-mdjs/version.rb
|
92
|
+
homepage: https://github.com/bridgetownrb/bridgetown-mdjs
|
93
|
+
licenses:
|
94
|
+
- MIT
|
95
|
+
metadata: {}
|
96
|
+
post_install_message:
|
97
|
+
rdoc_options: []
|
98
|
+
require_paths:
|
99
|
+
- lib
|
100
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
101
|
+
requirements:
|
102
|
+
- - ">="
|
103
|
+
- !ruby/object:Gem::Version
|
104
|
+
version: 2.5.0
|
105
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
106
|
+
requirements:
|
107
|
+
- - ">="
|
108
|
+
- !ruby/object:Gem::Version
|
109
|
+
version: '0'
|
110
|
+
requirements: []
|
111
|
+
rubygems_version: 3.1.4
|
112
|
+
signing_key:
|
113
|
+
specification_version: 4
|
114
|
+
summary: Kramdown-based support for Markdown JavaScript (mdjs) in Bridgetown
|
115
|
+
test_files: []
|