pax_global_header00006660000000000000000000000064137427774110014527gustar00rootroot0000000000000052 comment=df294bb4911979722b00df12d9c6c0aa700b2cd9 jekyll-seo-tag-2.7.1/000077500000000000000000000000001374277741100143655ustar00rootroot00000000000000jekyll-seo-tag-2.7.1/.github/000077500000000000000000000000001374277741100157255ustar00rootroot00000000000000jekyll-seo-tag-2.7.1/.github/workflows/000077500000000000000000000000001374277741100177625ustar00rootroot00000000000000jekyll-seo-tag-2.7.1/.github/workflows/actions/000077500000000000000000000000001374277741100214225ustar00rootroot00000000000000jekyll-seo-tag-2.7.1/.github/workflows/actions/memprof.rb000066400000000000000000000006751374277741100234240ustar00rootroot00000000000000# frozen_string_literal: true require 'jekyll' require 'memory_profiler' MemoryProfiler.report(allow_files: 'lib/jekyll-seo-tag') do Jekyll::PluginManager.require_from_bundler Jekyll::Commands::Build.process({ "source" => File.expand_path(ARGV[0]), "destination" => File.expand_path("#{ARGV[0]}/_site"), "disable_disk_cache" => true, }) puts '' end.pretty_print(scale_bytes: true, normalize_paths: true) jekyll-seo-tag-2.7.1/.github/workflows/third-party.yml000066400000000000000000000040451374277741100227570ustar00rootroot00000000000000name: Third-Party Repository Profiling on: push: branches: - master pull_request: branches: - master jobs: build_n_profile: if: "!contains(github.event.commits[0].message, '[ci skip]')" runs-on: 'ubuntu-latest' steps: - name: Checkout Jekyll SEO Tag uses: actions/checkout@v2 with: fetch-depth: 5 path: jekyll-seo-tag - name: Checkout Third-Party Repository (WITHOUT SEO Tag) uses: actions/checkout@v2 with: repository: ashmaroli/tomjoht.github.io ref: 'no-seo-tag' path: alpha-sandbox - name: Checkout Same Third-Party Repository (WITH SEO Tag) uses: actions/checkout@v2 with: repository: ashmaroli/tomjoht.github.io ref: 'seo-tag' path: sandbox - name: Set up Ruby uses: actions/setup-ruby@v1 with: ruby-version: 2.6.x - name: Set up Dependencies Cache uses: actions/cache@v1 with: path: sandbox/vendor/bundle key: ubuntu-latest-gems- restore-keys: | ubuntu-latest-gems- - name: Set up Dependencies run: | gem update --system --no-document gem update bundler --no-document bundle config gemfile sandbox/Gemfile bundle config path vendor/bundle bundle install --jobs 4 --retry 3 - name: Run Jekyll Build (WITHOUT SEO Tag) 3 times run: | bundle exec jekyll build -s alpha-sandbox -d alpha-sandbox/_site --trace bundle exec jekyll build -s alpha-sandbox -d alpha-sandbox/_site --trace bundle exec jekyll build -s alpha-sandbox -d alpha-sandbox/_site --trace - name: Run Jekyll Build (WITH SEO Tag) 3 times run: | bundle exec jekyll build -s sandbox -d sandbox/_site --trace bundle exec jekyll build -s sandbox -d sandbox/_site --trace bundle exec jekyll build -s sandbox -d sandbox/_site --trace - name: Memory Analysis of Jekyll Build (WITH SEO Tag) run: bundle exec ruby jekyll-seo-tag/.github/workflows/actions/memprof.rb sandbox jekyll-seo-tag-2.7.1/.gitignore000066400000000000000000000001441374277741100163540ustar00rootroot00000000000000*.gem .bundle .yardoc Gemfile.lock pkg spec/reports/ spec/fixtures/.jekyll-cache tmp/ vendor/bundle jekyll-seo-tag-2.7.1/.rspec000066400000000000000000000000361374277741100155010ustar00rootroot00000000000000--color --require spec_helper jekyll-seo-tag-2.7.1/.rubocop.yml000066400000000000000000000004421374277741100166370ustar00rootroot00000000000000inherit_from: .rubocop_todo.yml require: rubocop-jekyll inherit_gem: rubocop-jekyll: .rubocop.yml AllCops: TargetRubyVersion: 2.4 Exclude: - vendor/**/* Layout/LineLength: Exclude: - spec/**/* - jekyll-seo-tag.gemspec Metrics/BlockLength: Exclude: - spec/**/* jekyll-seo-tag-2.7.1/.rubocop_todo.yml000066400000000000000000000010241374277741100176610ustar00rootroot00000000000000# This configuration was generated by # `rubocop --auto-gen-config --auto-gen-only-exclude` # on 2020-03-20 11:41:46 +0100 using RuboCop version 0.80.1. # The point is for the user to remove these configuration records # one by one as the offenses are removed from the code base. # Note that changes in the inspected code, or installation of new # versions of RuboCop, may require this file to be generated again. # Offense count: 1 # Cop supports --auto-correct. Lint/ToJSON: Exclude: - 'lib/jekyll-seo-tag/json_ld_drop.rb' jekyll-seo-tag-2.7.1/.travis.yml000066400000000000000000000004131374277741100164740ustar00rootroot00000000000000language: ruby cache: bundler rvm: - 2.5 - 2.7 before_install: - gem update --system - gem install bundler script: script/cibuild env: global: - NOKOGIRI_USE_SYSTEM_LIBRARIES=true matrix: - JEKYLL_VERSION="~> 3.9" - JEKYLL_VERSION="~> 4.0" jekyll-seo-tag-2.7.1/Gemfile000066400000000000000000000003031374277741100156540ustar00rootroot00000000000000# frozen_string_literal: true source "https://rubygems.org" gemspec gem "jekyll", ENV["JEKYLL_VERSION"] if ENV["JEKYLL_VERSION"] gem "kramdown-parser-gfm" if ENV["JEKYLL_VERSION"] == "~> 3.9" jekyll-seo-tag-2.7.1/History.markdown000066400000000000000000000122451374277741100175760ustar00rootroot00000000000000## 2.7.1 / 2020-10-18 ### Development Fixes * refactor: mutate site payload instead of duplicating it (#419) ## 2.7.0 / 2020-10-18 ### Minor Enhancements * Change pagination message with `seo_paginator_message` option (#324) * Make Twitter Summary Card without having Twitter account (#284) * Prefer site.tagline to site.description for page title (#356) * Render og:locale meta only when defined explicitly (#388) ### Bug Fixes * Ensure a single leading `@` for twitter usernames (#367) ### Development Fixes * chore(deps): require Ruby > 2.4.0 EOL * test: fix locale specs that use the fallback locale (#360) * refactor: Replace read-only empty hash with private constant (#418) * refactor: Mutate hash literals instead of duplicating them (#417) * refactor: Reduce allocations of instance-agnostic objects (#376) * refactor: Memoize #author_hash in SeoTag::AuthorDrop (#342) * refactor: simplify conditional in SeoTag::Drop#date_modified (#343) * chore(ci): profile seo-tag plugin on a third-party repository (#414) * chore(ci): Jekyll v4.0 (#372) * chore(ci): test against current stable Ruby 2.5 and 2.7 (#385) * style: align with latest jekyll-rubocop (#382) * fix: Travis builds for Jekyll 3.x (#415) ### Documentation * Structured Data Testing Tool is deprecated (#409) * Rename Google webmaster tools to Google Search Console (#403) * Improve documentation on plugin usage (#399) * remove Google+ from example snippet (#358) * HTTPS link to https://ogp.me/ (#359) * HTTPS links to schema.org (#350) * use example.com for example URL (#351) ## 2.6.1 / 2019-05-17 ### Development Fixes * Test against Jekyll 4.x (#336) ## 2.6.0 / 2019-03-16 ### Minor Enhancements * Twitter Image and Title (#330) ### Bug Fixes * Do not cache the drop payload for SeoTag (#306) * Update url of schema website (#296) ### Development Fixes * Relax version constraint on Bundler (#325) * chore(ci): Add Ruby 2.6, drop Ruby 2.3 (#326) * chore (ci): remove deprecated `sudo: false` in .travis.yml (#333) * Lint Ruby code with rubocop-jekyll gem (#302) * chore(deps): bump rubocop-jekyll to v0.4 (#320) * chore(deps): bump rubocop-jekyll to v0.3 (#316) * Correct RuboCop offenses in spec files (#319) ### Documentation * Rectify error in Usage documentation (#328) ## 2.5.0 / 2018-05-18 * Docs: Prevent GitHub Pages from processing Liquid raw tag (#276) ### Documentation * Use gems config key for Jekyll < 3.5.0 (#255) * docs/usage - replace "below" with correct link (#280) ### Development Fixes * Test against Ruby 2.5 (#260) * add tests for twitter.card types (#289) * Target Ruby 2.3 and Rubocop 0.56.0 (#292) ### Minor Enhancements * Add webmaster_verifications for baidu (#263) * Include page number in title (#250) * Configure default Twitter summary card type (V2) (#225) ## 2.4.0 / 2017-12-04 ### Minor * Add meta generator (#236) * Consistently use self-closing tags (#246) * Strip null values from JSON-LD hash (#249) ### Documentation * Avoid deprecation warning when building docs (#243) ### Development Fixes * Test against latest Rubies (#242) * Use Nokigiri on CI (#181) ## 2.3.0 ### Minor Enhancements * Use canonical_url specified in page if present #211 * Fix for image.path causing an invalid url error #228 * Ensure `site.data.authors` is properly formatted before attempting to retrieve author meta #227 * Convert author, image, and JSON-LD to dedicated drops #229 * Cache parsed template #231 * Define path with `__dir__` #232 ### Documentation * gems: is deprecated in current Jekyll version of github-pages #230 ## 2.2.3 * Guard against the author's Twitter handle being Nil when stripping @'s #203 * Guard against empty title or description strings #206 ## 2.2.2 ### Minor Enhancements * Guard against arrays in subhashes #197 * Guard against invalid or missing URLs #199 ### Development fixes * Remove dynamic GitHub Pages logic from Gemfile #194 ## 2.2.1 * Convert template logic to a Liquid Drop (significant performance improvement) (#184) * Fix for JSON-LD validation warning for images missing required properties (#183) ## 2.2.0 ### Major Enhancements * Add author meta (#103) * Add og:locale support #166 * Add support for Bing and Yandex webmaster tools. Closes #147 (#148) * Add SEO author and date modified to validate JSON-LD output (#151) ### Minor Enhancements * Use `|` for title separator (#162) * Use `og:image` for twitter image (#174) ### Development Fixes * Style fixes (#170, #157, #149) * Test against latest version of Jekyll (#171) * Bump dev dependencies (#172) * Remove Rake dependency (#180) ## 2.1.0 ### Major Enhancement * Use new URL filters (#123) ### Minor Enhancements * Wraps logo image json data in a publisher property (#133) * Fix duplicated `escape_once` (#93) * Simplify minify regex (#125) * Don't mangle text with newlines #126 ### Documentation * Add front matter default example for image (#132) * Fix tiny typo (#106) * add example usage of social profiles (#139) ### Development * Inherit Jekyll's rubocop config for consistency (#109) * Correct spelling in .travis.yml (#112) jekyll-seo-tag-2.7.1/LICENSE.txt000066400000000000000000000021411374277741100162060ustar00rootroot00000000000000The MIT License (MIT) Copyright (c) 2015-present Ben Balter and the jekyll-seo-tag contributors 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. jekyll-seo-tag-2.7.1/docs/000077500000000000000000000000001374277741100153155ustar00rootroot00000000000000jekyll-seo-tag-2.7.1/docs/README.md000066400000000000000000000033111374277741100165720ustar00rootroot00000000000000## About Jekyll SEO Tag A Jekyll plugin to add metadata tags for search engines and social networks to better index and display your site's content. [![Gem Version](https://badge.fury.io/rb/jekyll-seo-tag.svg)](https://badge.fury.io/rb/jekyll-seo-tag) [![Build Status](https://travis-ci.org/jekyll/jekyll-seo-tag.svg)](https://travis-ci.org/jekyll/jekyll-seo-tag) ## What it does Jekyll SEO Tag adds the following meta tags to your site: * Page title, with site title or description appended * Page description * Canonical URL * Next and previous URLs on paginated pages * [JSON-LD Site and post metadata](https://developers.google.com/search/docs/guides/intro-structured-data) for richer indexing * [Open Graph](https://ogp.me/) title, description, site title, and URL (for Facebook, LinkedIn, etc.) * [Twitter Summary Card](https://dev.twitter.com/cards/overview) metadata While you could theoretically add the necessary metadata tags yourself, Jekyll SEO Tag provides a battle-tested template of crowdsourced best-practices. ## What it doesn't do Jekyll SEO tag is designed to output machine-readable metadata for search engines and social networks to index and display. If you're looking for something to analyze your Jekyll site's structure and content (e.g., more traditional SEO optimization), take a look at [The Jekyll SEO Gem](https://github.com/pmarsceill/jekyll-seo-gem). Jekyll SEO tag isn't designed to accommodate every possible use case. It should work for most site out of the box and without a laundry list of configuration options that serve only to confuse most users. ## Documentation For more information, see: * [Installation](installation.md) * [Usage](usage.md) * [Advanced usage](advanced-usage.md) jekyll-seo-tag-2.7.1/docs/_config.yml000066400000000000000000000003771374277741100174530ustar00rootroot00000000000000title: Jekyll SEO Tag description: A Jekyll plugin to add metadata tags for search engines and social networks to better index and display your site's content. permalink: pretty plugins: - jekyll-seo-tag - jekyll-sitemap theme: jekyll-theme-primer jekyll-seo-tag-2.7.1/docs/_layouts/000077500000000000000000000000001374277741100171545ustar00rootroot00000000000000jekyll-seo-tag-2.7.1/docs/_layouts/default.html000066400000000000000000000010521374277741100214640ustar00rootroot00000000000000 {% seo %}

