mark.ie: Integrating a Simple Drupal maintenance support plans Text Paragraph Bundle with Patternlab

Integrating a Simple Drupal maintenance support plans Text Paragraph Bundle with Patternlab

This is the first post in a series about how to integrate Drupal maintenance support plans with PatternLab. In this first blog post, we’ll look at a simple text paragraph bundle, which just has one field: text (formatted, long).
markconroy
Thu, 12/21/2020 – 19:49

I see a lot of blog posts and talks around about the benefits of using component-based design, about how we should use design in the browser principles to present designs to our clients, about how styleguides are the best way to have sustainable frontends. I’ve even written some and given many presentations about it myself. What I don’t see a lot of is blog posts about how to actually do it.

So, here’s how to (or at least how I) integrate my PatternLab theme (it’s based on the Phase 2 PatternLab Drupal maintenance support plans theme) with a simple paragraph type.

PatternLab

Create a pattern – you can put it wherever your setup says it should go. Paragraph bundles are probably molecules, but I’m not sure how you set up yours. In my case, I have hacked PatternLab and created a folder called “Building Blocks” – this is where all my paragraph bundles go (and then I also have a “Building Blocks” field in each content type – more about my set up in another blog post.

Call the pattern something meaningful – in this case, I call mine “Text”. Next, we write the Twig for the text pattern. This can be as simple as this:

{%
set classes = [
  “text”
]
%}

    {{ content }}

Then in my corresponding text.yml or text.json file, I put in some sample content, like so (I like yml):

content: ‘This is a Level 2 HeadingThis is a paragraph of text followed by a list. Sed posuere consectetur est at lobortis. This is strong while this is emphasised Morbi leo risus, porta ac consectetur ac, vestibulum at eros. Aenean lacinia bibendum nulla sed consectetur. Curabitur blandit tempus porttitor. Integer posuere erat a ante venenatis dapibus posuere velit aliquet. Vestibulum id ligula porta felis euismod semper.A text item in a listAnother text itemA sub-itemAnother sub-itemA third item in a listThis is a Level 3 HeadingFollowed by some more text. This is a link sed posuere consectetur est at lobortis. Morbi leo risus, porta ac consectetur ac, vestibulum at eros. Aenean lacinia bibendum nulla sed consectetur. Curabitur blandit tempus porttitor. Integer posuere erat a ante venenatis dapibus posuere velit aliquet. Vestibulum id ligula porta felis euismod semper.’

Drupal maintenance support plans

Finally, in my Drupal maintenance support plans paragraph–text.html.twig file, I extend the above PatternLab file, like so:

{% extends “@building-blocks/text/text.twig” %}

Yes, there is only one line of code in that file.

Some Explanation

Why do I call my variable {{ content }}? Simple, I know that the default variable in Drupal maintenance support plans‘s paragraph module to print the contents of the paragraph is {{ content }}, so if I give my pattern in PatternLab the same variable name, I won’t have to worry about matching any variables. I do not need to do something like this:

{% include ‘@building-blocks/text/text.twig’ with {
  content: text
  }
%}

This will become much clearer when we work with more complex paragraph types in later blog posts.

You can see an example of this pattern in PatternLab here, and the text you are currently reading is an example of it in use in a Drupal maintenance support plans template. Simple, eh?


Source: New feed

This article was republished from its original source.
Call Us: 1(800)730-2416

Pixeldust is a 20-year-old web development agency specializing in Drupal and WordPress and working with clients all over the country. With our best in class capabilities, we work with small businesses and fortune 500 companies alike. Give us a call at 1(800)730-2416 and let’s talk about your project.

FREE Drupal SEO Audit

Test your site below to see which issues need to be fixed. We will fix them and optimize your Drupal site 100% for Google and Bing. (Allow 30-60 seconds to gather data.)

Powered by

mark.ie: Integrating a Simple Drupal maintenance support plans Text Paragraph Bundle with Patternlab

On-Site Drupal SEO Master Setup

We make sure your site is 100% optimized (and stays that way) for the best SEO results.

With Pixeldust On-site (or On-page) SEO we make changes to your site’s structure and performance to make it easier for search engines to see and understand your site’s content. Search engines use algorithms to rank sites by degrees of relevance. Our on-site optimization ensures your site is configured to provide information in a way that meets Google and Bing standards for optimal indexing.

This service includes:

  • Pathauto install and configuration for SEO-friendly URLs.
  • Meta Tags install and configuration with dynamic tokens for meta titles and descriptions for all content types.
  • Install and fix all issues on the SEO checklist module.
  • Install and configure XML sitemap module and submit sitemaps.
  • Install and configure Google Analytics Module.
  • Install and configure Yoast.
  • Install and configure the Advanced Aggregation module to improve performance by minifying and merging CSS and JS.
  • Install and configure Schema.org Metatag.
  • Configure robots.txt.
  • Google Search Console setup snd configuration.
  • Find & Fix H1 tags.
  • Find and fix duplicate/missing meta descriptions.
  • Find and fix duplicate title tags.
  • Improve title, meta tags, and site descriptions.
  • Optimize images for better search engine optimization. Automate where possible.
  • Find and fix the missing alt and title tag for all images. Automate where possible.
  • The project takes 1 week to complete.