jekyll-strapi-4 1.0.1 → 1.0.7
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +39 -4
- data/lib/jekyll/{strapi → strapi4}/collection.rb +4 -0
- data/lib/jekyll/strapi4/collection_permalink.rb +38 -0
- data/lib/jekyll/{strapi → strapi4}/drops.rb +0 -0
- data/lib/jekyll/{strapi → strapi4}/generator.rb +20 -4
- data/lib/jekyll/{strapi → strapi4}/hooks.rb +0 -0
- data/lib/jekyll/{strapi → strapi4}/site.rb +11 -1
- data/lib/jekyll/{strapi → strapi4}/strapihttp.rb +0 -0
- data/lib/jekyll/{strapi → strapi4}/version.rb +1 -1
- data/lib/jekyll-strapi-4.rb +9 -0
- metadata +11 -10
- data/lib/jekyll-strapi.rb +0 -8
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 890a4e54e493d7dad0427c788818ff0cc0910cbab5a1a3b78e552186ca2a9a22
|
4
|
+
data.tar.gz: b1d97a5db3865c4f07f1f190efd46babde09dd0af0ba55980b5e631939bbaeaf
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: bcd4f926386f979f6753abdffaca1ca070dd9d1eb79c246699aae169b6cf97e1742bfb9e1ec7c5329b6ad3c38448625be6834849590616d351bcf4017362127c
|
7
|
+
data.tar.gz: f3d93f08761299ea162dd7dcc72ba4e5488a18253ba78203ea842f9add1dd3be3be23746cb63259d61e640807e78b9e1a808ccfde541871f058e61bfb20227e3
|
data/README.md
CHANGED
@@ -2,6 +2,12 @@
|
|
2
2
|
|
3
3
|
This plugin is based on the [jekyll-strapi](https://github.com/strapi-community/jekyll-strapi/) plugin.
|
4
4
|
|
5
|
+
![](deer-jekyll-strapi-4.png?raw=true)
|
6
|
+
|
7
|
+
Q: Why the Deer for logo?
|
8
|
+
|
9
|
+
A: Every project deserves to have the cute deer as a logo.
|
10
|
+
|
5
11
|
## Features
|
6
12
|
|
7
13
|
* Support for Strapi 4
|
@@ -13,17 +19,17 @@ This plugin is based on the [jekyll-strapi](https://github.com/strapi-community/
|
|
13
19
|
|
14
20
|
## Install
|
15
21
|
|
16
|
-
Add the "jekyll-strapi" gem to your Gemfile:
|
22
|
+
Add the "jekyll-strapi-4" gem to your Gemfile:
|
17
23
|
|
18
24
|
```
|
19
|
-
gem "jekyll-strapi"
|
25
|
+
gem "jekyll-strapi-4"
|
20
26
|
```
|
21
27
|
|
22
|
-
Then add "jekyll-strapi" to your plugins in `_config.yml`:
|
28
|
+
Then add "jekyll-strapi-4" to your plugins in `_config.yml`:
|
23
29
|
|
24
30
|
```
|
25
31
|
plugins:
|
26
|
-
- jekyll-strapi
|
32
|
+
- jekyll-strapi-4
|
27
33
|
```
|
28
34
|
|
29
35
|
## Configuration
|
@@ -41,6 +47,9 @@ strapi:
|
|
41
47
|
# type: photos
|
42
48
|
# Permalink used to generate the output files (eg. /articles/:id).
|
43
49
|
permalink: /photos/:id/
|
50
|
+
# Permalinks defined for different locales
|
51
|
+
permalinks:
|
52
|
+
pl: "/zdjecia/:id"
|
44
53
|
# Parameters (optional)
|
45
54
|
parameters:
|
46
55
|
sort: title:asc
|
@@ -130,3 +139,29 @@ module Jekyll
|
|
130
139
|
end
|
131
140
|
end
|
132
141
|
```
|
142
|
+
|
143
|
+
### Permalinks
|
144
|
+
|
145
|
+
When you have a multi-language content, you might want generate a proper url based on different patterns, for example:
|
146
|
+
| Language | permalink pattern | example |
|
147
|
+
| ----------- | ----------- | - |
|
148
|
+
| en | /image/:slug |yourdomain.com/image/orange/ |
|
149
|
+
| es | /imagen/:slug | yourdomain.com/imagen/naranja/ |
|
150
|
+
| pl | /zdjecie/:slug | yourdomain.com/zdjecie/pomarancza/ |
|
151
|
+
|
152
|
+
In that case you have to
|
153
|
+
1. set locales [on request parameters](#request-parameters),
|
154
|
+
2. set permalinks patterns [on _config.yml](#configuration).
|
155
|
+
|
156
|
+
When you create permalinks, set default permalink and optionals permalinks.
|
157
|
+
|
158
|
+
```yaml
|
159
|
+
strapi:
|
160
|
+
collections:
|
161
|
+
photos:
|
162
|
+
permalink: /image/:slug/
|
163
|
+
permalinks:
|
164
|
+
es: /imagen/:slug
|
165
|
+
pl: /zdjecia/:slug
|
166
|
+
|
167
|
+
```
|
@@ -0,0 +1,38 @@
|
|
1
|
+
module Jekyll
|
2
|
+
module Strapi
|
3
|
+
class StrapiCollectionPermalink
|
4
|
+
attr_reader :collection, :lang
|
5
|
+
|
6
|
+
def initialize(collection:, lang: nil)
|
7
|
+
@collection = collection
|
8
|
+
@lang = lang
|
9
|
+
end
|
10
|
+
|
11
|
+
def directory
|
12
|
+
use_different? ? permalinks[lang].split("/")[1] : collection.collection_name
|
13
|
+
end
|
14
|
+
|
15
|
+
def exist?
|
16
|
+
config.key? 'permalink'
|
17
|
+
end
|
18
|
+
|
19
|
+
def to_s
|
20
|
+
use_different? ? permalinks[lang] : config['permalink']
|
21
|
+
end
|
22
|
+
|
23
|
+
private
|
24
|
+
|
25
|
+
def config
|
26
|
+
collection.config
|
27
|
+
end
|
28
|
+
|
29
|
+
def permalinks
|
30
|
+
config['permalinks']
|
31
|
+
end
|
32
|
+
|
33
|
+
def use_different?
|
34
|
+
permalinks && permalinks[lang]
|
35
|
+
end
|
36
|
+
end
|
37
|
+
end
|
38
|
+
end
|
File without changes
|
@@ -22,15 +22,31 @@ module Jekyll
|
|
22
22
|
@collection = collection
|
23
23
|
@document = document
|
24
24
|
|
25
|
-
@
|
25
|
+
@site.lang = @document.attributes.locale
|
26
|
+
|
27
|
+
@dir = @collection.config['output_dir'] || collection.permalink.directory
|
28
|
+
|
29
|
+
url = Jekyll::URL.new(
|
30
|
+
:placeholders => {
|
31
|
+
:id => document.id.to_s,
|
32
|
+
:uid => document.uid,
|
33
|
+
:slug => document.attributes.slug,
|
34
|
+
:type => document.attributes.type,
|
35
|
+
:date => document.attributes.date,
|
36
|
+
:title => document.title
|
37
|
+
},
|
38
|
+
permalink: collection.permalink.to_s
|
39
|
+
)
|
40
|
+
|
26
41
|
# Default file name, can be overwritten by permalink frontmatter setting
|
27
|
-
|
42
|
+
file_name = url.to_s.split("/").last
|
43
|
+
@name = "#{file_name}.html"
|
28
44
|
# filename_to_read = File.join(base, "_layouts"), @collection.config['layout']
|
29
45
|
|
30
46
|
self.process(@name)
|
31
47
|
self.read_yaml(File.join(base, "_layouts"), @collection.config['layout'])
|
32
|
-
if @collection.
|
33
|
-
self.data['permalink'] = @collection.
|
48
|
+
if @collection.permalink.exist?
|
49
|
+
self.data['permalink'] = @collection.permalink.to_s
|
34
50
|
end
|
35
51
|
|
36
52
|
self.data['document'] = StrapiDocumentDrop.new(@document)
|
File without changes
|
@@ -1,6 +1,8 @@
|
|
1
1
|
module Jekyll
|
2
2
|
# Add helper methods for dealing with Strapi to the Site class
|
3
3
|
class Site
|
4
|
+
attr_accessor :lang
|
5
|
+
|
4
6
|
def strapi
|
5
7
|
return nil unless has_strapi?
|
6
8
|
end
|
@@ -25,7 +27,7 @@ module Jekyll
|
|
25
27
|
def strapi_link_resolver(collection = nil, document = nil)
|
26
28
|
return "/" unless collection != nil and @config['strapi']['collections'][collection]['permalink'] != nil
|
27
29
|
url = Jekyll::URL.new(
|
28
|
-
:template =>
|
30
|
+
:template => url_template(collection),
|
29
31
|
:placeholders => {
|
30
32
|
:id => document.id.to_s,
|
31
33
|
:uid => document.uid,
|
@@ -42,5 +44,13 @@ module Jekyll
|
|
42
44
|
def strapi_collection(collection_name)
|
43
45
|
strapi_collections[collection_name]
|
44
46
|
end
|
47
|
+
|
48
|
+
def url_template(collection)
|
49
|
+
permalink = @config['strapi']['collections'][collection]['permalink']
|
50
|
+
permalinks = @config['strapi']['collections'][collection]['permalinks']
|
51
|
+
|
52
|
+
return permalink unless permalinks && permalinks[lang]
|
53
|
+
"/#{lang}#{permalinks[lang]}"
|
54
|
+
end
|
45
55
|
end
|
46
56
|
end
|
File without changes
|
@@ -0,0 +1,9 @@
|
|
1
|
+
require 'jekyll/strapi4/strapihttp'
|
2
|
+
require 'jekyll/strapi4/collection_permalink'
|
3
|
+
require 'jekyll/strapi4/collection'
|
4
|
+
require 'jekyll/strapi4/drops'
|
5
|
+
require 'jekyll/strapi4/generator'
|
6
|
+
require 'jekyll/strapi4/hooks'
|
7
|
+
require 'jekyll/strapi4/site'
|
8
|
+
require 'jekyll/strapi4/version'
|
9
|
+
require 'jekyll/tags/strapiimagefilter'
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: jekyll-strapi-4
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.0.
|
4
|
+
version: 1.0.7
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Strapi Solutions
|
@@ -10,7 +10,7 @@ authors:
|
|
10
10
|
autorequire:
|
11
11
|
bindir: bin
|
12
12
|
cert_chain: []
|
13
|
-
date: 2022-07-
|
13
|
+
date: 2022-07-29 00:00:00.000000000 Z
|
14
14
|
dependencies:
|
15
15
|
- !ruby/object:Gem::Dependency
|
16
16
|
name: down
|
@@ -77,14 +77,15 @@ extra_rdoc_files: []
|
|
77
77
|
files:
|
78
78
|
- LICENSE
|
79
79
|
- README.md
|
80
|
-
- lib/jekyll-strapi.rb
|
81
|
-
- lib/jekyll/
|
82
|
-
- lib/jekyll/
|
83
|
-
- lib/jekyll/
|
84
|
-
- lib/jekyll/
|
85
|
-
- lib/jekyll/
|
86
|
-
- lib/jekyll/
|
87
|
-
- lib/jekyll/
|
80
|
+
- lib/jekyll-strapi-4.rb
|
81
|
+
- lib/jekyll/strapi4/collection.rb
|
82
|
+
- lib/jekyll/strapi4/collection_permalink.rb
|
83
|
+
- lib/jekyll/strapi4/drops.rb
|
84
|
+
- lib/jekyll/strapi4/generator.rb
|
85
|
+
- lib/jekyll/strapi4/hooks.rb
|
86
|
+
- lib/jekyll/strapi4/site.rb
|
87
|
+
- lib/jekyll/strapi4/strapihttp.rb
|
88
|
+
- lib/jekyll/strapi4/version.rb
|
88
89
|
- lib/jekyll/tags/strapiimagefilter.rb
|
89
90
|
homepage: https://github.com/bluszcz/jekyll-strapi-4
|
90
91
|
licenses:
|
data/lib/jekyll-strapi.rb
DELETED
@@ -1,8 +0,0 @@
|
|
1
|
-
require 'jekyll/strapi/strapihttp'
|
2
|
-
require 'jekyll/strapi/collection'
|
3
|
-
require 'jekyll/strapi/drops'
|
4
|
-
require 'jekyll/strapi/generator'
|
5
|
-
require 'jekyll/strapi/hooks'
|
6
|
-
require 'jekyll/strapi/site'
|
7
|
-
require 'jekyll/strapi/version'
|
8
|
-
require 'jekyll/tags/strapiimagefilter'
|