इस प्रश्न के दो अर्थपूर्ण हल हैं:
- एक प्लगइन का उपयोग करना
- एक कस्टम बनाना शामिल है
1. एक प्लगइन का उपयोग करना
मैंने कुछ प्लग इन करने की कोशिश की है और मेरा पसंदीदा हैjekyll-figure
।
1.1। इंस्टॉलjekyll-figure
एक तरह से स्थापित करने के लिए jekyll-figure
जोड़ने के लिए है gem "jekyll-figure"
अपने प्लग-इन समूह में अपने Gemfile करने के लिए।
फिर bundle install
अपनी टर्मिनल विंडो से चलाएं ।
1.2। उपयोगjekyll-figure
सीधे शब्दों में अपनी markdown लपेट {% figure %}
और {% endfigure %}
टैग।
आप ओपनिंग {% figure %}
टैग में कैप्शन देते हैं , और आप इसे मार्कडाउन के साथ भी स्टाइल कर सकते हैं!
उदाहरण:
{% figure caption:"Le logo de **Jekyll** et son clin d'oeil à Robert Louis Stevenson" %}
![Le logo de Jekyll](/assets/images/2018-08-07-jekyll-logo.png)
{% endfigure %}
1.3। इसे स्टाइल करें
अब जब आपकी छवियां और कैप्शन शब्दबद्ध रूप से सही हैं, तो आप सीएसएस को अपनी इच्छानुसार लागू कर सकते हैं:
figure
(छवि और कैप्शन दोनों के लिए)
figure img
(केवल छवि के लिए)
figcaption
(केवल कैप्शन के लिए)
2. एक कस्टम बनाना शामिल है
आपको अपने फ़ोल्डर में एक image.html
फ़ाइल बनाने_includes
की आवश्यकता होगी , और इसे मार्कडाउन में तरल का उपयोग करके शामिल करें ।
2.1। _Includes / image.html बनाएँ
image.html
अपने _includes फ़ोल्डर में दस्तावेज़ बनाएं :
<!-- _includes/image.html -->
<figure>
{% if include.url %}
<a href="{{ include.url }}">
{% endif %}
<img
{% if include.srcabs %}
src="{{ include.srcabs }}"
{% else %}
src="{{ site.baseurl }}/assets/images/{{ include.src }}"
{% endif %}
alt="{{ include.alt }}">
{% if include.url %}
</a>
{% endif %}
{% if include.caption %}
<figcaption>{{ include.caption }}</figcaption>
{% endif %}
</figure>
2.2। मार्कडाउन में, लिक्विड का उपयोग करके एक छवि शामिल करें
/assets/images
कैप्शन के साथ एक छवि :
This is [Jekyll](https://jekyllrb.com)'s logo :
{% include image.html
src="jekyll-logo.png" <!-- image filename (placed in /assets/images) -->
alt="Jekyll's logo" <!-- alt text -->
caption="This is Jekyll's logo, featuring Dr. Jekyll's serum!" <!-- Caption -->
%}
एक (बाह्य) छवि एक निरपेक्ष URL का उपयोग: (परिवर्तन src=""
करने के लिए srcabs=""
)
This is [Jekyll](https://jekyllrb.com)'s logo :
{% include image.html
srcabs="https://jekyllrb.com/img/logo-2x.png" <!-- absolute URL to image file -->
alt="Jekyll's logo" <!-- alt text -->
caption="This is Jekyll's logo, featuring Dr. Jekyll's serum!" <!-- Caption -->
%}
एक क्लिक करने योग्य छवि: ( url=""
तर्क जोड़ें )
This is [Jekyll](https://jekyllrb.com)'s logo :
{% include image.html
src="https://jekyllrb.com/img/logo-2x.png" <!-- absolute URL to image file -->
url="https://jekyllrb.com" <!-- destination url -->
alt="Jekyll's logo" <!-- alt text -->
caption="This is Jekyll's logo, featuring Dr. Jekyll's serum!" <!-- Caption -->
%}
कैप्शन के बिना एक छवि:
This is [Jekyll](https://jekyllrb.com)'s logo :
{% include image.html
src="https://jekyllrb.com/img/logo-2x.png" <!-- absolute URL to image file -->
alt="Jekyll's logo" <!-- alt text -->
%}
2.3। इसे स्टाइल करें
अब जब आपकी छवियां और कैप्शन शब्दबद्ध रूप से सही हैं, तो आप सीएसएस को अपनी इच्छानुसार लागू कर सकते हैं:
figure
(छवि और कैप्शन दोनों के लिए)
figure img
(केवल छवि के लिए)
figcaption
(केवल कैप्शन के लिए)
site_root
एक वैध चर के रूप में स्वीकार नहीं किया जाता है। जब इसे प्रस्तुत किया जाता है तो यह समाप्त हो जाता हैsrc="{{ site.url_root }}...
।