8.43.0 • Published 18 days ago

@takeshape/ssg v8.43.0

Weekly downloads
336
License
MIT
Repository
-
Last release
18 days ago

Summary

This is the TakeShape static site generator.

tsg.yml Configuration Options

templatePath: src/templates   #Sets the path to look for templates
staticPath: static            #TS deploys this directory. All of your JS, CSS need to end up here. Files like robots.txt, humans.txt and other files that do not need processing should live here.
buildPath: build              #Temporary build directory

locale: en-us #default
dates:
  tz: America/New_York #default
  format: LLL #default

context:                      #Global context available to all routes.
  assets: ../../static/assets/manifest.json
  [KEY]: [VALUE]
  ...

routes:                       #Routes tell TS which template to join with which context (graphql query) and the format of the resulting directory structure to generate
  homepage:
    path: /
    template: pages/homepage.html
    context: data/homepage.graphql
...

htmlCompression:              #Settings for compressing/minifying the generated html
  enabled: false #default
  options:                    #Refer to Html Compression section of readme to see options

Templating

TS uses the Nunjucks templating language. You can find detailed documentation on the Nunjucks site: (https://mozilla.github.io/nunjucks/templating.html

TS specific Nunjucks Filters

  • route(routeName: String)
    {{ post | route('posts') }}
    Returns a relative path to a piece of content as defined by the routes in tsg.yml. The input Object must have the necessary fields specified in the route path in order to construct the path properly.
  • md
    {{ markdown | md }}
    Markdown to safe HTML using the CommonMark spec http://commonmark.org/
  • numberFormat(format: String)
    {{ numberField | numberformat(',.2r') }}
    # grouped thousands with two significant digits, 4200 -> "4,200"
    Returns a number formatted according to the the format specifier string https://github.com/d3/d3-format
  • code(language: String)
    {{ codeField | code('javascript') }}
    Uses prism.js to return an HTML representation of the highlighted code. Takes an optional language string. You will need to manually include the corresponding CSS in your project.
  • image(params: Object)
    {{ imageField | image({w: 320, h: 240, q: 90, crop: 'faces'}) }}
    Returns an imgix ready url. Takes an object of keys and values for any imgix filter https://docs.imgix.com/apis/url
  • date(format: String|Object)
    {{ date | date('MMM Do YYYY') }}
    {{ date | date({format: 'MMM Do YYYY', tz: 'America/Los_Angeles') }}
    {{ date | date({format: 'LLL', tz: 'America/Los_Angeles', locale: 'fr') }}
    Formats dates using moment.js. format can be either a format string or an object where you can specify a format and override the default timezone and locale (configured in tsg.yml).

Configuring Block Canvas imgix settings via tsg.yml

Similarly to how the Nunjucks image filter allows you to apply imgix settings by specifying an object of keys and values, TS also allows you to apply these same settings to images within block canvas elements using the tsg.yml configuration.

Imgix settings are applied per route using the following syntax:

---
routes:
  homepage:
    path: /
    template: pages/homepage.html
    context: #Context is defined as an object with a query and variables
      query: data/homepage.graphql
      variables:
        imageConfig: #Imgix settings must be specified in a variable named imageConfig
          w: 500
          h: 500

Then, wherever you make your GraphQL query, ensure that the imageConfig variable is passed to the block canvas Html query:

query($imageConfig: JSON){
  home {
    blockCanvasHtml(imageConfig: $imageConfig)
  }
}

Imgix settings objects may be defined once and reused in multiple routes in tsg.yml using YAML anchors:

---
smallImageConfig: &smallImageConfig
  w: 25
  h: 25

largeImageConfig: &largeImageConfig
  w: 500
  h: 500

routes:
  homepage:
    path: /
    template: pages/homepage.html
    context:
      query: data/homepage.graphql
      variables:
        imageConfig:
          <<: *smallImageConfig
  about:
    path: /
    template: pages/about.html
    context:
      query: data/about.graphql
      variables:
        imageConfig:
          <<: *smallImageConfig
  gallery:
    path: /
    template: pages/gallery.html
    context:
      query: data/gallery.graphql
      variables:
        imageConfig:
          <<: *largeImageConfig

Html Compression

TS uses Minimize, a highly configurable, well-tested, JavaScript-based HTML minifier. You can find detailed documentation on the Minimize site.

Options

All options listed in the Options section of the Minimize site may be set:

Example

in tsg.yml:

htmlCompression:
enabled: true
options:
  empty: true
  comments: true
8.30.0

1 month ago

8.11.0

2 months ago

8.15.1

2 months ago

8.38.0

26 days ago

8.15.0

2 months ago

8.38.1

26 days ago

8.38.2

26 days ago

8.15.2

2 months ago

8.6.0

2 months ago

8.26.0

1 month ago

8.15.4

2 months ago

8.31.0

1 month ago

8.12.0

2 months ago

8.35.1

1 month ago

8.12.1

2 months ago

8.35.2

1 month ago

8.16.0

2 months ago

8.7.0

2 months ago

8.23.0

2 months ago

8.23.2

1 month ago

8.27.0

1 month ago

8.27.1

1 month ago

8.39.2

25 days ago

8.39.3

25 days ago

8.42.3

19 days ago

8.42.1

19 days ago

8.32.0

1 month ago

8.13.0

2 months ago

8.36.1

30 days ago

8.36.2

30 days ago

8.17.1

2 months ago

8.8.1

2 months ago

8.8.3

2 months ago

8.8.2

2 months ago

8.20.0

2 months ago

8.20.1

2 months ago

8.20.2

2 months ago

8.24.0

1 month ago

8.28.0

1 month ago

8.43.0

18 days ago

8.10.0

2 months ago

8.33.0

1 month ago

8.10.1

2 months ago

8.37.0

26 days ago

8.21.1

2 months ago

8.25.0

1 month ago

8.4.0

2 months ago

8.1.0

2 months ago

8.3.0

2 months ago

7.239.0

3 months ago

8.0.1

3 months ago

8.2.0

2 months ago

7.236.0

3 months ago

7.238.1

3 months ago

7.238.0

3 months ago

7.234.0

3 months ago

7.237.0

3 months ago

7.235.0

3 months ago

7.222.1

3 months ago

7.222.0

3 months ago

7.217.0

3 months ago

7.219.0

3 months ago

7.230.1

3 months ago

7.230.0

3 months ago

7.225.0

3 months ago

7.225.1

3 months ago

7.223.0

3 months ago

7.216.1

3 months ago

7.233.0

3 months ago

7.231.1

3 months ago

7.228.0

3 months ago

7.224.1

3 months ago

7.222.3

3 months ago

7.215.1

3 months ago

7.214.2

3 months ago

7.214.0

3 months ago

7.214.1

3 months ago

7.213.2

3 months ago

7.213.1

4 months ago

7.212.0

4 months ago

7.211.1

4 months ago

7.213.0

4 months ago

7.211.0

4 months ago

7.210.0

4 months ago

7.209.0

4 months ago

7.209.2

4 months ago

7.208.1

4 months ago

7.208.0

4 months ago

7.207.1

4 months ago

7.205.0

4 months ago

7.204.0

4 months ago

7.203.1

4 months ago

7.202.0

4 months ago

7.199.0

4 months ago

7.198.1

4 months ago

7.198.0

4 months ago

7.197.0

4 months ago

7.195.2

4 months ago

7.194.2

4 months ago

7.195.0

4 months ago

7.194.0

4 months ago

7.134.4

6 months ago

7.90.0

7 months ago

7.38.2

9 months ago

7.14.0

10 months ago

7.8.1

11 months ago

7.3.0

11 months ago

6.8.0

1 year ago

5.54.1

1 year ago

5.54.0

1 year ago

5.28.0

1 year ago

5.25.0

1 year ago

5.9.1

1 year ago

5.9.0

1 year ago

5.7.4

2 years ago

5.7.1

2 years ago

5.2.0

2 years ago

5.0.8

2 years ago

5.0.7

2 years ago