bridgetown_obsidian 0.1.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 +41 -0
- data/.rubocop.yml +23 -0
- data/CHANGELOG.md +14 -0
- data/Gemfile +16 -0
- data/LICENSE.txt +22 -0
- data/README.md +61 -0
- data/Rakefile +11 -0
- data/bridgetown.automation.rb +51 -0
- data/bridgetown_obsidian.gemspec +24 -0
- data/lib/bridgetown_obsidian/builder.rb +42 -0
- data/lib/bridgetown_obsidian/version.rb +5 -0
- data/lib/bridgetown_obsidian.rb +26 -0
- metadata +116 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA256:
|
3
|
+
metadata.gz: '028ac3f5309759bc586703cf604625546143e23100c377dc20f6434ab0d3df00'
|
4
|
+
data.tar.gz: a3e2c3d44f5c5450a730cc4cbcd9efa5f89c8d4e3baf17c11d657d712c7c3d71
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: 1b1416069c4deb82230388cf3a05605adabdca7146424624e801074b38519f8285d82babbd6baf9ddba6b322e3aa51be1ba7a176479715418da271f4127b07c5
|
7
|
+
data.tar.gz: 212fe62a78ac8d002d65967011a42cd373ea522ce92effa1db4652c3e5a7f20886730d5a624d2e1f1043ef9c1373c781b90b31ba9d6d7c82780f562d8dbd908f
|
data/.gitignore
ADDED
@@ -0,0 +1,41 @@
|
|
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
|
+
test/dest
|
36
|
+
.bridgetown-metadata
|
37
|
+
.bridgetown-cache
|
38
|
+
.bridgetown-webpack
|
39
|
+
|
40
|
+
.env
|
41
|
+
.DS_Store
|
data/.rubocop.yml
ADDED
@@ -0,0 +1,23 @@
|
|
1
|
+
require: rubocop-bridgetown
|
2
|
+
|
3
|
+
inherit_gem:
|
4
|
+
rubocop-bridgetown: .rubocop.yml
|
5
|
+
|
6
|
+
AllCops:
|
7
|
+
TargetRubyVersion: 2.7
|
8
|
+
|
9
|
+
Exclude:
|
10
|
+
- .gitignore
|
11
|
+
- .rubocop.yml
|
12
|
+
- "*.gemspec"
|
13
|
+
|
14
|
+
- Gemfile.lock
|
15
|
+
- CHANGELOG.md
|
16
|
+
- LICENSE.txt
|
17
|
+
- README.md
|
18
|
+
- Rakefile
|
19
|
+
- bridgetown.automation.rb
|
20
|
+
|
21
|
+
- script/**/*
|
22
|
+
- test/fixtures/**/*
|
23
|
+
- vendor/**/*
|
data/CHANGELOG.md
ADDED
@@ -0,0 +1,14 @@
|
|
1
|
+
# Changelog
|
2
|
+
|
3
|
+
All notable changes to this project will be documented in this file.
|
4
|
+
|
5
|
+
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
|
6
|
+
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
|
7
|
+
|
8
|
+
## [Unreleased]
|
9
|
+
|
10
|
+
- ...
|
11
|
+
|
12
|
+
## [0.1.0] - YYYY-MM-DD
|
13
|
+
|
14
|
+
- First version
|
data/Gemfile
ADDED
@@ -0,0 +1,16 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
source "https://rubygems.org"
|
4
|
+
gemspec
|
5
|
+
|
6
|
+
gem "bridgetown", ENV["BRIDGETOWN_VERSION"] if ENV["BRIDGETOWN_VERSION"]
|
7
|
+
|
8
|
+
group :test do
|
9
|
+
gem "minitest"
|
10
|
+
gem "minitest-profile"
|
11
|
+
gem "minitest-reporters"
|
12
|
+
end
|
13
|
+
|
14
|
+
group :development do
|
15
|
+
gem "standard"
|
16
|
+
end
|
data/LICENSE.txt
ADDED
@@ -0,0 +1,22 @@
|
|
1
|
+
The MIT License (MIT)
|
2
|
+
|
3
|
+
Copyright (c) 2020-present
|
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,61 @@
|
|
1
|
+
# Bridgetown Obsidian Plugin
|
2
|
+
|
3
|
+
A Bridgetown plugin to convert Obsidian notes to Bridgetown posts.
|
4
|
+
|
5
|
+
This plugin allows you to use Obsidian's [internal links](https://help.obsidian.md/Linking+notes+and+files/Internal+links) feature to cross reference your Bridgetown posts and [embed images](https://help.obsidian.md/Linking+notes+and+files/Embedding+files). It replaces all the wikilinks references in `src/_posts` with Bridgetown compatible versions:
|
6
|
+
|
7
|
+
1. Converts wikilinks from `[[My Markdown Post]]` to `<a href="/my-markdown post/">My Markdown Post</a>`
|
8
|
+
2. Supports optional link titles such as `[[My Markdown Post|with an optional title]]`
|
9
|
+
3. Converts image references from `![[attachments/image.jpg]]` to `<img src="/attachments/bridge.jpg" alt="" />`
|
10
|
+
|
11
|
+
## Installation
|
12
|
+
|
13
|
+
Run this command to add this plugin to your site's Gemfile:
|
14
|
+
|
15
|
+
```shell
|
16
|
+
bundle add bridgetown_obsidian
|
17
|
+
```
|
18
|
+
|
19
|
+
Then add the initializer to your configuration in `config/initializers.rb`:
|
20
|
+
|
21
|
+
```ruby
|
22
|
+
init :bridgetown_obsidian
|
23
|
+
```
|
24
|
+
|
25
|
+
### Obsidian Setup
|
26
|
+
|
27
|
+
There are two main ways you can use this plugin with obsidian.
|
28
|
+
|
29
|
+
1. Create a new vault that points to your `src/_posts` folder in Bridgetown. In this case you might want to add `.obsidian` to your `.gitignore` file.
|
30
|
+
|
31
|
+
2. Create an symbolink link in your existing vault to your Bridgetown folder. This option is [strongly advised against](https://help.obsidian.md/Files+and+folders/Symbolic+links+and+junctions) by Obsidian so use at your own risk.
|
32
|
+
|
33
|
+
```shell
|
34
|
+
ln -s /path/to/bridgetown/folder/src/_posts "My Blog"
|
35
|
+
```
|
36
|
+
|
37
|
+
In either case, turn on `Use [[Wikilinks]]` option in [Files & Links settings](https://help.obsidian.md/Linking+notes+and+files/Internal+links).
|
38
|
+
|
39
|
+
## Usage
|
40
|
+
|
41
|
+
Edit your posts in Obsidian. If you have a Bridgetown server running, you can see your changes in real-time. If not, your changes will get reflected the next time you build your site.
|
42
|
+
|
43
|
+
## Testing
|
44
|
+
|
45
|
+
- Run `bundle exec rake test` to run the test suite.
|
46
|
+
|
47
|
+
## Credits
|
48
|
+
|
49
|
+
Check out these other great plugins that helped to inspire this one:
|
50
|
+
|
51
|
+
- https://github.com/SpinalCMS/bridgetown-internal-markdown-links
|
52
|
+
- https://github.com/jamie/bridgetown-notable
|
53
|
+
|
54
|
+
## Contributing
|
55
|
+
|
56
|
+
1. Fork it (https://github.com/username/my-awesome-plugin/fork)
|
57
|
+
2. Clone the fork using `git clone` to your local development machine.
|
58
|
+
3. Create your feature branch (`git checkout -b my-new-feature`)
|
59
|
+
4. Commit your changes (`git commit -am 'Add some feature'`)
|
60
|
+
5. Push to the branch (`git push origin my-new-feature`)
|
61
|
+
6. Create a new Pull Request
|
data/Rakefile
ADDED
@@ -0,0 +1,51 @@
|
|
1
|
+
# If your plugin requires a lot of steps to get set up, consider writing an automation to help guide users.
|
2
|
+
# You could set up and configure all sorts of things, for example:
|
3
|
+
#
|
4
|
+
# add_gem("my_plugin")
|
5
|
+
#
|
6
|
+
# add_yarn_for_gem("my_plugin")
|
7
|
+
#
|
8
|
+
# add_initializer :"my_plugin" do
|
9
|
+
# <<~RUBY
|
10
|
+
# do
|
11
|
+
# some_config_key 12345
|
12
|
+
# end
|
13
|
+
# RUBY
|
14
|
+
# end
|
15
|
+
#
|
16
|
+
# create_builder "my_nifty_builder.rb" do
|
17
|
+
# <<~RUBY
|
18
|
+
# class MyNeatBuilder < SiteBuilder
|
19
|
+
# def build
|
20
|
+
# puts MyPlugin.hello
|
21
|
+
# end
|
22
|
+
# end
|
23
|
+
# RUBY
|
24
|
+
# end
|
25
|
+
#
|
26
|
+
# javascript_import do
|
27
|
+
# <<~JS
|
28
|
+
# import { MyPlugin } from "my_plugin"
|
29
|
+
# JS
|
30
|
+
# end
|
31
|
+
#
|
32
|
+
# javascript_import 'import "my_plugin/frontend/styles/index.css"'
|
33
|
+
#
|
34
|
+
# create_file "src/_data/plugin_data.yml" do
|
35
|
+
# <<~YAML
|
36
|
+
# data:
|
37
|
+
# goes: here
|
38
|
+
# YAML
|
39
|
+
# end
|
40
|
+
#
|
41
|
+
# color = ask("What's your favorite color?")
|
42
|
+
#
|
43
|
+
# append_to_file "bridgetown.config.yml" do
|
44
|
+
# <<~YAML
|
45
|
+
#
|
46
|
+
# my_plugin:
|
47
|
+
# favorite_color: #{color}
|
48
|
+
# YAML
|
49
|
+
# end
|
50
|
+
#
|
51
|
+
# Read the Automations documentation: https://www.bridgetownrb.com/docs/automations
|
@@ -0,0 +1,24 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require_relative "lib/bridgetown_obsidian/version"
|
4
|
+
|
5
|
+
Gem::Specification.new do |spec|
|
6
|
+
spec.name = "bridgetown_obsidian"
|
7
|
+
spec.version = BridgetownObsidian::VERSION
|
8
|
+
spec.author = "Onur Ozer"
|
9
|
+
spec.email = "onur@simplematters.dev"
|
10
|
+
spec.summary = "Converts Obsidian notes to Bridgetown posts"
|
11
|
+
spec.homepage = "https://github.com/onurozer/bridgetown_obsidian"
|
12
|
+
spec.license = "MIT"
|
13
|
+
|
14
|
+
spec.files = `git ls-files -z`.split("\x0").reject { |f| f.match(%r{^(test|script|spec|features|frontend)/}) }
|
15
|
+
spec.require_paths = ["lib"]
|
16
|
+
|
17
|
+
spec.required_ruby_version = ">= 2.7.0"
|
18
|
+
|
19
|
+
spec.add_dependency "bridgetown", ">= 1.2.0", "< 2.0"
|
20
|
+
|
21
|
+
spec.add_development_dependency "bundler"
|
22
|
+
spec.add_development_dependency "rake", ">= 13.0"
|
23
|
+
spec.add_development_dependency "rubocop-bridgetown", "~> 0.3"
|
24
|
+
end
|
@@ -0,0 +1,42 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module BridgetownObsidian
|
4
|
+
class Builder < Bridgetown::Builder
|
5
|
+
REGEX_WIKILINK = /(?<!!)\[\[([^\]]+?)(?:\|([^\]]+))?\]\]/
|
6
|
+
REGEX_IMAGES = /!\[\[(.+?)\]\]/
|
7
|
+
|
8
|
+
def build
|
9
|
+
generator :wikilinks
|
10
|
+
generator :images
|
11
|
+
end
|
12
|
+
|
13
|
+
def wikilinks
|
14
|
+
resources.each do |post|
|
15
|
+
post.content.gsub!(REGEX_WIKILINK) do |match|
|
16
|
+
wikilink = Regexp.last_match(1)
|
17
|
+
wikilink_title = Regexp.last_match(2) || wikilink
|
18
|
+
"[#{wikilink_title}](#{url_for("_posts/#{wikilink}.md")})"
|
19
|
+
end
|
20
|
+
end
|
21
|
+
end
|
22
|
+
|
23
|
+
def images
|
24
|
+
resources.each do |post|
|
25
|
+
post.content.gsub!(REGEX_IMAGES) do |match|
|
26
|
+
image = Regexp.last_match(1)
|
27
|
+
""
|
28
|
+
end
|
29
|
+
end
|
30
|
+
end
|
31
|
+
|
32
|
+
private
|
33
|
+
|
34
|
+
def resources
|
35
|
+
site.collections.posts.resources
|
36
|
+
end
|
37
|
+
|
38
|
+
def url_for(url)
|
39
|
+
Bridgetown::RubyTemplateView::Helpers.new(resource, site).url_for(url)
|
40
|
+
end
|
41
|
+
end
|
42
|
+
end
|
@@ -0,0 +1,26 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require "bridgetown"
|
4
|
+
require "bridgetown_obsidian/builder"
|
5
|
+
|
6
|
+
# @param config [Bridgetown::Configuration::ConfigurationDSL]
|
7
|
+
Bridgetown.initializer :bridgetown_obsidian do |config|
|
8
|
+
# Add code here which will run when a site includes
|
9
|
+
# `init :bridgetown_obsidian`
|
10
|
+
# in its configuration
|
11
|
+
|
12
|
+
# Add default configuration data:
|
13
|
+
config.bridgetown_obsidian ||= {}
|
14
|
+
# config.bridgetown_obsidian.collections ||= ['_posts']
|
15
|
+
|
16
|
+
# Register your builder:
|
17
|
+
config.builder BridgetownObsidian::Builder
|
18
|
+
|
19
|
+
# You can optionally supply a source manifest:
|
20
|
+
# config.source_manifest(
|
21
|
+
# origin: BridgetownObsidian,
|
22
|
+
# components: File.expand_path("../components", __dir__),
|
23
|
+
# layouts: File.expand_path("../layouts", __dir__),
|
24
|
+
# content: File.expand_path("../content", __dir__)
|
25
|
+
# )
|
26
|
+
end
|
metadata
ADDED
@@ -0,0 +1,116 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: bridgetown_obsidian
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.1.0
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Onur Ozer
|
8
|
+
autorequire:
|
9
|
+
bindir: bin
|
10
|
+
cert_chain: []
|
11
|
+
date: 2023-12-01 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: 1.2.0
|
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: 1.2.0
|
30
|
+
- - "<"
|
31
|
+
- !ruby/object:Gem::Version
|
32
|
+
version: '2.0'
|
33
|
+
- !ruby/object:Gem::Dependency
|
34
|
+
name: bundler
|
35
|
+
requirement: !ruby/object:Gem::Requirement
|
36
|
+
requirements:
|
37
|
+
- - ">="
|
38
|
+
- !ruby/object:Gem::Version
|
39
|
+
version: '0'
|
40
|
+
type: :development
|
41
|
+
prerelease: false
|
42
|
+
version_requirements: !ruby/object:Gem::Requirement
|
43
|
+
requirements:
|
44
|
+
- - ">="
|
45
|
+
- !ruby/object:Gem::Version
|
46
|
+
version: '0'
|
47
|
+
- !ruby/object:Gem::Dependency
|
48
|
+
name: rake
|
49
|
+
requirement: !ruby/object:Gem::Requirement
|
50
|
+
requirements:
|
51
|
+
- - ">="
|
52
|
+
- !ruby/object:Gem::Version
|
53
|
+
version: '13.0'
|
54
|
+
type: :development
|
55
|
+
prerelease: false
|
56
|
+
version_requirements: !ruby/object:Gem::Requirement
|
57
|
+
requirements:
|
58
|
+
- - ">="
|
59
|
+
- !ruby/object:Gem::Version
|
60
|
+
version: '13.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.3'
|
68
|
+
type: :development
|
69
|
+
prerelease: false
|
70
|
+
version_requirements: !ruby/object:Gem::Requirement
|
71
|
+
requirements:
|
72
|
+
- - "~>"
|
73
|
+
- !ruby/object:Gem::Version
|
74
|
+
version: '0.3'
|
75
|
+
description:
|
76
|
+
email: onur@simplematters.dev
|
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.automation.rb
|
89
|
+
- bridgetown_obsidian.gemspec
|
90
|
+
- lib/bridgetown_obsidian.rb
|
91
|
+
- lib/bridgetown_obsidian/builder.rb
|
92
|
+
- lib/bridgetown_obsidian/version.rb
|
93
|
+
homepage: https://github.com/onurozer/bridgetown_obsidian
|
94
|
+
licenses:
|
95
|
+
- MIT
|
96
|
+
metadata: {}
|
97
|
+
post_install_message:
|
98
|
+
rdoc_options: []
|
99
|
+
require_paths:
|
100
|
+
- lib
|
101
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
102
|
+
requirements:
|
103
|
+
- - ">="
|
104
|
+
- !ruby/object:Gem::Version
|
105
|
+
version: 2.7.0
|
106
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
107
|
+
requirements:
|
108
|
+
- - ">="
|
109
|
+
- !ruby/object:Gem::Version
|
110
|
+
version: '0'
|
111
|
+
requirements: []
|
112
|
+
rubygems_version: 3.4.22
|
113
|
+
signing_key:
|
114
|
+
specification_version: 4
|
115
|
+
summary: Converts Obsidian notes to Bridgetown posts
|
116
|
+
test_files: []
|