Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/gouravkhunger/jekyll-hostname
A liquid filter for Jekyll to extract the hostname from a URL
https://github.com/gouravkhunger/jekyll-hostname
hacktoberfest jekyll jekyll-plugin ruby
Last synced: about 1 month ago
JSON representation
A liquid filter for Jekyll to extract the hostname from a URL
- Host: GitHub
- URL: https://github.com/gouravkhunger/jekyll-hostname
- Owner: gouravkhunger
- License: mit
- Created: 2021-12-26T08:11:10.000Z (about 3 years ago)
- Default Branch: main
- Last Pushed: 2024-10-31T03:39:09.000Z (2 months ago)
- Last Synced: 2024-11-15T07:58:14.463Z (about 2 months ago)
- Topics: hacktoberfest, jekyll, jekyll-plugin, ruby
- Language: Ruby
- Homepage: http://hostname.gourav.sh/
- Size: 51.8 KB
- Stars: 3
- Watchers: 0
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE.md
Awesome Lists containing this project
README
# Jekyll::Hostname
[![Gem Version](https://img.shields.io/gem/v/jekyll-hostname)][ruby-gems]
[![Gem Total Downloads](https://img.shields.io/gem/dt/jekyll-hostname)][ruby-gems][ruby-gems]: https://rubygems.org/gems/jekyll-hostname
A jekyll plugin to grab the hostnames from a URL, meaning
- `https://google.com` becomes `google.com`
- `http://github.com` becomes `github.com`
- `https://github.com/gouravkhunger/jekyll-hostname` becomes `github.com`This gem was originally authored to be used as a custom plugin for the [static site](https://github.com/genicsblog/genicsblog.github.io) of [genicsblog.com](https://genicsblog.com)
## Installation
Add this line to your application's Gemfile inside the `jekyll_plugins` group:
```ruby
group :jekyll_plugins do
# other gems
gem "jekyll-hostname"
end
```Then, enable the plugin by adding it to the `plugins` section in the `_config.yml` file:
```yaml
plugins:
# - other plugins
- jekyll-hostname
```And then execute:
```shell
bundle install
```## Usage
This plugin is essentially a filter and works on any [valid URL string](https://en.wikipedia.org/wiki/URL#Syntax) provided inside a liquid tag. Use it as below:
```liquid
{% assign host = site.url | hostname %}
{% assign domain = post.source | hostname %}
```The `hostname` filter extracts the root domain from the given url string(here `site.url` or `page.source`)
## License
The gem is available as open source under the terms of the [MIT License](https://opensource.org/licenses/MIT).
```
MIT LicenseCopyright (c) 2021 Gourav Khunger
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
```