{{ site.title }}

{{ content }}
jekyll-seo-tag-2.7.1/docs/advanced-usage.md000066400000000000000000000144261374277741100205150ustar00rootroot00000000000000## Advanced usage Jekyll SEO Tag is designed to implement SEO best practices by default and to be the right fit for most sites right out of the box. If for some reason, you need more control over the output, read on: ### Disabling `` output If for some reason, you don't want the plugin to output `<title>` tags on each page, simply invoke the plugin within your template like so: <!-- {% raw %} --> ``` {% seo title=false %} ``` <!-- {% endraw %} --> ### Author information Author information is used to propagate the `creator` field of Twitter summary cards. This should be an author-specific, not site-wide Twitter handle (the site-wide username be stored as `site.twitter.username`). *TL;DR: In most cases, put `author: [your Twitter handle]` in the document's front matter, for sites with multiple authors. If you need something more complicated, read on.* There are several ways to convey this author-specific information. Author information is found in the following order of priority: 1. An `author` object, in the documents's front matter, e.g.: ```yml author: twitter: benbalter ``` 2. An `author` object, in the site's `_config.yml`, e.g.: ```yml author: twitter: benbalter ``` 3. `site.data.authors[author]`, if an author is specified in the document's front matter, and a corresponding key exists in `site.data.authors`. E.g., you have the following in the document's front matter: ```yml author: benbalter ``` And you have the following in `_data/authors.yml`: ```yml benbalter: picture: /img/benbalter.png twitter: jekyllrb potus: picture: /img/potus.png twitter: whitehouse ``` In the above example, the author `benbalter`'s Twitter handle will be resolved to `@jekyllrb`. This allows you to centralize author information in a single `_data/authors` file for site with many authors that require more than just the author's username. *Pro-tip: If `authors` is present in the document's front matter as an array (and `author` is not), the plugin will use the first author listed, as Twitter supports only one author.* 4. An author in the document's front matter (the simplest way), e.g.: ```yml author: benbalter ``` 5. An author in the site's `_config.yml`, e.g.: ```yml author: benbalter ``` ### Customizing JSON-LD output The following options can be set for any particular page. While the default options are meant to serve most users in the most common circumstances, there may be situations where more precise control is necessary. * `seo` * `name` - If the name of the thing that the page represents is different from the page title. (i.e.: "Frank's Café" vs "Welcome to Frank's Café") * `type` - The type of things that the page represents. This must be a [Schema.org type](https://schema.org/docs/schemas.html), and will probably usually be something like [`BlogPosting`](https://schema.org/BlogPosting), [`NewsArticle`](https://schema.org/NewsArticle), [`Person`](https://schema.org/Person), [`Organization`](https://schema.org/Organization), etc. * `links` - An array of other URLs that represent the same thing that this page represents. For instance, Jane's bio page might include links to Jane's GitHub and Twitter profiles. * `date_modified` - Manually specify the `dateModified` field in the JSON-LD output to override Jekyll's own `dateModified`. This field will take **first priority** for the `dateModified` JSON-LD output. This is useful when the file timestamp does not match the true time that the content was modified. A user may also install [Last Modified At](https://github.com/gjtorikian/jekyll-last-modified-at) which will offer an alternative way of providing for the `dateModified` field. ### Customizing image output For most users, setting `image: [path-to-image]` on a per-page basis should be enough. If you need more control over how images are represented, the `image` property can also be an object, with the following options: * `path` - The relative path to the image. Same as `image: [path-to-image]` * `height` - The height of the Open Graph (`og:image`) image * `width` - The width of the Open Graph (`og:image`) image You can use any of the above, optional properties, like so: ```yml image: path: /img/twitter.png height: 100 width: 100 ``` ### Setting a default image You can define a default image using [Front Matter defaults](https://jekyllrb.com/docs/configuration/front-matter-defaults/), to provide a default Twitter Card or OGP image to all of your posts and pages. Here is a very basic example, that you are encouraged to adapt to your needs: ```yml defaults: - scope: path: "" values: image: /assets/images/default-card.png ``` ### SmartyPants Titles Titles will be processed using [Jekyll's `smartify` filter](https://jekyllrb.com/docs/liquid/filters/). This will use SmartyPants to translate plain ASCII punctuation into "smart" typographic punctuation. This will not render or strip any Markdown you may be using in a page title. ### Setting customized Canonical URL You can set custom Canonical URL for a page by specifying canonical_url option in page front matter. E.g., you have the following in the page's front matter: ```yml layout: post title: Title of Your Post canonical_url: 'https://github.com/jekyll/jekyll-seo-tag/' ``` Which will generate canonical_url with specified link in canonical_url. ```html <link rel="canonical" href="https://github.com/jekyll/jekyll-seo-tag/" /> ``` If no canonical_url option was specified, then uses page url for generating canonical_url. E.g., you have not specified canonical_url in front matter: ```yml layout: post title: Title of Your Post ``` Which will generate following canonical_url: ```html <link rel="canonical" href="https://example.com/title-of-your-post" /> ``` ### Customizing title modifier for paginated pages You can override the default title modifier for paginated pages from `Page %{current} of %{total} for ` to a string of your choice by setting a `seo_paginator_message` key in your `_config.yml`. For example: ```yml seo_paginator_message: "%<current>s / %<total>s | " ``` While the value can be any string text, we recommend using a Ruby string-template containing the variables `current` and `total` similar to the example above, to incorporate the current page-number and total number of paginated pages in the title. ������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������jekyll-seo-tag-2.7.1/docs/installation.md�����������������������������������������������������������0000664�0000000�0000000�00000000710�13742777411�0020336�0����������������������������������������������������������������������������������������������������ustar�00root����������������������������root����������������������������0000000�0000000������������������������������������������������������������������������������������������������������������������������������������������������������������������������# Installing Jekyll SEO Tag 1. Add the following to your site's `Gemfile`: ```ruby gem 'jekyll-seo-tag' ``` 2. Add the following to your site's `_config.yml`: ```yml plugins: - jekyll-seo-tag ``` If you are using a Jekyll version less than `3.5.0`, use the `gems` key instead of `plugins`. 3. Add the following right before `</head>` in your site's template(s): <!-- {% raw %} --> ```liquid {% seo %} ``` <!-- {% endraw %} --> ��������������������������������������������������������jekyll-seo-tag-2.7.1/docs/usage.md������������������������������������������������������������������0000664�0000000�0000000�00000007511�13742777411�0016747�0����������������������������������������������������������������������������������������������������ustar�00root����������������������������root����������������������������0000000�0000000������������������������������������������������������������������������������������������������������������������������������������������������������������������������## Usage The SEO tag will respect any of the following if included in your site's `_config.yml` (and simply not include them if they're not defined): * `title` - Your site's title (e.g., *Ben's Awesome Site*, *The GitHub Blog*, etc.), used as part of the title tag like `Home | Ben's Awesome Site`. * `tagline` - A short description (e.g., *A blog dedicated to reviewing cat gifs*), used as part of the title tag like `Ben's Awesome Site | A blog dedicated to reviewing cat gifs` instead of `Ben's Awesome Site | Long description about a blog dedicated to reviewing cat gifs` that would be used when `page.title` is not defined. * `description` - A longer description used for the description meta tag. Also used as fallback for pages that don't provide their own `description`, and also as part of the page's title tag if neither `page.title` nor `site.tagline` has been defined. * `url` - The full URL to your site. Note: `site.github.url` will be used by default. * `author` - global author information (see [Advanced usage](advanced-usage.md#author-information)) * `twitter` - The following properties are available: * `twitter:card` - The site's default card type * `twitter:username` - The site's Twitter handle. You'll want to describe them like so: ```yml twitter: username: benbalter card: summary ``` * `facebook` - The following properties are available: * `facebook:app_id` - a Facebook app ID for Facebook insights * `facebook:publisher` - a Facebook page URL or ID of the publishing entity * `facebook:admins` - a Facebook user ID for domain insights linked to a personal account You'll want to describe one or more like so: ```yml facebook: app_id: 1234 publisher: 1234 admins: 1234 ``` * `logo` - URL to a site-wide logo (e.g., `/assets/your-company-logo.png`) - If you would like the "publisher" property to be present, you must add this field to your site's configuration, during the validation of the structured data by Google Search Console, if the `logo` field is not validated, you will find errors inherent to the publisher in the [Rich Results Testing Tool](https://search.google.com/test/rich-results) * `social` - For [specifying social profiles](https://developers.google.com/search/docs/guides/enhance-site#add-your-sites-name-logo-and-social-links). The following properties are available: * `name` - If the user or organization name differs from the site's name * `links` - An array of links to social media profiles. ```yml social: name: Ben Balter links: - https://twitter.com/BenBalter - https://www.facebook.com/ben.balter - https://www.linkedin.com/in/BenBalter - https://github.com/benbalter - https://keybase.io/benbalter ``` * `google_site_verification` for verifying ownership via Google Search Console * Alternatively, verify ownership with several services at once using the following format: ```yml webmaster_verifications: google: 1234 bing: 1234 alexa: 1234 yandex: 1234 baidu: 1234 ``` * `locale` - The locale these tags are marked up in. Of the format `language_TERRITORY`. Default is `en_US`. Takes priority over existing config key `lang`. The SEO tag will respect the following YAML front matter if included in a post, page, or document: * `title` - The title of the post, page, or document * `description` - A short description of the page's content * `image` - URL to an image associated with the post, page, or document (e.g., `/assets/page-pic.jpg`) * `author` - Page-, post-, or document-specific author information (see [Advanced usage](advanced-usage.md#author-information)) * `locale` - Page-, post-, or document-specific locale information. Takes priority over existing front matter attribute `lang`. *Note:* Front matter defaults can be used for any of the above values as described in advanced usage with an image example. ���������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������jekyll-seo-tag-2.7.1/jekyll-seo-tag.gemspec���������������������������������������������������������0000664�0000000�0000000�00000002633�13742777411�0020565�0����������������������������������������������������������������������������������������������������ustar�00root����������������������������root����������������������������0000000�0000000������������������������������������������������������������������������������������������������������������������������������������������������������������������������# frozen_string_literal: true require_relative "lib/jekyll-seo-tag/version" Gem::Specification.new do |spec| spec.name = "jekyll-seo-tag" spec.version = Jekyll::SeoTag::VERSION spec.authors = ["Ben Balter"] spec.email = ["ben.balter@github.com"] spec.summary = "A Jekyll plugin to add metadata tags for search engines and social networks to better index and display your site's content." spec.homepage = "https://github.com/jekyll/jekyll-seo-tag" spec.license = "MIT" # Prevent pushing this gem to RubyGems.org by setting 'allowed_push_host', or # delete this section to allow pushing this gem to any host. if spec.respond_to?(:metadata) spec.metadata["allowed_push_host"] = "https://rubygems.org" else raise "RubyGems 2.0 or newer is required to protect against public gem pushes." end spec.required_ruby_version = ">= 2.4.0" spec.files = `git ls-files -z`.split("\x0").reject { |f| f.match(%r!^(test|spec|features)/!) } spec.bindir = "exe" spec.executables = spec.files.grep(%r!^exe/!) { |f| File.basename(f) } spec.require_paths = ["lib"] spec.add_dependency "jekyll", ">= 3.8", "< 5.0" spec.add_development_dependency "bundler", ">= 1.15" spec.add_development_dependency "html-proofer", "~> 3.7" spec.add_development_dependency "rspec", "~> 3.5" spec.add_development_dependency "rubocop-jekyll", "~> 0.11" end �����������������������������������������������������������������������������������������������������jekyll-seo-tag-2.7.1/lib/���������������������������������������������������������������������������0000775�0000000�0000000�00000000000�13742777411�0015133�5����������������������������������������������������������������������������������������������������ustar�00root����������������������������root����������������������������0000000�0000000������������������������������������������������������������������������������������������������������������������������������������������������������������������������jekyll-seo-tag-2.7.1/lib/jekyll-seo-tag.rb����������������������������������������������������������0000664�0000000�0000000�00000005005�13742777411�0020307�0����������������������������������������������������������������������������������������������������ustar�00root����������������������������root����������������������������0000000�0000000������������������������������������������������������������������������������������������������������������������������������������������������������������������������# frozen_string_literal: true require "jekyll" require "jekyll-seo-tag/version" module Jekyll class SeoTag < Liquid::Tag autoload :JSONLD, "jekyll-seo-tag/json_ld" autoload :AuthorDrop, "jekyll-seo-tag/author_drop" autoload :ImageDrop, "jekyll-seo-tag/image_drop" autoload :JSONLDDrop, "jekyll-seo-tag/json_ld_drop" autoload :UrlHelper, "jekyll-seo-tag/url_helper" autoload :Drop, "jekyll-seo-tag/drop" autoload :Filters, "jekyll-seo-tag/filters" attr_accessor :context # Matches all whitespace that follows either # 1. A '}', which closes a Liquid tag # 2. A '{', which opens a JSON block # 3. A '>' followed by a newline, which closes an XML tag or # 4. A ',' followed by a newline, which ends a JSON line # We will strip all of this whitespace to minify the template # We will not strip any whitespace if the next character is a '-' # so that we do not interfere with the HTML comment at the # very begining MINIFY_REGEX = %r!(?<=[{}]|[>,]\n)\s+(?\!-)!.freeze def initialize(_tag_name, text, _tokens) super @text = text end def render(context) @context = context SeoTag.template.render!(payload, info) end private def options { "version" => Jekyll::SeoTag::VERSION, "title" => title?, } end def payload # site_payload is an instance of UnifiedPayloadDrop. See https://git.io/v5ajm context.registers[:site].site_payload.tap do |site_payload| site_payload["page"] = context.registers[:page] site_payload["paginator"] = context["paginator"] site_payload["seo_tag"] = drop end end def drop if context.registers[:site].liquid_renderer.respond_to?(:cache) Jekyll::SeoTag::Drop.new(@text, @context) else @drop ||= Jekyll::SeoTag::Drop.new(@text, @context) end end def info { :registers => context.registers, :filters => [Jekyll::Filters], } end class << self def template @template ||= Liquid::Template.parse template_contents end private def template_contents @template_contents ||= begin File.read(template_path).gsub(MINIFY_REGEX, "") end end def template_path @template_path ||= begin File.expand_path "./template.html", File.dirname(__FILE__) end end end end end Liquid::Template.register_tag("seo", Jekyll::SeoTag) ���������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������jekyll-seo-tag-2.7.1/lib/jekyll-seo-tag/������������������������������������������������������������0000775�0000000�0000000�00000000000�13742777411�0017762�5����������������������������������������������������������������������������������������������������ustar�00root����������������������������root����������������������������0000000�0000000������������������������������������������������������������������������������������������������������������������������������������������������������������������������jekyll-seo-tag-2.7.1/lib/jekyll-seo-tag/author_drop.rb����������������������������������������������0000664�0000000�0000000�00000005656�13742777411�0022651�0����������������������������������������������������������������������������������������������������ustar�00root����������������������������root����������������������������0000000�0000000������������������������������������������������������������������������������������������������������������������������������������������������������������������������# frozen_string_literal: true module Jekyll class SeoTag # A drop representing the current page's author # # Author name will be pulled from: # # 1. The page's `author` key # 2. The first author in the page's `authors` key # 3. The `author` key in the site config # # If the result from the name search is a string, we'll also check # for additional author metadata in `site.data.authors` class AuthorDrop < Jekyll::Drops::Drop # Initialize a new AuthorDrop # # page - The page hash (e.g., Page#to_liquid) # site - The Jekyll::Drops::SiteDrop def initialize(page: nil, site: nil) raise ArgumentError unless page && site @mutations = {} @page = page @site = site end # AuthorDrop#to_s should return name, allowing the author drop to safely # replace `page.author`, if necessary, and remain backwards compatible def name author_hash["name"] end alias_method :to_s, :name def twitter return @twitter if defined? @twitter twitter = author_hash["twitter"] || author_hash["name"] @twitter = twitter.is_a?(String) ? twitter.sub(%r!^@!, "") : nil end private attr_reader :page attr_reader :site # Finds the page author in the page.author, page.authors, or site.author # # Returns a string or hash representing the author def resolved_author return @resolved_author if defined? @resolved_author sources = [page["author"]] sources << page["authors"].first if page["authors"].is_a?(Array) sources << site["author"] @resolved_author = sources.find { |s| !s.to_s.empty? } end # If resolved_author is a string, attempts to find coresponding author # metadata in `site.data.authors` # # Returns a hash representing additional metadata or an empty hash def site_data_hash @site_data_hash ||= begin return {} unless resolved_author.is_a?(String) return {} unless site.data["authors"].is_a?(Hash) author_hash = site.data["authors"][resolved_author] author_hash.is_a?(Hash) ? author_hash : {} end end # Returns the normalized author hash representing the page author, # including site-wide metadata if the author is provided as a string, # or an empty hash, if the author cannot be resolved def author_hash @author_hash ||= begin if resolved_author.is_a? Hash resolved_author elsif resolved_author.is_a? String { "name" => resolved_author }.merge!(site_data_hash) else {} end end end # Since author_hash is aliased to fallback_data, any values in the hash # will be exposed via the drop, allowing support for arbitrary metadata alias_method :fallback_data, :author_hash end end end ����������������������������������������������������������������������������������jekyll-seo-tag-2.7.1/lib/jekyll-seo-tag/drop.rb�����������������������������������������������������0000664�0000000�0000000�00000014347�13742777411�0021264�0����������������������������������������������������������������������������������������������������ustar�00root����������������������������root����������������������������0000000�0000000������������������������������������������������������������������������������������������������������������������������������������������������������������������������# frozen_string_literal: true module Jekyll class SeoTag class Drop < Jekyll::Drops::Drop include Jekyll::SeoTag::UrlHelper TITLE_SEPARATOR = " | " FORMAT_STRING_METHODS = [ :markdownify, :strip_html, :normalize_whitespace, :escape_once, ].freeze HOMEPAGE_OR_ABOUT_REGEX = %r!^/(about/)?(index.html?)?$!.freeze EMPTY_READ_ONLY_HASH = {}.freeze private_constant :EMPTY_READ_ONLY_HASH def initialize(text, context) @obj = EMPTY_READ_ONLY_HASH @mutations = {} @text = text @context = context end def version Jekyll::SeoTag::VERSION end # Should the `<title>` tag be generated for this page? def title? return false unless title return @display_title if defined?(@display_title) @display_title = (@text !~ %r!title=false!i) end def site_title @site_title ||= format_string(site["title"] || site["name"]) end def site_tagline @site_tagline ||= format_string site["tagline"] end def site_description @site_description ||= format_string site["description"] end # Page title without site title or description appended def page_title @page_title ||= format_string(page["title"]) || site_title end def site_tagline_or_description site_tagline || site_description end # Page title with site title or description appended # rubocop:disable Metrics/CyclomaticComplexity def title @title ||= begin if site_title && page_title != site_title page_title + TITLE_SEPARATOR + site_title elsif site_description && site_title site_title + TITLE_SEPARATOR + site_tagline_or_description else page_title || site_title end end return page_number + @title if page_number @title end # rubocop:enable Metrics/CyclomaticComplexity def name return @name if defined?(@name) @name = if seo_name seo_name elsif !homepage_or_about? nil elsif site_social["name"] format_string site_social["name"] elsif site_title site_title end end def description @description ||= begin format_string(page["description"] || page["excerpt"]) || site_description end end # A drop representing the page author def author @author ||= AuthorDrop.new(:page => page, :site => site) end # A drop representing the JSON-LD output def json_ld @json_ld ||= JSONLDDrop.new(self) end # Returns a Drop representing the page's image # Returns nil if the image has no path, to preserve backwards compatability def image @image ||= ImageDrop.new(:page => page, :context => @context) @image if @image.path end def date_modified @date_modified ||= begin date = page_seo["date_modified"] || page["last_modified_at"].to_liquid || page["date"] filters.date_to_xmlschema(date) if date end end def date_published @date_published ||= filters.date_to_xmlschema(page["date"]) if page["date"] end def type @type ||= begin if page_seo["type"] page_seo["type"] elsif homepage_or_about? "WebSite" elsif page["date"] "BlogPosting" else "WebPage" end end end def links @links ||= begin if page_seo["links"] page_seo["links"] elsif homepage_or_about? && site_social["links"] site_social["links"] end end end def logo @logo ||= begin return unless site["logo"] if absolute_url? site["logo"] filters.uri_escape site["logo"] else filters.uri_escape filters.absolute_url site["logo"] end end end def page_lang @page_lang ||= page["lang"] || site["lang"] || "en_US" end def page_locale @page_locale ||= (page["locale"] || site["locale"] || page_lang).tr("-", "_") end def canonical_url @canonical_url ||= begin if page["canonical_url"].to_s.empty? filters.absolute_url(page["url"]).to_s.gsub(%r!/index\.html$!, "/") else page["canonical_url"] end end end private def filters @filters ||= Jekyll::SeoTag::Filters.new(@context) end def page @page ||= @context.registers[:page].to_liquid end def site @site ||= @context.registers[:site].site_payload["site"].to_liquid end def homepage_or_about? page["url"] =~ HOMEPAGE_OR_ABOUT_REGEX end def page_number return unless @context["paginator"] && @context["paginator"]["page"] current = @context["paginator"]["page"] total = @context["paginator"]["total_pages"] paginator_message = site["seo_paginator_message"] || "Page %<current>s of %<total>s for " format(paginator_message, :current => current, :total => total) if current > 1 end attr_reader :context def fallback_data @fallback_data ||= {} end def format_string(string) string = FORMAT_STRING_METHODS.reduce(string) do |memo, method| filters.public_send(method, memo) end string unless string.empty? end def seo_name @seo_name ||= format_string(page_seo["name"]) if page_seo["name"] end def page_seo @page_seo ||= sub_hash(page, "seo") end def site_social @site_social ||= sub_hash(site, "social") end # Safely returns a sub hash # # hash - the parent hash # key - the key in the parent hash # # Returns the sub hash or an empty hash, if it does not exist def sub_hash(hash, key) if hash[key].is_a?(Hash) hash[key] else EMPTY_READ_ONLY_HASH end end end end end �����������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������jekyll-seo-tag-2.7.1/lib/jekyll-seo-tag/filters.rb��������������������������������������������������0000664�0000000�0000000�00000000350�13742777411�0021755�0����������������������������������������������������������������������������������������������������ustar�00root����������������������������root����������������������������0000000�0000000������������������������������������������������������������������������������������������������������������������������������������������������������������������������# frozen_string_literal: true module Jekyll class SeoTag class Filters include Jekyll::Filters include Liquid::StandardFilters def initialize(context) @context = context end end end end ����������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������jekyll-seo-tag-2.7.1/lib/jekyll-seo-tag/image_drop.rb�����������������������������������������������0000664�0000000�0000000�00000004134�13742777411�0022417�0����������������������������������������������������������������������������������������������������ustar�00root����������������������������root����������������������������0000000�0000000������������������������������������������������������������������������������������������������������������������������������������������������������������������������# frozen_string_literal: true module Jekyll class SeoTag # A drop representing the page image # The image path will be pulled from: # # 1. The `image` key if it's a string # 2. The `image.path` key if it's a hash # 3. The `image.facebook` key # 4. The `image.twitter` key class ImageDrop < Jekyll::Drops::Drop include Jekyll::SeoTag::UrlHelper # Initialize a new ImageDrop # # page - The page hash (e.g., Page#to_liquid) # context - the Liquid::Context def initialize(page: nil, context: nil) raise ArgumentError unless page && context @mutations = {} @page = page @context = context end # Called path for backwards compatability, this is really # the escaped, absolute URL representing the page's image # Returns nil if no image path can be determined def path @path ||= filters.uri_escape(absolute_url) if absolute_url end alias_method :to_s, :path private attr_accessor :page attr_accessor :context # The normalized image hash with a `path` key (which may be nil) def image_hash @image_hash ||= begin image_meta = page["image"] if image_meta.is_a?(Hash) { "path" => nil }.merge!(image_meta) elsif image_meta.is_a?(String) { "path" => image_meta } else { "path" => nil } end end end alias_method :fallback_data, :image_hash def raw_path @raw_path ||= begin image_hash["path"] || image_hash["facebook"] || image_hash["twitter"] end end def absolute_url return unless raw_path return @absolute_url if defined? @absolute_url @absolute_url = if raw_path.is_a?(String) && absolute_url?(raw_path) == false filters.absolute_url raw_path else raw_path end end def filters @filters ||= Jekyll::SeoTag::Filters.new(context) end end end end ������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������jekyll-seo-tag-2.7.1/lib/jekyll-seo-tag/json_ld.rb��������������������������������������������������0000664�0000000�0000000�00000001761�13742777411�0021744�0����������������������������������������������������������������������������������������������������ustar�00root����������������������������root����������������������������0000000�0000000������������������������������������������������������������������������������������������������������������������������������������������������������������������������# frozen_string_literal: true module Jekyll class SeoTag # This module is deprecated, but is included in the Gem to avoid a breaking # change and should be removed at the next major version bump module JSONLD METHODS_KEYS = { :json_context => "@context", :type => "@type", :name => "name", :page_title => "headline", :json_author => "author", :json_image => "image", :date_published => "datePublished", :date_modified => "dateModified", :description => "description", :publisher => "publisher", :main_entity => "mainEntityOfPage", :links => "sameAs", :canonical_url => "url", }.freeze # Self should be a Jekyll::SeoTag::Drop instance (when extending the module) def json_ld Jekyll.logger.warn "Jekyll::SeoTag::JSONLD is deprecated" @json_ld ||= JSONLDDrop.new(self) end end end end ���������������jekyll-seo-tag-2.7.1/lib/jekyll-seo-tag/json_ld_drop.rb���������������������������������������������0000664�0000000�0000000�00000004471�13742777411�0022771�0����������������������������������������������������������������������������������������������������ustar�00root����������������������������root����������������������������0000000�0000000������������������������������������������������������������������������������������������������������������������������������������������������������������������������# frozen_string_literal: true module Jekyll class SeoTag class JSONLDDrop < Jekyll::Drops::Drop extend Forwardable def_delegator :page_drop, :name, :name def_delegator :page_drop, :description, :description def_delegator :page_drop, :canonical_url, :url def_delegator :page_drop, :page_title, :headline def_delegator :page_drop, :date_modified, :dateModified def_delegator :page_drop, :date_published, :datePublished def_delegator :page_drop, :links, :sameAs def_delegator :page_drop, :logo, :logo def_delegator :page_drop, :type, :type # Expose #type and #logo as private methods and #@type as a public method alias_method :"@type", :type private :type private :logo VALID_ENTITY_TYPES = %w(BlogPosting CreativeWork).freeze private_constant :VALID_ENTITY_TYPES # page_drop should be an instance of Jekyll::SeoTag::Drop def initialize(page_drop) @mutations = {} @page_drop = page_drop end def fallback_data @fallback_data ||= { "@context" => "https://schema.org", } end def author return unless page_drop.author["name"] { "@type" => "Person", "name" => page_drop.author["name"], } end def image return unless page_drop.image return page_drop.image.path if page_drop.image.keys.length == 1 hash = page_drop.image.to_h hash["url"] = hash.delete("path") hash["@type"] = "imageObject" hash end def publisher return unless logo output = { "@type" => "Organization", "logo" => { "@type" => "ImageObject", "url" => logo, }, } output["name"] = page_drop.author.name if page_drop.author.name output end def main_entity return unless VALID_ENTITY_TYPES.include?(type) { "@type" => "WebPage", "@id" => page_drop.canonical_url, } end alias_method :mainEntityOfPage, :main_entity private :main_entity def to_json to_h.reject { |_k, v| v.nil? }.to_json end private attr_reader :page_drop end end end �������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������jekyll-seo-tag-2.7.1/lib/jekyll-seo-tag/url_helper.rb�����������������������������������������������0000664�0000000�0000000�00000001102�13742777411�0022442�0����������������������������������������������������������������������������������������������������ustar�00root����������������������������root����������������������������0000000�0000000������������������������������������������������������������������������������������������������������������������������������������������������������������������������# frozen_string_literal: true module Jekyll class SeoTag # Mixin to share common URL-related methods between class module UrlHelper private # Determines if the given string is an absolute URL # # Returns true if an absolute URL. # Retruns false if it's a relative URL # Returns nil if it is not a string or can't be parsed as a URL def absolute_url?(string) return unless string Addressable::URI.parse(string).absolute? rescue Addressable::URI::InvalidURIError nil end end end end ��������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������jekyll-seo-tag-2.7.1/lib/jekyll-seo-tag/version.rb��������������������������������������������������0000664�0000000�0000000�00000000247�13742777411�0021777�0����������������������������������������������������������������������������������������������������ustar�00root����������������������������root����������������������������0000000�0000000������������������������������������������������������������������������������������������������������������������������������������������������������������������������# frozen_string_literal: true # Prevent bundler errors module Liquid; class Tag; end; end module Jekyll class SeoTag < Liquid::Tag VERSION = "2.7.1" end end ���������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������jekyll-seo-tag-2.7.1/lib/template.html��������������������������������������������������������������0000775�0000000�0000000�00000007322�13742777411�0017643�0����������������������������������������������������������������������������������������������������ustar�00root����������������������������root����������������������������0000000�0000000������������������������������������������������������������������������������������������������������������������������������������������������������������������������<!-- Begin Jekyll SEO tag v{{ seo_tag.version }} --> {% if seo_tag.title? %} <title>{{ seo_tag.title }} {% endif %} {% if seo_tag.page_title %} {% endif %} {% if seo_tag.author.name %} {% endif %} {% if seo_tag.description %} {% endif %} {% if site.url %} {% endif %} {% if seo_tag.site_title %} {% endif %} {% if seo_tag.image %} {% if seo_tag.image.height %} {% endif %} {% if seo_tag.image.width %} {% endif %} {% endif %} {% if page.date %} {% endif %} {% if paginator.previous_page %} {% endif %} {% if paginator.next_page %} {% endif %} {% if seo_tag.image %} {% else %} {% endif %} {% if seo_tag.page_title %} {% endif %} {% if site.twitter %} {% if seo_tag.author.twitter %} {% endif %} {% endif %} {% if site.facebook %} {% if site.facebook.admins %} {% endif %} {% if site.facebook.publisher %} {% endif %} {% if site.facebook.app_id %} {% endif %} {% endif %} {% if site.webmaster_verifications %} {% if site.webmaster_verifications.google %} {% endif %} {% if site.webmaster_verifications.bing %} {% endif %} {% if site.webmaster_verifications.alexa %} {% endif %} {% if site.webmaster_verifications.yandex %} {% endif %} {% if site.webmaster_verifications.baidu %} {% endif %} {% elsif site.google_site_verification %} {% endif %} jekyll-seo-tag-2.7.1/script/000077500000000000000000000000001374277741100156715ustar00rootroot00000000000000jekyll-seo-tag-2.7.1/script/bootstrap000077500000000000000000000000431374277741100176310ustar00rootroot00000000000000#!/bin/sh set -ex bundle install jekyll-seo-tag-2.7.1/script/cibuild000077500000000000000000000001551374277741100172330ustar00rootroot00000000000000#!/bin/sh set -ex bundle exec rspec bundle exec rubocop -S -D bundle exec gem build jekyll-seo-tag.gemspec jekyll-seo-tag-2.7.1/script/release000077500000000000000000000013611374277741100172400ustar00rootroot00000000000000#!/bin/sh # Tag and push a release. set -e # Make sure we're in the project root. cd $(dirname "$0")/.. # Build a new gem archive. rm -rf jekyll-seo-tag-*.gem gem build -q jekyll-seo-tag.gemspec # Make sure we're on the master branch. (git branch | grep -q '* master') || { echo "Only release from the master branch." exit 1 } # Figure out what version we're releasing. tag=v`ls jekyll-seo-tag-*.gem | sed 's/^jekyll-seo-tag-\(.*\)\.gem$/\1/'` # Make sure we haven't released this version before. git fetch -t origin (git tag -l | grep -q "$tag") && { echo "Whoops, there's already a '${tag}' tag." exit 1 } # Tag it and bag it. gem push jekyll-seo-tag-*.gem && git tag "$tag" && git push origin master && git push origin "$tag" jekyll-seo-tag-2.7.1/script/site000077500000000000000000000000621374277741100165610ustar00rootroot00000000000000#!/bin/sh bundle exec jekyll serve --source docs jekyll-seo-tag-2.7.1/spec/000077500000000000000000000000001374277741100153175ustar00rootroot00000000000000jekyll-seo-tag-2.7.1/spec/fixtures/000077500000000000000000000000001374277741100171705ustar00rootroot00000000000000jekyll-seo-tag-2.7.1/spec/fixtures/_layouts/000077500000000000000000000000001374277741100210275ustar00rootroot00000000000000jekyll-seo-tag-2.7.1/spec/fixtures/_layouts/default.html000066400000000000000000000001251374277741100233370ustar00rootroot00000000000000 {% seo %} {{ content }} jekyll-seo-tag-2.7.1/spec/fixtures/_posts/000077500000000000000000000000001374277741100204775ustar00rootroot00000000000000jekyll-seo-tag-2.7.1/spec/fixtures/_posts/2015-01-01-post.md000066400000000000000000000001231374277741100230230ustar00rootroot00000000000000--- title: Some "post" & a test description: A post layout: default --- Blah blah jekyll-seo-tag-2.7.1/spec/fixtures/_posts/2015-01-02-other-post.md000066400000000000000000000000431374277741100241440ustar00rootroot00000000000000--- layout: default --- Blah blah jekyll-seo-tag-2.7.1/spec/fixtures/_posts/2017-01-03-.md000066400000000000000000000002311374277741100221210ustar00rootroot00000000000000--- --- # A post without a title *See* https://github.com/jekyll/jekyll-seo-tag/commit/4f80ea50b773d1995985e35a8a63806516c353c4#commitcomment-22010563 jekyll-seo-tag-2.7.1/spec/fixtures/page.md000066400000000000000000000001301374277741100204200ustar00rootroot00000000000000--- title: blah "blah" & blah description: Some description layout: default --- # Test jekyll-seo-tag-2.7.1/spec/jekyll_seo_tag/000077500000000000000000000000001374277741100203125ustar00rootroot00000000000000jekyll-seo-tag-2.7.1/spec/jekyll_seo_tag/author_drop_spec.rb000066400000000000000000000103041374277741100241750ustar00rootroot00000000000000# frozen_string_literal: true RSpec.describe Jekyll::SeoTag::AuthorDrop do let(:data) { {} } let(:config) { { "author" => "site_author" } } let(:site) do site = make_site(config) site.data = data site end let(:site_payload) { site.site_payload["site"] } let(:name) { "foo" } let(:twitter) { "foo" } let(:picture) { nil } let(:expected_hash) do { "name" => name, "twitter" => twitter, } end let(:page_meta) { { "title" => "page title" } } let(:page) { make_page(page_meta) } subject { described_class.new(:page => page.to_liquid, :site => site_payload.to_liquid) } before do Jekyll.logger.log_level = :error end it "returns the author's name for #to_s" do expect(subject.to_s).to eql("site_author") end context "with site.authors as an array" do let("data") { { "authors" => %w(foo bar) } } let(:page_meta) { { "author" => "foo" } } it "doesn't error" do expect(subject.to_h).to eql(expected_hash) end end context "with site.authors[author] as string" do let("data") { { "authors" => { "foo" => "bar" } } } let(:page_meta) { { "author" => "foo" } } it "doesn't error" do expect(subject.to_h).to eql(expected_hash) end end [:with, :without].each do |site_data_type| context "#{site_data_type} site.author data" do let(:data) do if site_data_type == :with { "authors" => { "author" => { "name" => "data_author", "image" => "author.png" }, "array_author" => { "image" => "author.png" }, "string_author" => { "image" => "author.png" }, "site_author" => { "image" => "author.png" }, }, } else {} end end { :string => { "author" => "string_author" }, :array => { "authors" => %w(array_author author2) }, :empty_string => { "author" => "" }, :nil => { "author" => nil }, :hash => { "author" => { "name" => "hash_author" } }, }.each do |author_type, data| context "with author as #{author_type}" do let(:page_meta) { data } let(:expected_author) do "#{author_type}_author".sub("nil_", "site_").sub("empty_string_", "site_") end it "returns the name" do expect(subject["name"]).to eql(expected_author) end it "returns the twitter handle" do expect(subject["twitter"]).to eql(expected_author) end if site_data_type == :with && author_type != :hash it "returns arbitrary metadata" do expect(subject["image"]).to eql("author.png") end end end end end end context "with author as a front matter default" do let(:config) do { "defaults" => [ { "scope" => { "path" => "" }, "values" => { "author" => "front matter default" }, }, ], } end it "uses the author from the front matter default" do expect(subject["name"]).to eql("front matter default") end end context "twitter" do let(:page_meta) { { "author" => "author" } } it "pulls the handle from the author" do expect(subject["twitter"]).to eql("author") end context "with an @" do let(:page_meta) do { "author" => { "name" => "author", "twitter" => "@twitter", }, } end it "strips the @" do expect(subject["twitter"]).to eql("twitter") end end # See https://github.com/jekyll/jekyll-seo-tag/issues/202 context "without an author name or handle" do let(:page_meta) { { "author" => { "foo" => "bar" } } } it "dosen't blow up" do expect(subject["twitter"]).to be_nil end end context "with an explicit handle" do let(:page_meta) do { "author" => { "name" => "author", "twitter" => "twitter", }, } end it "pulls the handle from the hash" do expect(subject["twitter"]).to eql("twitter") end end end end jekyll-seo-tag-2.7.1/spec/jekyll_seo_tag/drop_spec.rb000066400000000000000000000323331374277741100226210ustar00rootroot00000000000000# frozen_string_literal: true RSpec.describe Jekyll::SeoTag::Drop do let(:config) { { "title" => "site title" } } let(:page_meta) { { "title" => "page title" } } let(:page) { make_page(page_meta) } let(:site) { make_site(config) } let(:context) { make_context(:page => page, :site => site) } let(:text) { "" } subject { described_class.new(text, context) } before do Jekyll.logger.log_level = :error end # Drop includes liquid filters which expect arguments # By default, in drops, `to_h` will call each public method with no arugments # Here, that would cause the filters to explode. This test ensures that all # public methods don't explode when called without arguments. Don't explode. it "doesn't blow up on to_h" do expect { subject.to_h }.to_not raise_error end it "returns the version" do expect(subject.version).to eql(Jekyll::SeoTag::VERSION) end context "title?" do it "knows to include the title" do expect(subject.title?).to be_truthy end context "with title=false" do let(:text) { "title=false" } it "knows not to include the title" do expect(subject.title?).to be_falsy end end context "site title" do it "knows the site title" do expect(subject.site_title).to eql("site title") end context "with site.name" do let(:config) { { "name" => "site title" } } it "knows the site title" do expect(subject.site_title).to eql("site title") end end end context "page title" do it "knows the page title" do expect(subject.page_title).to eql("page title") end context "without a page title" do let(:page) { make_page } it "knows the page title" do expect(subject.page_title).to eql("site title") end end end context "title" do context "with a page and site title" do it "builds the title" do expect(subject.title).to eql("page title | site title") end end context "with a site description but no page title" do let(:page) { make_page } let(:config) do { "title" => "site title", "description" => "site description" } end it "builds the title" do expect(subject.title).to eql("site title | site description") end end context "with a site tagline but no page title" do let(:page) { make_page } let(:config) do { "title" => "site title", "description" => "site description", "tagline" => "site tagline" } end it "builds the title" do expect(subject.title).to eql("site title | site tagline") end end context "with just a page title" do let(:site) { make_site } it "builds the title" do expect(subject.title).to eql("page title") end end context "with just a site title" do let(:page) { make_page } it "builds the title" do expect(subject.title).to eql("site title") end end context "without a page or site title" do let(:page) { make_page } let(:site) { make_site } it "returns nil" do expect(subject.title).to be_nil end end context "with an empty page title" do let(:page_meta) { { :title => "" } } it "builds the title" do expect(subject.title).to eql("site title") end end context "with an empty site title" do let(:config) { { :title => "" } } it "builds the title" do expect(subject.title).to eql("page title") end end context "with an empty page and site title" do let(:page_meta) { { :title => "" } } let(:config) { { :title => "" } } it "returns nil" do expect(subject.title).to be_nil end end end end context "name" do context "with seo.name" do let(:page_meta) do { "seo" => { "name" => "seo name" } } end it "uses the seo name" do expect(subject.name).to eql("seo name") end end context "the index" do let(:page_meta) { { "permalink" => "/" } } context "with site.social.name" do let(:config) { { "social" => { "name" => "social name" } } } it "uses site.social.name" do expect(subject.name).to eql("social name") end end context "with site.social as an array" do let(:config) { { "social" => %w(a b) } } it "uses site.social.name" do expect(subject.name).to be_nil end end it "uses the site title" do expect(subject.name).to eql("site title") end end context "site description" do context "with a site description" do let(:config) { { :description => "site description " } } it "returns the site discription" do expect(subject.site_description).to eql("site description") end end context "without a site description" do let(:site) { make_site } it "returns nil" do expect(subject.site_description).to be_nil end end end context "page description" do context "with a page description" do let(:page_meta) { { "description"=> "page description" } } it "uses the page description" do expect(subject.description).to eql("page description") end end context "with a page excerpt" do let(:page_meta) { { "description"=> "page excerpt" } } it "uses the page description" do expect(subject.description).to eql("page excerpt") end end context "with a site description" do let(:config) { { "description"=> "site description" } } it "uses the page description" do expect(subject.description).to eql("site description") end end context "with no descriptions" do let(:page_meta) { { "description" => nil, "excerpt" => nil } } let(:config) { { "description"=> nil } } it "uses returns nil" do expect(subject.description).to be_nil end end end context "author" do let(:page_meta) { { "author" => "foo" } } it "returns an AuthorDrop" do expect(subject.author).to be_a(Jekyll::SeoTag::AuthorDrop) end it "passes page information" do expect(subject.author.name).to eql("foo") end # Regression test to ensure to_liquid is called on site and page # before being passed to AuthorDrop context "with author as a front matter default" do let(:page_meta) { {} } let(:config) do { "defaults" => [ { "scope" => { "path" => "" }, "values" => { "author" => "front matter default" }, }, ], } end it "uses the author from the front matter default" do expect(subject.author["name"]).to eql("front matter default") end end end end context "date published" do let(:config) { { "timezone" => "America/New_York" } } let(:page_meta) { { "date" => "2017-01-01" } } it "uses page.date" do expect(subject.date_published).to eql("2017-01-01T00:00:00-05:00") end end context "date modified" do let(:config) { { "timezone" => "America/New_York" } } context "with seo.date_modified" do let(:page_meta) { { "seo" => { "date_modified" => "2017-01-01" } } } it "uses seo.date_modified" do expect(subject.date_modified).to eql("2017-01-01T00:00:00-05:00") end end context "with page.last_modified_at" do let(:page_meta) { { "last_modified_at" => "2017-01-01" } } it "uses page.last_modified_at" do expect(subject.date_modified).to eql("2017-01-01T00:00:00-05:00") end end context "date" do let(:page_meta) { { "date" => "2017-01-01" } } it "uses page.date" do expect(subject.date_modified).to eql("2017-01-01T00:00:00-05:00") end end end context "type" do context "with seo.type set" do let(:page_meta) { { "seo" => { "type" => "test" } } } it "uses seo.type" do expect(subject.type).to eql("test") end end context "with seo as an array" do let(:page_meta) { { "seo" => %w(a b) } } it "uses seo.type" do expect(subject.type).to eql("WebPage") end end context "the homepage" do let(:page_meta) { { "permalink" => "/" } } it "is a website" do expect(subject.type).to eql("WebSite") end end context "the about page" do let(:page) { make_page("permalink" => "/about/") } it "is a website" do expect(subject.type).to eql("WebSite") end end context "a blog post" do let(:page_meta) { { "date" => "2017-01-01" } } it "is a blog post" do expect(subject.type).to eql("BlogPosting") end end it "is a webpage" do expect(subject.type).to eql("WebPage") end end context "links" do context "with seo.links" do let(:page_meta) { { "seo" => { "links" => %w(foo bar) } } } it "uses seo.links" do expect(subject.links).to eql(%w(foo bar)) end end context "with site.social.links" do let(:config) { { "social" => { "links"=> %w(a b) } } } it "doesn't use site.social.links" do expect(subject.links).to be_nil end context "the homepage" do let(:page_meta) { { "permalink" => "/" } } it "uses site.social.links" do expect(subject.links).to eql(%w(a b)) end end end end context "logo" do context "without site.logo" do it "returns nothing" do expect(subject.logo).to be_nil end end context "with an absolute site.logo" do let(:config) { { "logo" => "http://example.com/image.png" } } it "uses site.logo" do expect(subject.logo).to eql("http://example.com/image.png") end end context "with a relative site.logo" do let(:config) do { "logo" => "image.png", "url" => "http://example.com", } end it "uses site.logo" do expect(subject.logo).to eql("http://example.com/image.png") end end context "with a uri-escaped logo" do let(:config) { { "logo" => "some image.png" } } it "escapes the logo" do expect(subject.logo).to eql("/some%20image.png") end end end context "image" do let(:image) { "foo.png" } let(:page_meta) { { "image" => image } } it "returns a Drop" do expect(subject.image).to be_a(Jekyll::SeoTag::ImageDrop) end it "returns the image" do expect(subject.image["path"]).to eql("/foo.png") end end context "lang" do context "with page.lang" do let(:page_meta) { { "lang" => "en_GB" } } it "uses page.lang" do expect(subject.page_lang).to eql("en_GB") end end context "with site.lang" do let(:config) { { "lang" => "en_GB" } } it "uses site.lang" do expect(subject.page_lang).to eql("en_GB") end end context "with nothing" do it "defaults" do expect(subject.page_lang).to eql("en_US") end end end context "homepage_or_about?" do [ "/", "/index.html", "index.html", "/index.htm", "/about/", "/about/index.html", ].each do |permalink| context "when passed '#{permalink}' as a permalink" do let(:page_meta) { { "permalink" => permalink } } it "knows it's the home or about page" do expect(subject.send(:homepage_or_about?)).to be_truthy end end end context "a random URL" do let(:page_meta) { { "permalink" => "/about-foo/" } } it "knows it's not the home or about page" do expect(subject.send(:homepage_or_about?)).to be_falsy end end end context "canonical url" do let(:config) { { :url => "http://example.com" } } context "when canonical url is specified for a page" do let(:canonical_url) { "https://github.com/jekyll/jekyll-seo-tag/" } let(:page_meta) { { "title" => "page title", "canonical_url" => canonical_url } } it "uses specified canonical url" do expect(subject.canonical_url).to eq(canonical_url) end end context "when canonical url is not specified for a page" do it "uses site specific canonical url" do expect(subject.canonical_url).to eq("http://example.com/page.html") end end end context "pagination" do let(:context) do make_context( { :page => page, :site => site }, "paginator" => { "page" => 2, "total_pages" => 10 } ) end it "render default pagination title" do expect(subject.send(:page_number)).to eq("Page 2 of 10 for ") end context "render custom pagination title" do let(:config) { { "seo_paginator_message" => "%s of %s" } } it "renders the correct page number" do expect(subject.send(:page_number)).to eq("2 of 10") end end end it "exposes the JSON-LD drop" do expect(subject.json_ld).to be_a(Jekyll::SeoTag::JSONLDDrop) end end jekyll-seo-tag-2.7.1/spec/jekyll_seo_tag/filters_spec.rb000066400000000000000000000011461374277741100233230ustar00rootroot00000000000000# frozen_string_literal: true RSpec.describe Jekyll::SeoTag::Filters do let(:page) { make_page } let(:site) { make_site } let(:context) { make_context(:page => page, :site => site) } subject { described_class.new(context) } before do Jekyll.logger.log_level = :error end it "stores the context" do expect(subject.instance_variable_get("@context")).to be_a(Liquid::Context) end it "exposes jekyll filters" do expect(subject).to respond_to(:markdownify) end it "exposes liquid standard filters" do expect(subject).to respond_to(:normalize_whitespace) end end jekyll-seo-tag-2.7.1/spec/jekyll_seo_tag/image_drop_spec.rb000066400000000000000000000045021374277741100237600ustar00rootroot00000000000000# frozen_string_literal: true RSpec.describe Jekyll::SeoTag::ImageDrop do let(:config) { { "title" => "site title" } } let(:image) { nil } let(:page_meta) { { "image" => image } } let(:page) { make_page(page_meta) } let(:site) { make_site(config) } let(:context) { make_context(:page => page, :site => site) } let(:text) { "" } subject { described_class.new(:page => page.to_liquid, :context => context) } before do Jekyll.logger.log_level = :error end context "with image as a string" do let(:image) { "image.png" } it "returns the image" do expect(subject["path"]).to eql("/image.png") end context "with site.url" do let(:config) { { "url" => "http://example.com" } } it "makes the path absolute" do expect(subject["path"]).to eql("http://example.com/image.png") end end context "with a URL-escaped path" do let(:image) { "some image.png" } it "URL-escapes the image" do expect(subject["path"]).to eql("/some%20image.png") end end end context "with image as a hash" do context "with a path" do let(:image) { { "path" => "image.png" } } it "returns the image" do expect(subject["path"]).to eql("/image.png") end end context "with facebook" do let(:image) { { "facebook" => "image.png" } } it "returns the image" do expect(subject["path"]).to eql("/image.png") end end context "with twitter" do let(:image) { { "twitter" => "image.png" } } it "returns the image" do expect(subject["path"]).to eql("/image.png") end end context "with some random hash" do let(:image) { { "foo" => "bar" } } it "returns nil" do expect(subject["path"]).to be_nil end it "returns arbitrary values" do expect(subject["foo"]).to eql("bar") end end context "with an invalid path" do let(:image) { ":" } it "returns the path" do expect(subject["path"]).to eql(":") end end context "with height and width" do let(:image) { { "path" => "image.png", "height" => 5, "width" => 10 } } it "returns the height and width" do expect(subject["height"]).to eql(5) expect(subject["width"]).to eql(10) end end end end jekyll-seo-tag-2.7.1/spec/jekyll_seo_tag/json_ld_drop_spec.rb000066400000000000000000000110651374277741100243300ustar00rootroot00000000000000# frozen_string_literal: true RSpec.describe Jekyll::SeoTag::JSONLDDrop do let(:author) { "author" } let(:image) { "image" } let(:metadata) do { "title" => "title", "author" => author, "image" => image, "date" => "2017-01-01", "description" => "description", "seo" => { "name" => "seo name", "date_modified" => "2017-01-02", "links" => %w(a b), }, } end let(:config) do { "logo" => "logo", "timezone" => "America/New_York", } end let(:page) { make_page(metadata) } let(:site) { make_site(config) } let(:context) { make_context(:page => page, :site => site) } let(:page_drop) { Jekyll::SeoTag::Drop.new("", context) } subject { described_class.new(page_drop) } before do Jekyll.logger.log_level = :error end it "returns the context" do expect(subject).to have_key("@context") expect(subject["@context"]).to eql("https://schema.org") end it "returns the type" do expect(subject).to have_key("@type") expect(subject["@type"]).to eql("BlogPosting") end it "returns the name" do expect(subject).to have_key("name") expect(subject["name"]).to eql("seo name") end it "returns the headline" do expect(subject).to have_key("headline") expect(subject["headline"]).to eql("title") end context "author" do { "string" => "author", "hash" => { "name" => "author" }, }.each do |key, value| context "when passed as a #{key}" do let(:author) { value } it "returns the author" do expect(subject).to have_key("author") expect(subject["author"]).to be_a(Hash) expect(subject["author"]).to have_key("@type") expect(subject["author"]["@type"]).to eql("Person") expect(subject["author"]).to have_key("name") expect(subject["author"]["name"]).to be_a(String) expect(subject["author"]["name"]).to eql("author") end end end end context "image" do context "with image as a string" do let(:image) { "image" } it "returns the image as a string" do expect(subject).to have_key("image") expect(subject["image"]).to be_a(String) expect(subject["image"]).to eql("/image") end end context "with image as a hash" do let(:image) { { "path" => "image", "height" => 5, "width" => 10 } } it "returns the image as a hash" do expect(subject).to have_key("image") expect(subject["image"]).to be_a(Hash) expect(subject["image"]).to eql( "@type" => "imageObject", "url" => "/image", "height" => 5, "width" => 10 ) end end end it "returns the datePublished" do expect(subject).to have_key("datePublished") expect(subject["datePublished"]).to eql("2017-01-01T00:00:00-05:00") end it "returns the dateModified" do expect(subject).to have_key("dateModified") expect(subject["dateModified"]).to eql("2017-01-02T00:00:00-05:00") end it "returns the description" do expect(subject).to have_key("description") expect(subject["description"]).to eql("description") end it "returns the publisher" do expect(subject).to have_key("publisher") publisher = subject["publisher"] expect(publisher).to be_a(Hash) expect(publisher).to have_key("@type") expect(publisher["@type"]).to eql("Organization") expect(publisher).to have_key("logo") logo = publisher["logo"] expect(logo).to have_key("@type") expect(logo["@type"]).to eql("ImageObject") expect(logo).to have_key("url") expect(logo["url"]).to eql("/logo") end it "returns the main entity of page" do expect(subject).to have_key("mainEntityOfPage") expect(subject["mainEntityOfPage"]).to be_a(Hash) expect(subject["mainEntityOfPage"]).to have_key("@type") expect(subject["mainEntityOfPage"]["@type"]).to eql("WebPage") expect(subject["mainEntityOfPage"]).to have_key("@id") expect(subject["mainEntityOfPage"]["@id"]).to eql("/page.html") end it "returns sameAs" do expect(subject).to have_key("sameAs") expect(subject["sameAs"]).to be_a(Array) expect(subject["sameAs"]).to eql(%w(a b)) end it "returns the url" do expect(subject).to have_key("url") expect(subject["url"]).to eql("/page.html") end context "with null values" do let(:metadata) { {} } it "does not return null values as json" do expect(subject.to_json).to_not match(%r!:null!) end end end jekyll-seo-tag-2.7.1/spec/jekyll_seo_tag_integration_spec.rb000077500000000000000000000551231374277741100242650ustar00rootroot00000000000000# frozen_string_literal: true RSpec.describe Jekyll::SeoTag do let(:page) { make_page } let(:site) { make_site } let(:post) { make_post } let(:context) { make_context(:page => page, :site => site) } let(:tag) { "seo" } let(:text) { "" } let(:output) { Liquid::Template.parse("{% #{tag} #{text} %}").render!(context, {}) } let(:json) { output.match(%r!!m)[1] } let(:json_data) { JSON.parse(json) } let(:paginator) { { "previous_page" => true, "previous_page_path" => "foo", "next_page" => true, "next_page_path" => "bar" } } before do Jekyll.logger.log_level = :error end it "builds" do expect(output).to match(%r!Jekyll SEO tag!i) end it "outputs the plugin version" do version = Jekyll::SeoTag::VERSION expect(output).to match(%r!Jekyll SEO tag v#{version}!i) end it "outputs meta generator" do expect(output).to match(%r!Jekyll v#{Jekyll::VERSION}!i) end it "outputs valid HTML" do site.process options = { :check_html => true, :checks_to_ignore => %w(ScriptCheck LinkCheck ImageCheck), } status = HTMLProofer.check_directory(dest_dir, options).run expect(status).to eql(true) end context "with page.title" do let(:page) { make_page("title" => "foo") } it "builds the title with a page title only" do expect(output).to match(%r!foo!) expected = %r!! expect(output).to match(expected) end context "with site.name" do let(:site) { make_site("name" => "Site Name") } it "builds the title with a page title and site name" do expect(output).to match(%r!foo \| Site Name!) end end context "with site.title" do let(:site) { make_site("title" => "bar") } it "builds the title with a page title and site title" do expect(output).to match(%r!foo \| bar!) end end context "with site.description" do let(:site) { make_site("description" => "Site Description") } it "builds the title without the site description" do expect(output).not_to match(%r!foo \| Site Description!) end end context "with site.title and site.description" do let(:site) { make_site("title" => "Site Title", "description" => "Site Description") } it "builds the title with a page title and site title" do expect(output).to match(%r!foo \| Site Title!) end it "does not build the title with the site description" do expect(output).not_to match(%r!foo \| Site Description!) end end context "with site.title and site.description" do let(:site) { make_site("title" => "Site Title", "description" => "Site Description") } it "builds the title with a page title and site title" do expect(output).to match(%r!foo \| Site Title!) end it "does not build the title with the site description" do expect(output).not_to match(%r!Page Title \| Site Description!) end end end context "with site.title" do let(:site) { make_site("title" => "Site title") } it "builds the title with only a site title" do expect(output).to match(%r!Site title!) end end context "with site.title and site.description" do let(:site) { make_site("title" => "Site Title", "description" => "Site Description") } it "builds the title with site title and description" do expect(output).to match(%r!Site Title \| Site Description!) end end context "with page.description" do let(:page) { make_page("description" => "foo") } it "uses the page description" do expect(output).to match(%r!!) expect(output).to match(%r!!) end end context "with page.excerpt" do let(:page) { make_page("excerpt" => "foo") } it "uses the page excerpt when no page description exists" do expect(output).to match(%r!!) expect(output).to match(%r!!) end end context "with site.description" do let(:site) { make_site("description" => "foo") } it "uses the site description when no page description nor excerpt exist" do expect(output).to match(%r!!) expect(output).to match(%r!!) end end context "with site.url" do let(:site) { make_site("url" => "http://example.invalid") } it "uses the site url to build the seo url" do expected = %r!! expect(output).to match(expected) expected = %r!! expect(output).to match(expected) end context "with page.permalink" do let(:page) { make_page("permalink" => "/page/index.html") } it "uses replaces '/index.html' with '/'" do expected = %r!! expect(output).to match(expected) expected = %r!! expect(output).to match(expected) end end context "with site.baseurl" do let(:site) { make_site("url" => "http://example.invalid", "baseurl" => "/foo") } it "uses baseurl to build the seo url" do expected = %r!! expect(output).to match(expected) expected = %r!! expect(output).to match(expected) end end context "with relative page.image as a string" do let(:page) { make_page("image" => "/img/foo.png") } it "outputs an open graph image" do expected = '' expect(output).to include(expected) end end context "with absolute page.image" do let(:page) { make_page("image" => "http://cdn.example.invalid/img/foo.png") } it "outputs an open graph image" do expected = '' expect(output).to include(expected) end end context "with page.image as an object" do context "when given a path" do let(:page) { make_page("image" => { "path" => "/img/foo.png" }) } it "outputs an open graph image" do expected = %r!! expect(output).to match(expected) end end context "when given a facebook image" do let(:page) { make_page("image" => { "facebook" => "/img/facebook.png" }) } it "outputs an open graph image" do expected = %r!! expect(output).to match(expected) end end context "when given a twitter image" do let(:page) { make_page("image" => { "twitter" => "/img/twitter.png" }) } it "outputs an open graph image" do expected = %r!! expect(output).to match(expected) end end context "when given an image height and width" do let(:image) { { "path" => "/img/foo.png", "height" => 1, "width" => 2 } } let(:page) { make_page("image" => image) } it "outputs an open graph image width and height" do expected = %r!! expect(output).to match(expected) expected = %r!! expect(output).to match(expected) end end end context "with site.logo" do let(:site) { make_site("logo" => "/logo.png", "url" => "http://example.invalid") } it "outputs the logo" do expect(json_data["publisher"]["logo"]["url"]).to eql("http://example.invalid/logo.png") end end context "with absolute site.logo" do let(:site) { make_site("logo" => "http://cdn.example.invalid/logo.png", "url" => "http://example.invalid") } it "outputs the logo" do expect(json_data["publisher"]["logo"]["url"]).to eql("http://cdn.example.invalid/logo.png") end end context "with site.logo and page.author" do let(:site) { make_site("logo" => "http://cdn.example.invalid/logo.png", "url" => "http://example.invalid", "author" => "Mr. Foo") } it "outputs the author" do expect(json_data["publisher"]["name"]).to eql("Mr. Foo") end end context "with page author" do let(:site) { make_site("logo" => "/logo.png", "url" => "http://example.invalid") } let(:page) { make_post("author" => "Mr. Foo") } it "outputs the author" do expect(json_data["author"]["@type"]).to eql("Person") expect(json_data["author"]["name"]).to eql("Mr. Foo") end it "outputs the publisher author" do expect(json_data["publisher"]["name"]).to eql("Mr. Foo") end end context "with seo type is BlogPosting" do let(:site) { make_site("url" => "http://example.invalid") } let(:page) { make_post("seo" => { "type" => "BlogPosting" }, "permalink" => "/foo/") } it "outputs the mainEntityOfPage" do expect(json_data["mainEntityOfPage"]["@type"]).to eql("WebPage") expect(json_data["mainEntityOfPage"]["@id"]).to eql("http://example.invalid/foo/") end end context "with seo type is CreativeWork" do let(:site) { make_site("url" => "http://example.invalid") } let(:page) { make_post("seo" => { "type" => "CreativeWork" }, "permalink" => "/foo/") } it "outputs the mainEntityOfPage" do expect(json_data["mainEntityOfPage"]["@type"]).to eql("WebPage") expect(json_data["mainEntityOfPage"]["@id"]).to eql("http://example.invalid/foo/") end end context "with site.title" do let(:site) { make_site("title" => "Foo", "url" => "http://example.invalid") } it "outputs the site title meta" do expect(output).to match(%r!!) end it "minifies the output" do version = Jekyll::SeoTag::VERSION expected = <<~HTML Foo HTML expect(output).to match(expected) end end end context "posts" do context "with post meta" do let(:site) { make_site("url" => "http://example.invalid") } let(:meta) do { "title" => "post", "description" => "description", "image" => "/img.png", } end let(:page) { make_post(meta) } it "outputs post meta" do expected = %r!! expect(output).to match(expected) expect(json_data["headline"]).to eql("post") expect(json_data["description"]).to eql("description") expect(json_data["image"]).to eql("http://example.invalid/img.png") end it "minifies JSON-LD" do expect(output).to_not match(%r!{.*?\s.*?}!) end it "removes null values from JSON-LD" do expect(output).to_not match(%r!:null!) end end end context "facebook" do let(:site_facebook) do { "admins" => "jekyllrb-fb-admins", "app_id" => "jekyllrb-fb-app_id", "publisher" => "jekyllrb-fb-publisher", } end let(:site) { make_site("facebook" => site_facebook) } it "outputs facebook admins meta" do expected = %r!! expect(output).to match(expected) end it "outputs facebook app ID meta" do expected = %r!! expect(output).to match(expected) end it "outputs facebook article publisher meta" do expected = %r!! expect(output).to match(expected) end end context "twitter" do context "with site.twitter.username" do let(:site_twitter) { { "username" => "jekyllrb" } } let(:site) { make_site("twitter" => site_twitter) } context "with page.author as a string" do let(:page) { make_page("author" => "benbalter") } it "outputs twitter card meta" do expected = %r!! expect(output).to match(expected) expected = %r!! expect(output).to match(expected) expected = %r!! expect(output).to match(expected) end context "with an @" do let(:page) { make_page("author" => "@benbalter") } it "outputs the twitter card" do expected = %r!! expect(output).to match(expected) end end context "with site.data.authors" do let(:author_data) { {} } let(:data) { { "authors" => author_data } } let(:site) { make_site("data" => data, "twitter" => site_twitter) } context "with the author in site.data.authors" do let(:author_data) { { "benbalter" => { "twitter" => "test" } } } it "outputs the twitter card" do expected = %r!! expect(output).to match(expected) end end context "without the author in site.data.authors" do it "outputs the twitter card" do expected = %r!! expect(output).to match(expected) end end end end context "with page.image" do context "without *.twitter.card" do let(:page) { make_page("image" => "/img/foo.png") } it "outputs summary card with large image" do expected = %r!! expect(output).to match(expected) end end context "with page.twitter.card" do let(:page_twitter) { { "card" => "summary" } } let(:page) { make_page("image" => "/img/foo.png", "twitter" => page_twitter) } it "outputs summary card with small image" do expected = %r!! expect(output).to match(expected) end end context "with site.twitter.card" do let(:site_twitter) { { "username" => "jekyllrb", "card" => "summary" } } let(:site) { make_site("twitter" => site_twitter) } let(:page) { make_page("image" => "/img/foo.png") } it "outputs summary card with small image" do expected = %r!! expect(output).to match(expected) end end end context "with page.author as a hash" do let(:page) { make_page("author" => { "twitter" => "@test" }) } it "supports author data as a hash" do expected = %r!! expect(output).to match(expected) end end context "with page.authors as an array" do let(:page) { make_page("authors" => %w(test foo)) } it "supports author data as an array" do expected = %r!! expect(output).to match(expected) end end context "with site.author as a hash" do let(:author) { { "twitter" => "@test" } } let(:site) { make_site("author" => author, "twitter" => site_twitter) } it "supports author data as an hash" do expected = %r!! expect(output).to match(expected) end end end end context "author" do let(:site) { make_site("author" => "Site Author") } context "with site.author" do it "outputs site author metadata" do expected = %r!! expect(output).to match(expected) end end context "with page.author" do let(:page) { make_page("author" => "Page Author") } it "outputs page author metadata" do expected = %r!! expect(output).to match(expected) end end context "without page.author" do let(:page) { make_page("author" => "") } it "outputs site author metadata" do expected = %r!! expect(output).to match(expected) end end context "with site.data.authors" do let(:author_data) { { "renshuki" => { "name" => "Site Data Author" } } } let(:data) { { "authors" => author_data } } context "with the author in site.data.authors" do let(:site) { make_site("data" => data, "author" => "renshuki") } it "outputs the author metadata" do expected = %r!! expect(output).to match(expected) end end context "without the author in site.data.authors" do it "outputs site author metadata" do expected = %r!! expect(output).to match(expected) end end end end context "with site.social" do let(:links) { ["http://foo.invalid", "http://bar.invalid"] } let(:social_namespace) { { "name" => "Ben", "links" => links } } let(:site) { make_site("social" => social_namespace) } let(:page) { make_post(meta) } context "on homepage" do let(:meta) do { "permalink" => "/", "seo" => { "type" => "person", }, } end it "outputs social meta" do expect(json_data["@type"]).to eql("person") expect(json_data["name"]).to eql("Ben") expect(json_data["sameAs"]).to eql(links) end end context "on about page" do let(:meta) { { "permalink" => "/about/" } } it "outputs sameAs links" do expect(json_data["sameAs"]).to eql(links) end end context "on other pages" do let(:meta) { { "permalink" => "/2/" } } it "does not output sameAs links" do expect(json_data["sameAs"]).to be_nil end end end context "with site.name" do let(:site) { make_site("name" => "Site name") } it "uses site.name if site.title is not present" do expected = %r!! expect(output).to match(expected) end context "with site.title" do let(:site) { make_site("name" => "Site Name", "title" => "Site Title") } it "uses site.tile if both site.title and site.name are present" do expected = %r!! expect(output).to match(expected) end end end context "with title=false" do let(:text) { "title=false" } it "does not output a tag" do expect(output).not_to match(%r!<title>!) end end context "with pagination" do let(:context) { make_context({}, "paginator" => paginator) } it "outputs pagination links" do expect(output).to match(%r!<link rel="prev" href="/foo" />!) expect(output).to match(%r!<link rel="next" href="/bar" />!) end end context "webmaster verification" do context "with site.webmaster_verifications" do let(:site_verifications) do { "google" => "foo", "bing" => "bar", "alexa" => "baz", "yandex" => "bat", } end let(:site) { make_site("webmaster_verifications" => site_verifications) } it "outputs google verification meta" do expected = %r!<meta name="google-site-verification" content="foo" />! expect(output).to match(expected) end it "outputs bing verification meta" do expected = %r!<meta name="msvalidate.01" content="bar" />! expect(output).to match(expected) end it "outputs alexa verification meta" do expected = %r!<meta name="alexaVerifyID" content="baz" />! expect(output).to match(expected) end it "outputs yandex verification meta" do expected = %r!<meta name="yandex-verification" content="bat" />! expect(output).to match(expected) end end context "with site.google_site_verification" do let(:site) { make_site("google_site_verification" => "foo") } it "outputs google verification meta" do expected = %r!<meta name="google-site-verification" content="foo" />! expect(output).to match(expected) end end end context "with locale" do it "uses en_US when no locale is specified" do expected = %r!<meta property="og:locale" content="en_US" />! expect(output).to match(expected) end context "with site.lang" do let(:site) { make_site("lang" => "de_DE") } it "uses site.lang if page.lang is not present" do expected = %r!<meta property="og:locale" content="de_DE" />! expect(output).to match(expected) end context "with page.lang" do let(:page) { make_page("lang" => "en_UK") } it "uses page.lang if both site.lang and page.lang are present" do expected = %r!<meta property="og:locale" content="en_UK" />! expect(output).to match(expected) end end end context "with site.lang hyphenated" do let(:site) { make_site("lang" => "en-AU") } it "coerces hyphen to underscore" do expected = %r!<meta property="og:locale" content="en_AU" />! expect(output).to match(expected) end end end end ���������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������jekyll-seo-tag-2.7.1/spec/jekyll_seo_tag_spec.rb����������������������������������������������������0000664�0000000�0000000�00000002645�13742777411�0021660�0����������������������������������������������������������������������������������������������������ustar�00root����������������������������root����������������������������0000000�0000000������������������������������������������������������������������������������������������������������������������������������������������������������������������������# frozen_string_literal: true RSpec.describe Jekyll::SeoTag do let(:config) { { "title" => "site title" } } let(:page_meta) { {} } let(:page) { make_page(page_meta) } let(:site) { make_site(config) } let(:render_context) { make_context(:page => page, :site => site) } let(:text) { "" } let(:tag_name) { "github_edit_link" } let(:tokenizer) { Liquid::Tokenizer.new("") } let(:parse_context) { Liquid::ParseContext.new } let(:rendered) { subject.render(render_context) } let(:payload) { subject.send(:payload) } subject do tag = described_class.parse(tag_name, text, tokenizer, parse_context) tag.instance_variable_set("@context", render_context) tag end before do Jekyll.logger.log_level = :error end it "returns the template" do expect(described_class.template).to be_a(Liquid::Template) end context "payload" do it "contains the drop" do expect(payload["seo_tag"]).to be_a(Jekyll::SeoTag::Drop) end it "contains the Jekyll drop" do expect(payload["jekyll"]).to be_a(Jekyll::Drops::JekyllDrop) end it "contains the page" do expect(payload["page"]).to be_a(Jekyll::Page) end it "contains the site" do expect(payload["site"]).to be_a(Jekyll::Drops::SiteDrop) end end it "renders" do expected = "<!-- Begin Jekyll SEO tag v#{described_class::VERSION} -->" expect(rendered).to match(expected) end end �������������������������������������������������������������������������������������������jekyll-seo-tag-2.7.1/spec/spec_helper.rb������������������������������������������������������������0000664�0000000�0000000�00000002410�13742777411�0020132�0����������������������������������������������������������������������������������������������������ustar�00root����������������������������root����������������������������0000000�0000000������������������������������������������������������������������������������������������������������������������������������������������������������������������������# frozen_string_literal: true $LOAD_PATH.unshift File.expand_path("../lib", __dir__) require "jekyll" require "jekyll-seo-tag" require "html-proofer" # Monkey patch Jekyll::Drops::Drop so Rspec's `have_key` works as expected module Jekyll module Drops class Drop alias_method :has_key?, :key? end end end ENV["JEKYLL_LOG_LEVEL"] = "error" def dest_dir File.expand_path("../tmp/dest", __dir__) end def source_dir File.expand_path("fixtures", __dir__) end CONFIG_DEFAULTS = { "source" => source_dir, "destination" => dest_dir, "gems" => ["jekyll-seo-tag"], }.freeze def make_page(options = {}) page = Jekyll::Page.new site, CONFIG_DEFAULTS["source"], "", "page.md" page.data = options page end def make_post(options = {}) filename = File.expand_path("_posts/2015-01-01-post.md", CONFIG_DEFAULTS["source"]) config = { :site => site, :collection => site.collections["posts"] } page = Jekyll::Document.new filename, config page.merge_data!(options) page end def make_site(options = {}) config = Jekyll.configuration CONFIG_DEFAULTS.merge(options) Jekyll::Site.new(config) end def make_context(registers = {}, environments = {}) Liquid::Context.new(environments, {}, { :site => site, :page => page }.merge(registers)) end ������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������