Explore all Static Site Generator open source software, libraries, packages, source code, cloud functions and APIs.

Popular New Releases in Static Site Generator

hugo

v0.97.3

gatsby

v4.12

jekyll

v3.9.2

mkdocs

eleventy

Eleventy v1.0.1: It’s Elementary

Popular Libraries in Static Site Generator

hugo

by gohugoio doticongodoticon

star image 58416 doticonApache-2.0

The world’s fastest framework for building websites.

gatsby

by gatsbyjs doticonjavascriptdoticon

star image 52745 doticonMIT

Build blazing fast, modern apps and websites with React

jekyll

by jekyll doticonrubydoticon

star image 44432 doticonMIT

:globe_with_meridians: Jekyll is a blog-aware static site generator in Ruby

mkdocs

by mkdocs doticonpythondoticon

star image 13251 doticonBSD-2-Clause

Project documentation with Markdown.

eleventy

by 11ty doticonjavascriptdoticon

star image 11833 doticonMIT

A simpler static site generator. An alternative to Jekyll. Transforms a directory of templates (of varying types) into HTML.

pelican

by getpelican doticonhtmldoticon

star image 10781 doticonAGPL-3.0

Static site generator that supports Markdown and reST syntax. Powered by Python.

minimal-mistakes

by mmistakes doticonhtmldoticon

star image 8571 doticonMIT

:triangular_ruler: Jekyll theme for building a personal site, blog, project documentation, or portfolio.

zola

by getzola doticonrustdoticon

star image 8446 doticonMIT

A fast static site generator in a single binary with everything built-in. https://www.getzola.org

metalsmith

by segmentio doticonjavascriptdoticon

star image 7650 doticonNOASSERTION

An extremely simple, pluggable static site generator.

Trending New libraries in Static Site Generator

eleventy-high-performance-blog

by google doticonjavascriptdoticon

star image 3551 doticonMIT

A high performance blog template for the 11ty static site generator.

nextra

by shuding doticonjavascriptdoticon

star image 3346 doticonMIT

The Next.js Static Site Generator

docuowl

by docuowl doticongodoticon

star image 1042 doticonNOASSERTION

πŸ¦‰ A documentation generator

microsite

by natemoo-re doticontypescriptdoticon

star image 841 doticonMIT

Do more with less JavaScript. Microsite is a smarter, performance-obsessed static site generator powered by Preact and Snowpack.

bridgetown

by bridgetownrb doticonrubydoticon

star image 655 doticonMIT

A next-generation progressive site generator & fullstack framework, powered by Ruby

retype

by retypeapp doticonjavascriptdoticon

star image 494 doticonNOASSERTION

Retype is an ✨ ultra-high-performance✨ static site generator that builds a website based on simple text files.

binserve

by mufeedvh doticonrustdoticon

star image 448 doticonMIT

A blazingly fast static web server with routing, templating, and security in a single binary you can set up with zero code. :zap::crab:

codedoc

by CONNECT-platform doticontypescriptdoticon

star image 351 doticonMIT

Create beautiful modern documentation websites.

doctave

by Doctave doticonrustdoticon

star image 348 doticonMIT

A batteries-included developer documentation site generator

Top Authors in Static Site Generator

1

apache

26 Libraries

star icon900

2

maptime

10 Libraries

star icon67

3

app-generator

10 Libraries

star icon37

4

18F

10 Libraries

star icon187

5

CloudCannon

9 Libraries

star icon132

6

bep

8 Libraries

star icon164

7

rbind

8 Libraries

star icon191

8

wowchemy

8 Libraries

star icon13251

9

assemble

7 Libraries

star icon4197

10

kura

7 Libraries

star icon89

1

26 Libraries

star icon900

2

10 Libraries

star icon67

3

10 Libraries

star icon37

4

10 Libraries

star icon187

5

9 Libraries

star icon132

6

8 Libraries

star icon164

7

8 Libraries

star icon191

8

8 Libraries

star icon13251

9

7 Libraries

star icon4197

10

7 Libraries

star icon89

Trending Kits in Static Site Generator

No Trending Kits are available at this moment for Static Site Generator

Trending Discussions on Static Site Generator

Unable to use CloudFlare Pages to build due to gatsby.config invalid

Modify all files in specified directory (including subfolders) and saving them in new directory while presevering folder structure (Python)

How to do overflow of image from left side instead of right side

Issues with Gatsby Shadowing

How do you sort a list of blog post tags by the number of posts that contain the tag (using Nunjucks in Eleventy)?

Problem with figure caption in responsive image gallery using HTML+CSS

How do I deploy a static site generated by Nextjs to Vercel?

Does Using React Context API In NextJS App Disable Static Site Generator?

how to place text e.g. with h4 tag next to icon?

How to save call_user_func_array() function output

QUESTION

Unable to use CloudFlare Pages to build due to gatsby.config invalid

Asked 2022-Feb-04 at 16:46

I used cloudflare pages' to build my site, but I encountered the error: Cannot read properties of undefined (reading 'split')`. The following is a complete cloudflare log:

123:36:39.607    Initializing build environment. This may take up to a few minutes to complete
223:39:21.372    Success: Finished initializing build environment
323:39:21.372    Cloning repository...
423:39:23.083    Success: Finished cloning repository files
523:39:23.211    Installing dependencies
623:39:23.215    Python version set to 2.7
723:39:24.367    Downloading and installing node v17.4.0...
823:39:24.548    Downloading https://nodejs.org/dist/v17.4.0/node-v17.4.0-linux-x64.tar.xz...
923:39:24.860    Computing checksum with sha256sum
1023:39:25.013    Checksums matched!
1123:39:28.569    Now using node v17.4.0 (npm v8.3.1)
1223:39:28.655    Started restoring cached build plugins
1323:39:28.659    Finished restoring cached build plugins
1423:39:28.808    Attempting ruby version 2.7.1, read from environment
1523:39:29.966    Using ruby version 2.7.1
1623:39:30.280    Using PHP version 5.6
1723:39:30.317    5.2 is already installed.
1823:39:30.325    Using Swift version 5.2
1923:39:30.325    Started restoring cached node modules
2023:39:30.328    Finished restoring cached node modules
2123:39:31.135    Found npm version (8.3.1) that doesn't match expected (8.4.1)
2223:39:31.135    Installing npm at version 8.4.1
2323:39:34.201    
2423:39:34.202    removed 1 package, changed 38 packages, and audited 217 packages in 3s
2523:39:34.202    
2623:39:34.202    11 packages are looking for funding
2723:39:34.202      run `npm fund` for details
2823:39:34.205    
2923:39:34.205    3 moderate severity vulnerabilities
3023:39:34.205    
3123:39:34.205    To address all issues, run:
3223:39:34.206      npm audit fix
3323:39:34.206    
3423:39:34.206    Run `npm audit` for details.
3523:39:34.217    NPM installed successfully
3623:39:34.658    Installing NPM modules using NPM version 8.4.1
3723:39:51.138    npm WARN deprecated urix@0.1.0: Please see https://github.com/lydell/urix#deprecated
3823:39:51.261    npm WARN deprecated resolve-url@0.2.1: https://github.com/lydell/resolve-url#deprecated
3923:39:51.353    npm WARN deprecated source-map-resolve@0.5.3: See https://github.com/lydell/source-map-resolve#deprecated
4023:39:51.996    npm WARN deprecated uuid@3.4.0: Please upgrade  to version 7 or higher.  Older versions may use Math.random() in certain circumstances, which is known to be problematic.  See https://v8.dev/blog/math-random for details.
4123:39:53.095    npm WARN deprecated request@2.88.2: request has been deprecated, see https://github.com/request/request/issues/3142
4223:39:54.180    npm WARN deprecated source-map-url@0.4.1: See https://github.com/lydell/source-map-url#deprecated
4323:39:54.852    npm WARN deprecated querystring@0.2.1: The querystring API is considered Legacy. new code should use the URLSearchParams API instead.
4423:39:59.626    npm WARN deprecated har-validator@5.1.5: this library is no longer supported
4523:40:04.403    npm WARN deprecated babel-eslint@10.1.0: babel-eslint is now @babel/eslint-parser. This package will no longer receive updates.
4623:40:05.052    npm WARN deprecated svgo@1.3.2: This SVGO version is no longer supported. Upgrade to v2.x.x.
4723:40:06.272    npm WARN deprecated @hapi/bourne@1.3.2: This version has been deprecated and is no longer supported or maintained
4823:40:06.971    npm WARN deprecated @hapi/address@2.1.4: Moved to 'npm install @sideway/address'
4923:40:13.245    npm WARN deprecated @hapi/joi@15.1.1: Switch to 'npm install joi'
5023:40:13.938    npm WARN deprecated @hapi/topo@3.1.6: This version has been deprecated and is no longer supported or maintained
5123:40:14.138    npm WARN deprecated @hapi/hoek@8.5.1: This version has been deprecated and is no longer supported or maintained
5223:40:14.754    npm WARN deprecated @hapi/hoek@8.5.1: This version has been deprecated and is no longer supported or maintained
5323:43:07.275    
5423:43:07.275    added 1961 packages, and audited 1962 packages in 4m
5523:43:07.275    
5623:43:07.275    272 packages are looking for funding
5723:43:07.275      run `npm fund` for details
5823:43:07.558    
5923:43:07.558    43 vulnerabilities (20 moderate, 21 high, 2 critical)
6023:43:07.558    
6123:43:07.558    To address issues that do not require attention, run:
6223:43:07.558      npm audit fix
6323:43:07.558    
6423:43:07.558    To address all issues (including breaking changes), run:
6523:43:07.558      npm audit fix --force
6623:43:07.558    
6723:43:07.558    Run `npm audit` for details.
6823:43:07.581    NPM modules installed
6923:43:08.028    Installing Hugo 0.54.0
7023:43:08.672    Hugo Static Site Generator v0.54.0-B1A82C61A/extended linux/amd64 BuildDate: 2019-02-01T10:04:38Z
7123:43:08.674    Started restoring cached go cache
7223:43:08.683    Finished restoring cached go cache
7323:43:08.763    go version go1.14.4 linux/amd64
7423:43:08.770    go version go1.14.4 linux/amd64
7523:43:08.771    Installing missing commands
7623:43:08.771    Verify run directory
7723:43:08.771    Executing user command: gatsby build
7823:43:09.178    tput: unknown terminal "unknown"
7923:43:09.180    ╔════════════════════════════════════════════════════════════════════════╗
8023:43:09.180    β•‘                                                                        β•‘
8123:43:09.180    β•‘   Gatsby collects anonymous usage analytics                            β•‘
8223:43:09.180    β•‘   to help improve Gatsby for all users.                                β•‘
8323:43:09.180    β•‘                                                                        β•‘
8423:43:09.180    β•‘   If you'd like to opt-out, you can use `gatsby telemetry --disable`   β•‘
8523:43:09.180    β•‘   To learn more, checkout https://gatsby.dev/telemetry                 β•‘
8623:43:09.180    β•‘                                                                        β•‘
8723:43:09.180    β•šβ•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•
8823:43:12.022    
8923:43:12.022     ERROR #10123  CONFIG
9023:43:12.023    
9123:43:12.023    We encountered an error while trying to load your site's gatsby-config. Please
9223:43:12.023    fix the error and try again.
9323:43:12.023    
9423:43:12.023    
9523:43:12.088    [2K[1A[2K[G
9623:43:12.089    [0m
9723:43:12.089    [0m  [0m[97m[41mTypeError[0m[37m[41m:[0m[37m[41m [0m[97m[41mCannot read properties of undefined (reading 'split')[0m
9823:43:12.089    [0m  [0m
9923:43:12.089    [0m  [0m[90m-[0m [0m[93mgatsby-config.js[0m[90m:[0m[93m30[0m[37m [0m[37mObject.<anonymous>[0m
10023:43:12.089    [0m  [0m  [0m[90m/opt/buildhome/repo/gatsby-config.js:30:67[0m
10123:43:12.089    [0m  [0m
10223:43:12.089    [0m  [0m[90m-[0m [0m[93mv8-compile-cache.js[0m[90m:[0m[93m192[0m[37m [0m[37mModule._compile[0m
10323:43:12.089    [0m  [0m  [0m[90m[repo]/[v8-compile-cache]/v8-compile-cache.js:192:30[0m
10423:43:12.089    [0m  [0m
10523:43:12.089    [0m  [0m[90m-[0m [0m[93mloader[0m[90m:[0m[93m1149[0m[37m [0m[37mObject.Module._extensions..js[0m
10623:43:12.089    [0m  [0m  [0m[90mnode:internal/modules/cjs/loader:1149:10[0m
10723:43:12.089    [0m  [0m
10823:43:12.089    [0m  [0m[90m-[0m [0m[93mloader[0m[90m:[0m[93m975[0m[37m [0m[37mModule.load[0m
10923:43:12.089    [0m  [0m  [0m[90mnode:internal/modules/cjs/loader:975:32[0m
11023:43:12.089    [0m  [0m
11123:43:12.089    [0m  [0m[90m-[0m [0m[93mloader[0m[90m:[0m[93m822[0m[37m [0m[37mFunction.Module._load[0m
11223:43:12.089    [0m  [0m  [0m[90mnode:internal/modules/cjs/loader:822:12[0m
11323:43:12.089    [0m  [0m
11423:43:12.089    [0m  [0m[90m-[0m [0m[93mloader[0m[90m:[0m[93m999[0m[37m [0m[37mModule.require[0m
11523:43:12.089    [0m  [0m  [0m[90mnode:internal/modules/cjs/loader:999:19[0m
11623:43:12.089    [0m  [0m
11723:43:12.089    [0m  [0m[90m-[0m [0m[93mv8-compile-cache.js[0m[90m:[0m[93m159[0m[37m [0m[37mrequire[0m
11823:43:12.089    [0m  [0m  [0m[90m[repo]/[v8-compile-cache]/v8-compile-cache.js:159:20[0m
11923:43:12.089    [0m  [0m
12023:43:12.089    [0m  [0m[90m-[0m [0m[93mget-config-file.ts[0m[90m:[0m[93m30[0m[37m [0m[37mgetConfigFile[0m
12123:43:12.089    [0m  [0m  [0m[90m[repo]/[gatsby]/src/bootstrap/get-config-file.ts:30:20[0m
12223:43:12.089    [0m  [0m
12323:43:12.089    [0m  [0m[90m-[0m [0m[93mload-config-and-plugins.ts[0m[90m:[0m[93m28[0m[37m [0m[37mloadConfigAndPlugins[0m
12423:43:12.089    [0m  [0m  [0m[90m[repo]/[gatsby]/src/bootstrap/load-config-and-plugins.ts:28:50[0m
12523:43:12.089    [0m  [0m
12623:43:12.089    [0m  [0m[90m-[0m [0m[93minitialize.ts[0m[90m:[0m[93m146[0m[37m [0m[37minitialize[0m
12723:43:12.089    [0m  [0m  [0m[90m[repo]/[gatsby]/src/services/initialize.ts:146:46[0m
12823:43:12.089    [0m  [0m
12923:43:12.089    [0m  [0m[90m-[0m [0m[93mindex.ts[0m[90m:[0m[93m47[0m[37m [0m[37mbootstrap[0m
13023:43:12.089    [0m  [0m  [0m[90m[repo]/[gatsby]/src/bootstrap/index.ts:47:15[0m
13123:43:12.089    [0m  [0m
13223:43:12.089    [0m  [0m[90m-[0m [0m[93mbuild.ts[0m[90m:[0m[93m94[0m[37m [0m[37mbuild[0m
13323:43:12.089    [0m  [0m  [0m[90m[repo]/[gatsby]/src/commands/build.ts:94:59[0m
13423:43:12.089    [0m  [0m
13523:43:12.089    [0m
13623:43:12.089    
13723:43:12.095    [2K[1A[2K[Gnot finished open and validate gatsby-configs, load plugins - 0.188s
13823:43:12.095    
13923:43:12.285    Failed: build command exited with code: 1
140

The strange thing is that local can build successfully, but cloudflare does not. I tried to specify the same node, npm, gatsby and gatsby-cli versions for cloudflare as local, but still this error.

Specifically, on CloudFlare Pages, I created two environment variables to specify Node and NPM versions.They are:

Variable name | Value
NODE_VERSION 17.4.0
NPM_VERSION 8.4.1

You can see from the logs that their versions have been successfully specified. For gatsby and gatsby-cli, I specified their versions as 3.14.6 and 4.6.1 respectively, which was changed in package.json.

Unfortunately, as I said before, the local build works, yet cloudflare still throws Cannot read properties of undefined (reading 'split') error. What is the problem? Is there any solution?

ANSWER

Answered 2022-Feb-04 at 16:46

I guess you have used the same approach to configure languages Kontent gatsby source plugin as it is in starters.

According to the error, I would guess your environment variables are not propagated to Cloudflare. So process.env.KONTENT_LANGUAGE_CODENAMES is undefined -> which causess the error cannot read properties of undefined (reading 'split') on gatsby-config.js:30:67.

Source https://stackoverflow.com/questions/70989536

QUESTION

Modify all files in specified directory (including subfolders) and saving them in new directory while presevering folder structure (Python)

Asked 2021-Dec-27 at 03:52

(I'm new to python so please excuse the probably trivial question. I tried my best looking for similar issues but suprisingly couldn't find someone with the same question.)

I'm trying to build a simple static site generator in Python. The script should take all .txt files in a specific directory (including subfolders), paste the content of each into a template .html file and then save all the newly generated .html files into a new directory while recreating the folder structure of the original directory.

So for I got the code which does the conversion itself for a single file but I'm unsure how to do it for multiple files in a directory.

1with open('template/page.html', 'r') as template:
2    templatedata = template.read()
3
4with open('content/content.txt', 'r') as content:
5    contentdata = content.read()
6
7pagedata = templatedata.replace('!PlaceholderContent!', contentdata)
8
9with open('www/content.html', 'w') as output:
10        output.write(pagedata)
11

ANSWER

Answered 2021-Dec-27 at 03:52

To manipulate files and directories, you will need to import some system functionalites under the built-in module os.

1with open('template/page.html', 'r') as template:
2    templatedata = template.read()
3
4with open('content/content.txt', 'r') as content:
5    contentdata = content.read()
6
7pagedata = templatedata.replace('!PlaceholderContent!', contentdata)
8
9with open('www/content.html', 'w') as output:
10        output.write(pagedata)
11import os
12

The functionalities under the os module include :

  • Listing the content of a directory :

1with open('template/page.html', 'r') as template:
2    templatedata = template.read()
3
4with open('content/content.txt', 'r') as content:
5    contentdata = content.read()
6
7pagedata = templatedata.replace('!PlaceholderContent!', contentdata)
8
9with open('www/content.html', 'w') as output:
10        output.write(pagedata)
11import os
12path_to_template_dir = 'template/'
13template_files = os.listdir(path_to_template_dir)
14print(template_files)   
15# Outputs : ['page.html']
16
  • Creating a directory (If it does not already exist) :

  • 1with open('template/page.html', 'r') as template:
    2    templatedata = template.read()
    3
    4with open('content/content.txt', 'r') as content:
    5    contentdata = content.read()
    6
    7pagedata = templatedata.replace('!PlaceholderContent!', contentdata)
    8
    9with open('www/content.html', 'w') as output:
    10        output.write(pagedata)
    11import os
    12path_to_template_dir = 'template/'
    13template_files = os.listdir(path_to_template_dir)
    14print(template_files)   
    15# Outputs : ['page.html']
    16path_to_output_dir = 'www/'
    17try : 
    18    os.mkdir(path_to_output_dir)
    19except FileExistsError as e:
    20    print('Directory exists:', path_to_output_dir)
    21

    And since you know the names of the directories you want to use, and using these two functions, you now know the names of the files you want to use and generate, you can now concatenate the name of each file to the names of its directories to create the string str of the final file path, which you can then open() for reading and/or writing.

    It's hard to give a perfect code example for your question since the logic of how you want to manipulate each of the template and content file is missing, but here is an example for writing a file inside the newly created directory :

    1with open('template/page.html', 'r') as template:
    2    templatedata = template.read()
    3
    4with open('content/content.txt', 'r') as content:
    5    contentdata = content.read()
    6
    7pagedata = templatedata.replace('!PlaceholderContent!', contentdata)
    8
    9with open('www/content.html', 'w') as output:
    10        output.write(pagedata)
    11import os
    12path_to_template_dir = 'template/'
    13template_files = os.listdir(path_to_template_dir)
    14print(template_files)   
    15# Outputs : ['page.html']
    16path_to_output_dir = 'www/'
    17try : 
    18    os.mkdir(path_to_output_dir)
    19except FileExistsError as e:
    20    print('Directory exists:', path_to_output_dir)
    21path_to_output_file = path_to_output_dir + 'content.html'
    22
    23with open(path_to_output_file, 'w') as output:
    24    output.write('Content')
    25

    And an example for reading all the template files inside the template/ directory and then printing them to the screen.

    1with open('template/page.html', 'r') as template:
    2    templatedata = template.read()
    3
    4with open('content/content.txt', 'r') as content:
    5    contentdata = content.read()
    6
    7pagedata = templatedata.replace('!PlaceholderContent!', contentdata)
    8
    9with open('www/content.html', 'w') as output:
    10        output.write(pagedata)
    11import os
    12path_to_template_dir = 'template/'
    13template_files = os.listdir(path_to_template_dir)
    14print(template_files)   
    15# Outputs : ['page.html']
    16path_to_output_dir = 'www/'
    17try : 
    18    os.mkdir(path_to_output_dir)
    19except FileExistsError as e:
    20    print('Directory exists:', path_to_output_dir)
    21path_to_output_file = path_to_output_dir + 'content.html'
    22
    23with open(path_to_output_file, 'w') as output:
    24    output.write('Content')
    25for template_file in template_files:
    26    path_to_template_file = path_to_template_dir + template_file
    27    with open(path_to_template_file, 'r') as template:
    28        print(template.read())
    29

    In the end, manipulating files is all about creating the path string you want to read from or write to, and then accessing it.

    Anymore functionalities you might need (for example : checking if a path is a file os.path.isfile() or if it's for a directory os.path.isdir() can be found under the os module.

    Source https://stackoverflow.com/questions/70491135

    QUESTION

    How to do overflow of image from left side instead of right side

    Asked 2021-Dec-20 at 16:07

    1`
    2/*======================CONTENT========================*/
    3
    4.content {
    5  padding: 110px 30px;
    6  overflow: hidden;
    7}
    8
    9.content__inner {
    10  display: grid;
    11  grid-template-columns: 1fr 2fr;
    12  column-gap: 50px;
    13  margin: 80px 0 0;
    14  color: var(--blue-two);
    15}
    16
    17.content__title {
    18  font-size: 59px;
    19  font-weight: 500;
    20  color: var(--blue-two);
    21  text-align: center;
    22}
    23
    24.card {
    25  font-size: 23px;
    26  line-height: 1.5;
    27  text-align: left;
    28  padding: 22.5px;
    29}
    30
    31.card:first-child {
    32  background-color: var(--white-two);
    33  border-radius: 5px;
    34}
    35
    36.card:first-child .card__title {
    37  color: var(--blue-one);
    38}
    39
    40.card__subtitle {
    41  font-weight: 300;
    42}
    43
    44.content__img {
    45  width: 130%;
    46  border-radius: 5px;
    47  margin: auto 0;
    48}
    49
    50
    51/*======================TOOLS========================*/
    52
    53.tools {
    54  background-color: var(--white-two);
    55  padding: 110px;
    56  border: 1px solid red;
    57}
    58
    59.container {
    60  border: 1px solid blue;
    61}
    62
    63.tools__inner {
    64  display: grid;
    65  grid-template-columns: 2fr 1fr;
    66  column-gap: 50px;
    67  margin: 80px 0 0;
    68  border: 1px solid green;
    69}
    70
    71.tools__img {
    72  width: 100%;
    73}
    74
    75.tools__text {
    76  text-align: left;
    77}
    78
    79.tools__title {
    80  font-size: 49px;
    81  color: #e56134;
    82  margin: 0 0 16px;
    83}
    84
    85.tools__subtitle {
    86  font-weight: 300;
    87  font-size: 23px;
    88  line-height: 1.5;
    89  margin: 0 0 32px;
    90}
    91
    92.tools__logos {
    93  margin: 10px 0 0;
    94}
    95
    96`
    1`
    2/*======================CONTENT========================*/
    3
    4.content {
    5  padding: 110px 30px;
    6  overflow: hidden;
    7}
    8
    9.content__inner {
    10  display: grid;
    11  grid-template-columns: 1fr 2fr;
    12  column-gap: 50px;
    13  margin: 80px 0 0;
    14  color: var(--blue-two);
    15}
    16
    17.content__title {
    18  font-size: 59px;
    19  font-weight: 500;
    20  color: var(--blue-two);
    21  text-align: center;
    22}
    23
    24.card {
    25  font-size: 23px;
    26  line-height: 1.5;
    27  text-align: left;
    28  padding: 22.5px;
    29}
    30
    31.card:first-child {
    32  background-color: var(--white-two);
    33  border-radius: 5px;
    34}
    35
    36.card:first-child .card__title {
    37  color: var(--blue-one);
    38}
    39
    40.card__subtitle {
    41  font-weight: 300;
    42}
    43
    44.content__img {
    45  width: 130%;
    46  border-radius: 5px;
    47  margin: auto 0;
    48}
    49
    50
    51/*======================TOOLS========================*/
    52
    53.tools {
    54  background-color: var(--white-two);
    55  padding: 110px;
    56  border: 1px solid red;
    57}
    58
    59.container {
    60  border: 1px solid blue;
    61}
    62
    63.tools__inner {
    64  display: grid;
    65  grid-template-columns: 2fr 1fr;
    66  column-gap: 50px;
    67  margin: 80px 0 0;
    68  border: 1px solid green;
    69}
    70
    71.tools__img {
    72  width: 100%;
    73}
    74
    75.tools__text {
    76  text-align: left;
    77}
    78
    79.tools__title {
    80  font-size: 49px;
    81  color: #e56134;
    82  margin: 0 0 16px;
    83}
    84
    85.tools__subtitle {
    86  font-weight: 300;
    87  font-size: 23px;
    88  line-height: 1.5;
    89  margin: 0 0 32px;
    90}
    91
    92.tools__logos {
    93  margin: 10px 0 0;
    94}
    95
    96``============CONTENT SECTION===============
    97<section class="content">
    98  <div class="container">
    99    <div class="content__title">Content management <br> for the whole team</div>
    100    <div class="content__inner">
    101
    102      <div class="content-cards">`enter code here`
    103        <div class="card">
    104          <div class="card__title">Collaborate</div>
    105          <div class="card__subtitle">Invite your client or team to create and edit content. Set them as Admin, Publisher, or Writer.
    106          </div>
    107        </div>
    108        <div class="card">
    109          <div class="card__title">Preview before you publish</div>
    110          <div class="card__subtitle">Preview changes before they go live. Then publish with one click whenever you’re ready.
    111          </div>
    112        </div>
    113        <div class="card">
    114          <div class="card__title">Smart text editor</div>
    115          <div class="card__subtitle">Choose between a visual editor or just plain Markdown. Drag and drop images or even entire text files.
    116          </div>
    117        </div>
    118        <div class="card">
    119          <div class="card__title">Powerful content</div>
    120          <div class="card__subtitle">Customize your site with document collections, advanced metadata, and custom permalinks.
    121          </div>
    122        </div>
    123      </div>
    124
    125      <img src="img/content__pic1.jpg" alt="" class="content__img">
    126
    127    </div>
    128  </div>
    129</section>
    130
    131============TOOLS SECTION===============
    132<section class="tools">
    133  <div class="container">
    134    <div class="content__title">Develop with tools you <br> already love</div>
    135
    136    <div class="tools__inner">
    137      <img src="img/tools_pic1.jpg" alt="tools1" class="tools__img">
    138      <div class="tools__text">
    139        <div class="tools__title">Built on open source</div>
    140        <div class="tools__subtitle">Siteleaf is compatible with Jekyll, the static site generator for over half a million websites running on GitHub Pages.
    141        </div>
    142        <div class="tools__subtitle">
    143          Benefit from a large open source community. Use any existing Jekyll theme, or write your own using Liquid, Sass, and CoffeeScript. Develop locally and even offline.
    144        </div>
    145        <img src="img/tools__logos.svg" alt="logos" class="tools__logos">
    146      </div>
    147    </div>
    148  </div>
    149</section>

    Content section

    Tools section

    content__pic1.jpg

    tools__pic1.jpg

    As you can see the Content section(Screenshot below) is as Tools section(Screenshot below) but in reverse, how can I place Tools image as in Content section ? I need the overflow of tools__img1.jpg from left side not from right! How can I do that?

    ANSWER

    Answered 2021-Dec-20 at 16:07

    Put this css below into your component's css. The img element in the container align right and overflow from left.

    1`
    2/*======================CONTENT========================*/
    3
    4.content {
    5  padding: 110px 30px;
    6  overflow: hidden;
    7}
    8
    9.content__inner {
    10  display: grid;
    11  grid-template-columns: 1fr 2fr;
    12  column-gap: 50px;
    13  margin: 80px 0 0;
    14  color: var(--blue-two);
    15}
    16
    17.content__title {
    18  font-size: 59px;
    19  font-weight: 500;
    20  color: var(--blue-two);
    21  text-align: center;
    22}
    23
    24.card {
    25  font-size: 23px;
    26  line-height: 1.5;
    27  text-align: left;
    28  padding: 22.5px;
    29}
    30
    31.card:first-child {
    32  background-color: var(--white-two);
    33  border-radius: 5px;
    34}
    35
    36.card:first-child .card__title {
    37  color: var(--blue-one);
    38}
    39
    40.card__subtitle {
    41  font-weight: 300;
    42}
    43
    44.content__img {
    45  width: 130%;
    46  border-radius: 5px;
    47  margin: auto 0;
    48}
    49
    50
    51/*======================TOOLS========================*/
    52
    53.tools {
    54  background-color: var(--white-two);
    55  padding: 110px;
    56  border: 1px solid red;
    57}
    58
    59.container {
    60  border: 1px solid blue;
    61}
    62
    63.tools__inner {
    64  display: grid;
    65  grid-template-columns: 2fr 1fr;
    66  column-gap: 50px;
    67  margin: 80px 0 0;
    68  border: 1px solid green;
    69}
    70
    71.tools__img {
    72  width: 100%;
    73}
    74
    75.tools__text {
    76  text-align: left;
    77}
    78
    79.tools__title {
    80  font-size: 49px;
    81  color: #e56134;
    82  margin: 0 0 16px;
    83}
    84
    85.tools__subtitle {
    86  font-weight: 300;
    87  font-size: 23px;
    88  line-height: 1.5;
    89  margin: 0 0 32px;
    90}
    91
    92.tools__logos {
    93  margin: 10px 0 0;
    94}
    95
    96``============CONTENT SECTION===============
    97<section class="content">
    98  <div class="container">
    99    <div class="content__title">Content management <br> for the whole team</div>
    100    <div class="content__inner">
    101
    102      <div class="content-cards">`enter code here`
    103        <div class="card">
    104          <div class="card__title">Collaborate</div>
    105          <div class="card__subtitle">Invite your client or team to create and edit content. Set them as Admin, Publisher, or Writer.
    106          </div>
    107        </div>
    108        <div class="card">
    109          <div class="card__title">Preview before you publish</div>
    110          <div class="card__subtitle">Preview changes before they go live. Then publish with one click whenever you’re ready.
    111          </div>
    112        </div>
    113        <div class="card">
    114          <div class="card__title">Smart text editor</div>
    115          <div class="card__subtitle">Choose between a visual editor or just plain Markdown. Drag and drop images or even entire text files.
    116          </div>
    117        </div>
    118        <div class="card">
    119          <div class="card__title">Powerful content</div>
    120          <div class="card__subtitle">Customize your site with document collections, advanced metadata, and custom permalinks.
    121          </div>
    122        </div>
    123      </div>
    124
    125      <img src="img/content__pic1.jpg" alt="" class="content__img">
    126
    127    </div>
    128  </div>
    129</section>
    130
    131============TOOLS SECTION===============
    132<section class="tools">
    133  <div class="container">
    134    <div class="content__title">Develop with tools you <br> already love</div>
    135
    136    <div class="tools__inner">
    137      <img src="img/tools_pic1.jpg" alt="tools1" class="tools__img">
    138      <div class="tools__text">
    139        <div class="tools__title">Built on open source</div>
    140        <div class="tools__subtitle">Siteleaf is compatible with Jekyll, the static site generator for over half a million websites running on GitHub Pages.
    141        </div>
    142        <div class="tools__subtitle">
    143          Benefit from a large open source community. Use any existing Jekyll theme, or write your own using Liquid, Sass, and CoffeeScript. Develop locally and even offline.
    144        </div>
    145        <img src="img/tools__logos.svg" alt="logos" class="tools__logos">
    146      </div>
    147    </div>
    148  </div>
    149</section>// index.html
    150<div class="img-container">
    151    <img src="your-image.png"/>
    152</div>
    153
    1`
    2/*======================CONTENT========================*/
    3
    4.content {
    5  padding: 110px 30px;
    6  overflow: hidden;
    7}
    8
    9.content__inner {
    10  display: grid;
    11  grid-template-columns: 1fr 2fr;
    12  column-gap: 50px;
    13  margin: 80px 0 0;
    14  color: var(--blue-two);
    15}
    16
    17.content__title {
    18  font-size: 59px;
    19  font-weight: 500;
    20  color: var(--blue-two);
    21  text-align: center;
    22}
    23
    24.card {
    25  font-size: 23px;
    26  line-height: 1.5;
    27  text-align: left;
    28  padding: 22.5px;
    29}
    30
    31.card:first-child {
    32  background-color: var(--white-two);
    33  border-radius: 5px;
    34}
    35
    36.card:first-child .card__title {
    37  color: var(--blue-one);
    38}
    39
    40.card__subtitle {
    41  font-weight: 300;
    42}
    43
    44.content__img {
    45  width: 130%;
    46  border-radius: 5px;
    47  margin: auto 0;
    48}
    49
    50
    51/*======================TOOLS========================*/
    52
    53.tools {
    54  background-color: var(--white-two);
    55  padding: 110px;
    56  border: 1px solid red;
    57}
    58
    59.container {
    60  border: 1px solid blue;
    61}
    62
    63.tools__inner {
    64  display: grid;
    65  grid-template-columns: 2fr 1fr;
    66  column-gap: 50px;
    67  margin: 80px 0 0;
    68  border: 1px solid green;
    69}
    70
    71.tools__img {
    72  width: 100%;
    73}
    74
    75.tools__text {
    76  text-align: left;
    77}
    78
    79.tools__title {
    80  font-size: 49px;
    81  color: #e56134;
    82  margin: 0 0 16px;
    83}
    84
    85.tools__subtitle {
    86  font-weight: 300;
    87  font-size: 23px;
    88  line-height: 1.5;
    89  margin: 0 0 32px;
    90}
    91
    92.tools__logos {
    93  margin: 10px 0 0;
    94}
    95
    96``============CONTENT SECTION===============
    97<section class="content">
    98  <div class="container">
    99    <div class="content__title">Content management <br> for the whole team</div>
    100    <div class="content__inner">
    101
    102      <div class="content-cards">`enter code here`
    103        <div class="card">
    104          <div class="card__title">Collaborate</div>
    105          <div class="card__subtitle">Invite your client or team to create and edit content. Set them as Admin, Publisher, or Writer.
    106          </div>
    107        </div>
    108        <div class="card">
    109          <div class="card__title">Preview before you publish</div>
    110          <div class="card__subtitle">Preview changes before they go live. Then publish with one click whenever you’re ready.
    111          </div>
    112        </div>
    113        <div class="card">
    114          <div class="card__title">Smart text editor</div>
    115          <div class="card__subtitle">Choose between a visual editor or just plain Markdown. Drag and drop images or even entire text files.
    116          </div>
    117        </div>
    118        <div class="card">
    119          <div class="card__title">Powerful content</div>
    120          <div class="card__subtitle">Customize your site with document collections, advanced metadata, and custom permalinks.
    121          </div>
    122        </div>
    123      </div>
    124
    125      <img src="img/content__pic1.jpg" alt="" class="content__img">
    126
    127    </div>
    128  </div>
    129</section>
    130
    131============TOOLS SECTION===============
    132<section class="tools">
    133  <div class="container">
    134    <div class="content__title">Develop with tools you <br> already love</div>
    135
    136    <div class="tools__inner">
    137      <img src="img/tools_pic1.jpg" alt="tools1" class="tools__img">
    138      <div class="tools__text">
    139        <div class="tools__title">Built on open source</div>
    140        <div class="tools__subtitle">Siteleaf is compatible with Jekyll, the static site generator for over half a million websites running on GitHub Pages.
    141        </div>
    142        <div class="tools__subtitle">
    143          Benefit from a large open source community. Use any existing Jekyll theme, or write your own using Liquid, Sass, and CoffeeScript. Develop locally and even offline.
    144        </div>
    145        <img src="img/tools__logos.svg" alt="logos" class="tools__logos">
    146      </div>
    147    </div>
    148  </div>
    149</section>// index.html
    150<div class="img-container">
    151    <img src="your-image.png"/>
    152</div>
    153// index.css
    154.img-container {
    155    display: flex;
    156    justify-content: end;
    157}
    158
    159

    Source https://stackoverflow.com/questions/70423808

    QUESTION

    Issues with Gatsby Shadowing

    Asked 2021-Nov-05 at 20:54

    I am using the @lekoarts gatsby-theme-minimal-blog. You can view my code here: https://github.com/CodyWMitchell/my-site

    I feel like I am losing hair because of how much time I have spent trying to get this working. I am running Gatsby locally, and I've somehow successfully shadowed the footer component. I want to shadow the header component, but for some reason nothing is working at all.

    In the lekoarts theme, the footer is in the same folder location as the header component, but when I add a file called header.tsx to overwrite the other header.tsx in the same location as the footer that is successfully shadowing nothing happens. I tried adding it in every other possible place I can think of, restarting the local build, and I'm at my wits end.

    Here's the kicker, when I remove footer.tsx from the local src directory I added it to, It gives me an error now? Why would it give me an error for a file not existing that wasn't even there in the theme to begin with until I added it?

    enter image description here

    I really (really) want to give a static site generator a shot, but this feels extremely frustrating for something that should be simple, and it's discouraging me for suggesting something like this for any kind of complex project.

    Any help or advice would be much appreciated.

    ANSWER

    Answered 2021-Nov-05 at 09:21

    Try to clean .cache folder and re-run the dev. Every time you "shadow" or change the components in theme folder, you should do it.

    Just run gatsby clean or npm run clean - I saw that script in your repo.

    Source https://stackoverflow.com/questions/69848307

    QUESTION

    How do you sort a list of blog post tags by the number of posts that contain the tag (using Nunjucks in Eleventy)?

    Asked 2021-Sep-16 at 01:47

    I have a blog built with Eleventy (static site generator), using Nunjucks as the templating language.

    I have a page that lists all the tags I've assigned to my posts. It lists them in alphabetical order, with the number of posts per tag.

    What I'd also like to do is list the tags in order of frequency (most-used tags first).

    The code that works to get the alphabetical list (with counts) looks like this:

    1<section id="tags-number-of-posts">
    2  {% for tag2, posts2 in collections | dictsort %}
    3  {% set tag2Url %}/tags/{{ tag2 | slug }}/{% endset %}
    4   <a href="{{ tag2Url | url }}">{{ tag2 }} ({{ posts2 | length }})</a><br/>
    5  {% endfor %}
    6</section>
    7

    The result now is like:

    Blender (1)
    boats (2)
    Bomb Factory (1)
    bonfires (4)
    books (3)

    but I'd like it to be:

    bonfires (4)
    books (3)
    boats (2)
    Blender (1)
    Bomb Factory (1)

    (You can see the actual result at this deploy preview site: https://text-timeline--davidrhoden-basic.netlify.app/tagslist/ .)

    I've tried changing dictsort to sort(attribute="posts2.length"), as well as other permutations that might make sense, like sort(attribute="length"), but nothing has worked.

    I guess "length" is not an attribute of the posts themselves. So maybe a filter like sort won't work in this context.

    But is there a way to sort this list by those post counts? Surely there must be. Do I need to bring in something like lodash, or some javascript function like map?

    ANSWER

    Answered 2021-Sep-16 at 01:47

    You might be able to use Eleventy custom collections to do what you want. We can use Javascript in the .eleventy.js file to count the number of posts in each tag, then sort the data by the number of posts.

    Since Eleventy doesn't seem to give us a pre-grouped object of tags and posts, we're doing that ourselves. This does mean that if you put duplicate tags on one post, it will be counted twice. It is possible to de-dupe the tags, but it shouldn't be an issue if you're careful.

    1<section id="tags-number-of-posts">
    2  {% for tag2, posts2 in collections | dictsort %}
    3  {% set tag2Url %}/tags/{{ tag2 | slug }}/{% endset %}
    4   <a href="{{ tag2Url | url }}">{{ tag2 }} ({{ posts2 | length }})</a><br/>
    5  {% endfor %}
    6</section>
    7// .eleventy.js
    8module.exports = function (eleventyConfig) {
    9  // ...
    10
    11  // addCollection receives the new collection's name and a
    12  // callback that can return any arbitrary data (since v0.5.3)
    13  eleventyConfig.addCollection('bySize', (collectionApi) => {
    14    // see https://www.11ty.dev/docs/collections/#getall()
    15    const allPosts = collectionApi.getAll()
    16
    17    // https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Map
    18    const countPostsByTag = new Map()
    19    allPosts.forEach((post) => {
    20      // short circuit eval sets tags to an empty array if there are no tags set
    21      const tags = post.data.tags || []
    22      tags.forEach((tag) => {
    23        const count = countPostsByTag.get(tag) || 0
    24        countPostsByTag.set(tag, count + 1)
    25      })
    26    })
    27
    28    // Maps are iterators so we spread it into an array to sort
    29    // https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Map/entries
    30    // https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/sort
    31    const sortedArray = [...countPostsByTag].sort((a, b) => b[1] - a[1])
    32    
    33    // this function returns an array of [tag, count] pairs sorted by count
    34    // [['bonfires', 4], ['books', 3], ['boats', 2], ...]
    35    return sortedArray
    36  })
    37  })
    38
    39  return {
    40    // ...
    41  }
    42}
    43

    We can then use this data in Nunjucks with collections.bySize.

    1<section id="tags-number-of-posts">
    2  {% for tag2, posts2 in collections | dictsort %}
    3  {% set tag2Url %}/tags/{{ tag2 | slug }}/{% endset %}
    4   <a href="{{ tag2Url | url }}">{{ tag2 }} ({{ posts2 | length }})</a><br/>
    5  {% endfor %}
    6</section>
    7// .eleventy.js
    8module.exports = function (eleventyConfig) {
    9  // ...
    10
    11  // addCollection receives the new collection's name and a
    12  // callback that can return any arbitrary data (since v0.5.3)
    13  eleventyConfig.addCollection('bySize', (collectionApi) => {
    14    // see https://www.11ty.dev/docs/collections/#getall()
    15    const allPosts = collectionApi.getAll()
    16
    17    // https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Map
    18    const countPostsByTag = new Map()
    19    allPosts.forEach((post) => {
    20      // short circuit eval sets tags to an empty array if there are no tags set
    21      const tags = post.data.tags || []
    22      tags.forEach((tag) => {
    23        const count = countPostsByTag.get(tag) || 0
    24        countPostsByTag.set(tag, count + 1)
    25      })
    26    })
    27
    28    // Maps are iterators so we spread it into an array to sort
    29    // https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Map/entries
    30    // https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/sort
    31    const sortedArray = [...countPostsByTag].sort((a, b) => b[1] - a[1])
    32    
    33    // this function returns an array of [tag, count] pairs sorted by count
    34    // [['bonfires', 4], ['books', 3], ['boats', 2], ...]
    35    return sortedArray
    36  })
    37  })
    38
    39  return {
    40    // ...
    41  }
    42}
    43<section id="tags-number-of-posts">
    44    {# we can still destructure the tag name and count even though it's an array #}
    45    {% for tag, count in collections.bySize %}
    46        {% set tagUrl %}/tags/{{ tag | slug }}/{% endset %}
    47        <a href="{{ tagUrl | url }}">{{ tag }} ({{ count }})</a><br/>
    48    {% endfor %}
    49</section>
    50

    If you need to have the array of posts in your collections object and not just the number of posts, it is also possible to modify the JavaScript to do so.

    Source https://stackoverflow.com/questions/69198527

    QUESTION

    Problem with figure caption in responsive image gallery using HTML+CSS

    Asked 2021-Sep-09 at 21:33

    I'm currently making a (static) website from scratch (so code the HTML and CSS stuff myself), and I want to have a responsive "image gallery" that changes the width of the pictures according to your screen width, so I followed this tutorial: CSS Image Gallery - responsive

    However, changing it to my own likings I encountered an issue I could not fix with my current HTML/CSS skillset (it is not that much, I'm quite new in this). My problem is when I have (in my example three) images of the same size in my gallery, but the captions of the image have different length, this negatively affects the text that is followed by the gallery (see example and image below). I tried to fix this with the tutorials available at W3 and stuff, but nothing worked yet.

    Does any of you how to (easily) fix this? And if so, please explain what you changed, because I want to truly understand what is going on at my website (that is why I didn't want to use these static site generators).

    Note: I have made 3 types of galleries, one for two, three and four images, which explains the ".responsivethree" etc classes

    enter image description here

    1<!DOCTYPE html>
    2<html lang="en-NL">
    3<head>
    4  <meta charset="UTF-8">
    5  <meta name="viewport" content="width=device-width, initial-scale=1.0">
    6  <title>Example</title>
    7  <style type="text/css">
    8    body {
    9    font-family: helvetica;
    10    padding: 20px;
    11    font-size:11pt;
    12}
    13
    14header {
    15    max-width: 800px;
    16}
    17
    18main {
    19    max-width: 800px;
    20}
    21
    22section {
    23    padding-left: 15px;
    24    border-left: 1px solid rgb(223, 223, 223);
    25    border-radius: 5px;
    26}
    27
    28footer {
    29    max-width: 800px;
    30}
    31
    32
    33div.gallery {
    34  padding: 0px;
    35}
    36
    37div.gallery img {
    38  width: 98%;
    39  height: auto;
    40  display: block;
    41  margin-left: auto;
    42  margin-right: auto;
    43}
    44
    45div.desc {
    46  padding: 2px;
    47  padding-bottom: 5px;
    48  text-align: center;
    49  color: gray;
    50  font-size: 85%;
    51}
    52
    53* {
    54  box-sizing: border-box;
    55}
    56
    57.responsivefour {
    58  padding: 0 6px;
    59  float: left;
    60  width: 24.99999%;
    61}
    62
    63.responsivethree {
    64  padding: 0 6px;
    65  float: left;
    66  width: 33.32%;
    67}
    68
    69.responsivetwo {
    70  padding: 0 6px;
    71  float: left;
    72  width: 49.9988%;
    73}
    74
    75@media only screen and (max-width: 700px) {
    76  .responsivefour {
    77    width: 49.99999%;
    78    margin: 6px 0;
    79  }
    80}
    81
    82@media only screen and (max-width: 500px) {
    83  .responsivefour {
    84    width: 100%;
    85  }
    86  .responsivethree {
    87    width: 100%;
    88  }
    89  .responsivetwo {
    90    width: 100%;
    91  }
    92}
    93
    94.clearfix:after {
    95  content: "";
    96  display: table;
    97  clear: both;
    98}
    99  </style>
    100</head>
    101<body>
    102<!-- #################################################################### -->
    103<header  id="top">
    104    <h1>Header</h1>
    105</header>
    106<!-- #################################################################### -->
    107<main>
    108<article id="test">
    109    <h2>bla</h2>
    110    <section>
    111        <p>
    112            Lorem ipsum dolor sit amet, consectetuer adipiscing elit. Etiamlobortis facilisis sem. Nullam nec mi et neque pharetrasollicitudin. Praesent imperdiet mi nec ante. Donec ullamcorper,felis non sodales commodo, lectus velit ultrices augue, adignissim nibh lectus placerat pede. Vivamus nunc nunc, molestieut, ultricies vel, semper in, velit. Ut porttitor. Praesent in sapien. Lorem ipsum dolor sit amet, consectetuer adipiscing elit. Duis fringilla tristique neque. Sed interdum libero ut metus. Pellentesque placerat. Nam rutrum augue a leo. Morbi sed elit sit amet ante lobortis sollicitudin. Praesent blandit blandit mauris. Praesent lectus tellus, aliquet aliquam, luctus a, egestas a, turpis. Mauris lacinia lorem sit amet ipsum. Nunc quis urna dictum turpis accumsan semper. 
    113        </p>
    114        <div class="responsivethree">
    115            <div class="gallery">
    116                <img src="https://www.w3schools.com/images/w3schools_green.jpg" alt="image 1">
    117          <div class="desc">--- short description ---</div>
    118            </div>
    119        </div>
    120        <div class="responsivethree">
    121            <div class="gallery">
    122            <img src="https://www.w3schools.com/images/w3schools_green.jpg" alt="image 2" >
    123              <div class="desc">--- Very, utterly, super uber mega long description, don't you think, geeeeeez! ---</div>
    124            </div>
    125        </div>
    126        <div class="responsivethree">
    127            <div class="gallery">
    128            <img src="https://www.w3schools.com/images/w3schools_green.jpg" alt="image 3" >
    129              <div class="desc">--- stuff ---</div>
    130            </div>
    131      </div>
    132        <p>
    133            <b>This is my problem...</b> Lorem ipsum dolor sit amet, consectetuer adipiscing elit. Etiamlobortis facilisis sem. Nullam nec mi et neque pharetrasollicitudin. Praesent imperdiet mi nec ante. Donec ullamcorper,felis non sodales commodo, lectus velit ultrices augue, adignissim nibh lectus placerat pede. Vivamus nunc nunc, molestieut, ultricies vel, semper in, velit. Ut porttitor. Praesent in sapien. Lorem ipsum dolor sit amet, consectetuer adipiscing elit. Duis fringilla tristique neque. Sed interdum libero ut metus. Pellentesque placerat. Nam rutrum augue a leo. Morbi sed elit sit amet ante lobortis sollicitudin. Praesent blandit blandit mauris. Praesent lectus tellus, aliquet aliquam, luctus a, egestas a, turpis. Mauris lacinia lorem sit amet ipsum. Nunc quis urna dictum turpis accumsan semper.
    134        </p>
    135    </section>
    136</article>
    137</main>
    138<!-- #################################################################### -->
    139<footer>
    140    <p style="text-align: center;">footer tooter</p>
    141</footer>
    142<!-- #################################################################### -->
    143</body>
    144</html>

    ANSWER

    Answered 2021-Sep-09 at 21:33

    The float:left property you gave to the responsivethree class aligns the images to the left. Since you did not reset the left justification feature afterward, you are having a problem with the text scrolling. The clear:both command is used to reset the float:left property.

    1<!DOCTYPE html>
    2<html lang="en-NL">
    3<head>
    4  <meta charset="UTF-8">
    5  <meta name="viewport" content="width=device-width, initial-scale=1.0">
    6  <title>Example</title>
    7  <style type="text/css">
    8    body {
    9    font-family: helvetica;
    10    padding: 20px;
    11    font-size:11pt;
    12}
    13
    14header {
    15    max-width: 800px;
    16}
    17
    18main {
    19    max-width: 800px;
    20}
    21
    22section {
    23    padding-left: 15px;
    24    border-left: 1px solid rgb(223, 223, 223);
    25    border-radius: 5px;
    26}
    27
    28footer {
    29    max-width: 800px;
    30}
    31
    32
    33div.gallery {
    34  padding: 0px;
    35}
    36
    37div.gallery img {
    38  width: 98%;
    39  height: auto;
    40  display: block;
    41  margin-left: auto;
    42  margin-right: auto;
    43}
    44
    45div.desc {
    46  padding: 2px;
    47  padding-bottom: 5px;
    48  text-align: center;
    49  color: gray;
    50  font-size: 85%;
    51}
    52
    53* {
    54  box-sizing: border-box;
    55}
    56
    57.responsivefour {
    58  padding: 0 6px;
    59  float: left;
    60  width: 24.99999%;
    61}
    62
    63.responsivethree {
    64  padding: 0 6px;
    65  float: left;
    66  width: 33.32%;
    67}
    68
    69.responsivetwo {
    70  padding: 0 6px;
    71  float: left;
    72  width: 49.9988%;
    73}
    74
    75@media only screen and (max-width: 700px) {
    76  .responsivefour {
    77    width: 49.99999%;
    78    margin: 6px 0;
    79  }
    80}
    81
    82@media only screen and (max-width: 500px) {
    83  .responsivefour {
    84    width: 100%;
    85  }
    86  .responsivethree {
    87    width: 100%;
    88  }
    89  .responsivetwo {
    90    width: 100%;
    91  }
    92}
    93
    94.clearfix:after {
    95  content: "";
    96  display: table;
    97  clear: both;
    98}
    99  </style>
    100</head>
    101<body>
    102<!-- #################################################################### -->
    103<header  id="top">
    104    <h1>Header</h1>
    105</header>
    106<!-- #################################################################### -->
    107<main>
    108<article id="test">
    109    <h2>bla</h2>
    110    <section>
    111        <p>
    112            Lorem ipsum dolor sit amet, consectetuer adipiscing elit. Etiamlobortis facilisis sem. Nullam nec mi et neque pharetrasollicitudin. Praesent imperdiet mi nec ante. Donec ullamcorper,felis non sodales commodo, lectus velit ultrices augue, adignissim nibh lectus placerat pede. Vivamus nunc nunc, molestieut, ultricies vel, semper in, velit. Ut porttitor. Praesent in sapien. Lorem ipsum dolor sit amet, consectetuer adipiscing elit. Duis fringilla tristique neque. Sed interdum libero ut metus. Pellentesque placerat. Nam rutrum augue a leo. Morbi sed elit sit amet ante lobortis sollicitudin. Praesent blandit blandit mauris. Praesent lectus tellus, aliquet aliquam, luctus a, egestas a, turpis. Mauris lacinia lorem sit amet ipsum. Nunc quis urna dictum turpis accumsan semper. 
    113        </p>
    114        <div class="responsivethree">
    115            <div class="gallery">
    116                <img src="https://www.w3schools.com/images/w3schools_green.jpg" alt="image 1">
    117          <div class="desc">--- short description ---</div>
    118            </div>
    119        </div>
    120        <div class="responsivethree">
    121            <div class="gallery">
    122            <img src="https://www.w3schools.com/images/w3schools_green.jpg" alt="image 2" >
    123              <div class="desc">--- Very, utterly, super uber mega long description, don't you think, geeeeeez! ---</div>
    124            </div>
    125        </div>
    126        <div class="responsivethree">
    127            <div class="gallery">
    128            <img src="https://www.w3schools.com/images/w3schools_green.jpg" alt="image 3" >
    129              <div class="desc">--- stuff ---</div>
    130            </div>
    131      </div>
    132        <p>
    133            <b>This is my problem...</b> Lorem ipsum dolor sit amet, consectetuer adipiscing elit. Etiamlobortis facilisis sem. Nullam nec mi et neque pharetrasollicitudin. Praesent imperdiet mi nec ante. Donec ullamcorper,felis non sodales commodo, lectus velit ultrices augue, adignissim nibh lectus placerat pede. Vivamus nunc nunc, molestieut, ultricies vel, semper in, velit. Ut porttitor. Praesent in sapien. Lorem ipsum dolor sit amet, consectetuer adipiscing elit. Duis fringilla tristique neque. Sed interdum libero ut metus. Pellentesque placerat. Nam rutrum augue a leo. Morbi sed elit sit amet ante lobortis sollicitudin. Praesent blandit blandit mauris. Praesent lectus tellus, aliquet aliquam, luctus a, egestas a, turpis. Mauris lacinia lorem sit amet ipsum. Nunc quis urna dictum turpis accumsan semper.
    134        </p>
    135    </section>
    136</article>
    137</main>
    138<!-- #################################################################### -->
    139<footer>
    140    <p style="text-align: center;">footer tooter</p>
    141</footer>
    142<!-- #################################################################### -->
    143</body>
    144</html><!DOCTYPE html>
    145<html lang="en-NL">
    146<head>
    147  <meta charset="UTF-8">
    148  <meta name="viewport" content="width=device-width, initial-scale=1.0">
    149  <title>Example</title>
    150  <style type="text/css">
    151    body {
    152    font-family: helvetica;
    153    padding: 20px;
    154    font-size:11pt;
    155}
    156
    157header {
    158    max-width: 800px;
    159}
    160
    161main {
    162    max-width: 800px;
    163}
    164
    165section {
    166    padding-left: 15px;
    167    border-left: 1px solid rgb(223, 223, 223);
    168    border-radius: 5px;
    169}
    170
    171footer {
    172    max-width: 800px;
    173}
    174
    175
    176div.gallery {
    177  padding: 0px;
    178}
    179
    180div.gallery img {
    181  width: 98%;
    182  height: auto;
    183  display: block;
    184  margin-left: auto;
    185  margin-right: auto;
    186}
    187
    188div.desc {
    189  padding: 2px;
    190  padding-bottom: 5px;
    191  text-align: center;
    192  color: gray;
    193  font-size: 85%;
    194}
    195
    196* {
    197  box-sizing: border-box;
    198}
    199
    200.responsivefour {
    201  padding: 0 6px;
    202  float: left;
    203  width: 24.99999%;
    204}
    205
    206.responsivethree {
    207  padding: 0 6px;
    208  float: left;
    209  width: 33.32%;
    210}
    211
    212.responsivetwo {
    213  padding: 0 6px;
    214  float: left;
    215  width: 49.9988%;
    216}
    217
    218@media only screen and (max-width: 700px) {
    219  .responsivefour {
    220    width: 49.99999%;
    221    margin: 6px 0;
    222  }
    223}
    224
    225@media only screen and (max-width: 500px) {
    226  .responsivefour {
    227    width: 100%;
    228  }
    229  .responsivethree {
    230    width: 100%;
    231  }
    232  .responsivetwo {
    233    width: 100%;
    234  }
    235}
    236
    237.clearfix:after {
    238  content: "";
    239  display: table;
    240  clear: both;
    241}
    242
    243.clear {
    244  clear: both;
    245}
    246  </style>
    247</head>
    248<body>
    249<!-- #################################################################### -->
    250<header  id="top">
    251    <h1>Header</h1>
    252</header>
    253<!-- #################################################################### -->
    254<main>
    255<article id="test">
    256    <h2>bla</h2>
    257    <section>
    258        <p>
    259            Lorem ipsum dolor sit amet, consectetuer adipiscing elit. Etiamlobortis facilisis sem. Nullam nec mi et neque pharetrasollicitudin. Praesent imperdiet mi nec ante. Donec ullamcorper,felis non sodales commodo, lectus velit ultrices augue, adignissim nibh lectus placerat pede. Vivamus nunc nunc, molestieut, ultricies vel, semper in, velit. Ut porttitor. Praesent in sapien. Lorem ipsum dolor sit amet, consectetuer adipiscing elit. Duis fringilla tristique neque. Sed interdum libero ut metus. Pellentesque placerat. Nam rutrum augue a leo. Morbi sed elit sit amet ante lobortis sollicitudin. Praesent blandit blandit mauris. Praesent lectus tellus, aliquet aliquam, luctus a, egestas a, turpis. Mauris lacinia lorem sit amet ipsum. Nunc quis urna dictum turpis accumsan semper. 
    260        </p>
    261        <div class="responsivethree">
    262            <div class="gallery">
    263                <img src="https://www.w3schools.com/images/w3schools_green.jpg" alt="image 1">
    264          <div class="desc">--- short description ---</div>
    265            </div>
    266        </div>
    267        <div class="responsivethree">
    268            <div class="gallery">
    269            <img src="https://www.w3schools.com/images/w3schools_green.jpg" alt="image 2" >
    270              <div class="desc">--- Very, utterly, super uber mega long description, don't you think, geeeeeez! ---</div>
    271            </div>
    272        </div>
    273        <div class="responsivethree">
    274            <div class="gallery">
    275            <img src="https://www.w3schools.com/images/w3schools_green.jpg" alt="image 3" >
    276              <div class="desc">--- stuff ---</div>
    277            </div>
    278      </div>
    279        <p class="clear">
    280            <b>This is my problem...</b> Lorem ipsum dolor sit amet, consectetuer adipiscing elit. Etiamlobortis facilisis sem. Nullam nec mi et neque pharetrasollicitudin. Praesent imperdiet mi nec ante. Donec ullamcorper,felis non sodales commodo, lectus velit ultrices augue, adignissim nibh lectus placerat pede. Vivamus nunc nunc, molestieut, ultricies vel, semper in, velit. Ut porttitor. Praesent in sapien. Lorem ipsum dolor sit amet, consectetuer adipiscing elit. Duis fringilla tristique neque. Sed interdum libero ut metus. Pellentesque placerat. Nam rutrum augue a leo. Morbi sed elit sit amet ante lobortis sollicitudin. Praesent blandit blandit mauris. Praesent lectus tellus, aliquet aliquam, luctus a, egestas a, turpis. Mauris lacinia lorem sit amet ipsum. Nunc quis urna dictum turpis accumsan semper.
    281        </p>
    282    </section>
    283</article>
    284</main>
    285<!-- #################################################################### -->
    286<footer>
    287    <p style="text-align: center;">footer tooter</p>
    288</footer>
    289<!-- #################################################################### -->
    290</body>
    291</html>

    Source https://stackoverflow.com/questions/69124837

    QUESTION

    How do I deploy a static site generated by Nextjs to Vercel?

    Asked 2021-Sep-01 at 05:23

    I used the Nextjs static site generator to output a simple static site. I am attempting to deploy this site to Vercel but I keep getting an error while it is building. I have deployed this same site to static hosting sites in the past, but want to try Vercel now.

    The nextjs docs explicitly say my nextjs app requires zero config:

    We strongly recommend using Vercel even if your Next.js app is fully static. Vercel is optimized to make static Next.js apps blazingly fast. next export works with Zero Config deployments on Vercel.

    This is my package.json, the deployment scripts run npm export which runs next build && next export to create the out/ directory, like the docs recommend:
    1{
    2  "name": "new-barber-shop",
    3  "version": "1.0.0",
    4  "description": "",
    5  "main": "index.js",
    6  "scripts": {
    7    "dev": "next",
    8    "build": "next build && next export",
    9    "export": "next export",
    10    "start": "next start"
    11  },
    12  "author": "",
    13  "license": "ISC",
    14  "dependencies": {
    15    "@zeit/next-css": "^1.0.1",
    16    "google-maps-react": "^2.0.2",
    17    "next": "^9.1.2",
    18    "react": "^16.11.0",
    19    "react-bootstrap": "^1.0.0-beta.14",
    20    "react-dom": "^16.11.0",
    21    "semantic-ui-react": "^0.88.1"
    22  }
    23}
    24
    Here is a portion of the Vercel deployment build logs containing the error:
    1{
    2  "name": "new-barber-shop",
    3  "version": "1.0.0",
    4  "description": "",
    5  "main": "index.js",
    6  "scripts": {
    7    "dev": "next",
    8    "build": "next build && next export",
    9    "export": "next export",
    10    "start": "next start"
    11  },
    12  "author": "",
    13  "license": "ISC",
    14  "dependencies": {
    15    "@zeit/next-css": "^1.0.1",
    16    "google-maps-react": "^2.0.2",
    17    "next": "^9.1.2",
    18    "react": "^16.11.0",
    19    "react-bootstrap": "^1.0.0-beta.14",
    20    "react-dom": "^16.11.0",
    21    "semantic-ui-react": "^0.88.1"
    22  }
    23}
    2422:42:26.610
    25Compiled successfully.
    2622:42:26.611
    2722:42:26.612
    28Automatically optimizing pages...
    2922:42:27.095
    3022:42:27.109
    31Page            Size     Files  Packages
    3222:42:27.109
    33β”Œ ⚑ /           98.9 kB      2        13
    3422:42:27.109
    35β”œ   /_app       223 kB       0         2
    3622:42:27.109
    37β”œ   /_document
    3822:42:27.109
    39β””   /_error     1.96 kB      0         0
    4022:42:27.109
    4122:42:27.109
    42Ξ»  (Lambda)       page was emitted as a lambda (i.e. getInitialProps)
    4322:42:27.109
    44⚑  (Static File)  page was prerendered as static HTML
    4522:42:27.109
    4622:42:27.445
    47Error: Cannot export when target is not server. https://err.sh/zeit/next.js/next-export-serverless
    4822:42:27.445
    49    at _default (/vercel/path0/node_modules/next/dist/export/index.js:1:2956)
    5022:42:27.445
    51    at nextExport (/vercel/path0/node_modules/next/dist/cli/next-export.js:20:325)
    5222:42:27.445
    53    at /vercel/p
    54

    As you can see it compiled successfully, but runs into an error when it tries to export I believe. Any ideas?

    This is my next.config.js:
    1{
    2  "name": "new-barber-shop",
    3  "version": "1.0.0",
    4  "description": "",
    5  "main": "index.js",
    6  "scripts": {
    7    "dev": "next",
    8    "build": "next build && next export",
    9    "export": "next export",
    10    "start": "next start"
    11  },
    12  "author": "",
    13  "license": "ISC",
    14  "dependencies": {
    15    "@zeit/next-css": "^1.0.1",
    16    "google-maps-react": "^2.0.2",
    17    "next": "^9.1.2",
    18    "react": "^16.11.0",
    19    "react-bootstrap": "^1.0.0-beta.14",
    20    "react-dom": "^16.11.0",
    21    "semantic-ui-react": "^0.88.1"
    22  }
    23}
    2422:42:26.610
    25Compiled successfully.
    2622:42:26.611
    2722:42:26.612
    28Automatically optimizing pages...
    2922:42:27.095
    3022:42:27.109
    31Page            Size     Files  Packages
    3222:42:27.109
    33β”Œ ⚑ /           98.9 kB      2        13
    3422:42:27.109
    35β”œ   /_app       223 kB       0         2
    3622:42:27.109
    37β”œ   /_document
    3822:42:27.109
    39β””   /_error     1.96 kB      0         0
    4022:42:27.109
    4122:42:27.109
    42Ξ»  (Lambda)       page was emitted as a lambda (i.e. getInitialProps)
    4322:42:27.109
    44⚑  (Static File)  page was prerendered as static HTML
    4522:42:27.109
    4622:42:27.445
    47Error: Cannot export when target is not server. https://err.sh/zeit/next.js/next-export-serverless
    4822:42:27.445
    49    at _default (/vercel/path0/node_modules/next/dist/export/index.js:1:2956)
    5022:42:27.445
    51    at nextExport (/vercel/path0/node_modules/next/dist/cli/next-export.js:20:325)
    5222:42:27.445
    53    at /vercel/p
    54module.exports = {
    55  target: 'serverless',
    56    exportPathMap: function() {
    57      return {
    58        '/': { page: '/' }
    59      };
    60    }
    61  };
    62
    Error log when running npm run build in local project (identical to error output when deploying to Vercel
    1{
    2  "name": "new-barber-shop",
    3  "version": "1.0.0",
    4  "description": "",
    5  "main": "index.js",
    6  "scripts": {
    7    "dev": "next",
    8    "build": "next build && next export",
    9    "export": "next export",
    10    "start": "next start"
    11  },
    12  "author": "",
    13  "license": "ISC",
    14  "dependencies": {
    15    "@zeit/next-css": "^1.0.1",
    16    "google-maps-react": "^2.0.2",
    17    "next": "^9.1.2",
    18    "react": "^16.11.0",
    19    "react-bootstrap": "^1.0.0-beta.14",
    20    "react-dom": "^16.11.0",
    21    "semantic-ui-react": "^0.88.1"
    22  }
    23}
    2422:42:26.610
    25Compiled successfully.
    2622:42:26.611
    2722:42:26.612
    28Automatically optimizing pages...
    2922:42:27.095
    3022:42:27.109
    31Page            Size     Files  Packages
    3222:42:27.109
    33β”Œ ⚑ /           98.9 kB      2        13
    3422:42:27.109
    35β”œ   /_app       223 kB       0         2
    3622:42:27.109
    37β”œ   /_document
    3822:42:27.109
    39β””   /_error     1.96 kB      0         0
    4022:42:27.109
    4122:42:27.109
    42Ξ»  (Lambda)       page was emitted as a lambda (i.e. getInitialProps)
    4322:42:27.109
    44⚑  (Static File)  page was prerendered as static HTML
    4522:42:27.109
    4622:42:27.445
    47Error: Cannot export when target is not server. https://err.sh/zeit/next.js/next-export-serverless
    4822:42:27.445
    49    at _default (/vercel/path0/node_modules/next/dist/export/index.js:1:2956)
    5022:42:27.445
    51    at nextExport (/vercel/path0/node_modules/next/dist/cli/next-export.js:20:325)
    5222:42:27.445
    53    at /vercel/p
    54module.exports = {
    55  target: 'serverless',
    56    exportPathMap: function() {
    57      return {
    58        '/': { page: '/' }
    59      };
    60    }
    61  };
    62$ npm run build
    63
    64> new-barber-shop@1.0.0 build F:\Austin\web-apps\new-barber-shop
    65> next build && next export
    66
    67Browserslist: caniuse-lite is outdated. Please run next command `npm update`
    68Creating an optimized production build  
    69
    70Compiled successfully.
    71
    72Automatically optimizing pages  
    73
    74Page            Size     Files  Packages
    75β”Œ ⚑ /           98.9 kB      2        13
    76β”œ   /_app       223 kB       0         2
    77β”œ   /_document
    78β””   /_error     1.96 kB      0         4
    79
    80Ξ»  (Lambda)       page was emitted as a lambda (i.e. getInitialProps)
    81⚑  (Static File)  page was prerendered as static HTML
    82
    83Error: Cannot export when target is not server. https://err.sh/zeit/next.js/next-export-serverless
    84    at _default (F:\Austin\web-apps\new-barber-shop\node_modules\next\dist\export\index.js:1:2956)
    85    at nextExport (F:\Austin\web-apps\new-barber-shop\node_modules\next\dist\cli\next-export.js:20:325)
    86    at commands.(anonymous function).then.exec (F:\Austin\web-apps\new-barber-shop\node_modules\next\dist\bin\next:29:346)
    87    at process._tickCallback (internal/process/next_tick.js:68:7)
    88    at Function.Module.runMain (internal/modules/cjs/loader.js:834:11)
    89    at startup (internal/bootstrap/node.js:283:19)
    90    at bootstrapNodeJSCore (internal/bootstrap/node.js:622:3)
    91npm ERR! code ELIFECYCLE
    92npm ERR! errno 1
    93npm ERR! new-barber-shop@1.0.0 build: `next build && next export`
    94npm ERR! Exit status 1
    95npm ERR!
    96npm ERR! Failed at the new-barber-shop@1.0.0 build script.
    97npm ERR! This is probably not a problem with npm. There is likely additional logging output above.
    98
    99npm ERR! A complete log of this run can be found in:
    100npm ERR!     C:\Users\Austin\AppData\Roaming\npm-cache\_logs\2021-09-01T04_17_12_371Z-debug.log
    101

    ANSWER

    Answered 2021-Sep-01 at 05:23

    You are probably having "target": "serverless" in your next.config.js. Remove it or set it to "target": "server".

    Next.js can only handle exporting when the target is set to server (this is the default value). A serverless build, for instance, has no handler for requests–this is usually implemented by a hosting provider.


    EDIT: It appears that the error was due to old version of Next.js, most probably because they then understood Zeit (now Vercel) as a serverless platform and used to override the target. Updating the version will fix the problem. Also add .next, out, etc. to .gitignore. Here is the updated repo.

    Source https://stackoverflow.com/questions/69006532

    QUESTION

    Does Using React Context API In NextJS App Disable Static Site Generator?

    Asked 2021-Jun-10 at 17:58

    I've got some questions about nextJS and SSG (static site generator)

    1 - I want to manage my app state globally so I want to use react's context api. As I understand using redux in next js app disables SSG. If I use react context api does that disable too?

    2 - I know that I can do server side rendering but I want to have a custom nodejs server that I created from scratch. And I want to fetch data from my nodeJS server in the client side. Does making that way disable SSG and bad for performance?

    ANSWER

    Answered 2021-Jun-10 at 17:58

    This documentation will help you clarify your understanding on how Next.js handles automatic static optimization. Take a look at the caveats in that documentation to understand when that gets disabled at a global level.

    Beyond that, whether or not each individual page behaves as SSG, ISR, SSG + CSR or SSR is a matter of the data requirements of the individual page. See this documentation to better understand the different ways Next.js handles each page depending on the data requirements.

    Now, to answer your two questions directly:

    1. I cannot find any indication that using Redux in Next.js disables SSG. In fact, here is an official example using Redux to illustrate both an SSG and SSR Next.js page implementation. Same goes for the react context API. On the other hand, it is entirely possible for you to unintentionally disable SSG by both using Redux / react context while requiring dynamic data in your page. Read up on the documentation linked in the second paragraph above to understand this better.

    2. Fetching data from your custom NodeJS server client-side does not necessarily disable SSG. It will disable SSG if you require dynamic data on each page load. You have the choice to either statically generate your page (SSG + CSR) and then request your data client-side post page load (think axois / browser fetch API + loading indicator); OR, if you need the data to be present immediately upon page load (SSG & SSR), you can use getStaticProps + getStaticPaths to inject that data at build time (SSG) or getServerSideProps to inject the data on each page load (SSR).

    Source https://stackoverflow.com/questions/67924496

    QUESTION

    how to place text e.g. with h4 tag next to icon?

    Asked 2021-Jun-09 at 14:55

    I'm currently individualizing the Hugo theme https://github.com/themefisher/vex-hugo

    A demo can be found here: https://themes.gohugo.io/theme/vex-hugo/

    Under the features there are nice icons with some text. I want to place the headings next to the icons.

    In the html code a loop is used to place the text - which is defined in a yml file for static site generator Hugo - like this for the left icons and text:

    1  <div class="col-md-4">
    2        {{ range .left_side }}
    3        <div class="mb-40 text-center text-md-left">
    4          <i class="d-inlin-block h2 mb-10 {{ .icon }}"></i>
    5          <h4 class="font-weight-bold mb-2">{{ .title | markdownify }}</h4>
    6          <p>{{ .content | markdownify }}</p>
    7        </div>
    8        {{ end }}
    9

    I've added style="display: inline;" to the h4-tag, which will place the icons beside the text

    enter image description here

    But, with severe side effect, i.e. the nice arrangement (is it center?) of the three icon-text elements in the container next to the image is destroyed. Thus, I have to find another way. In addition I want to add more space between icon and text.

    Compare first (good) to lower (bad) image enter image description here

    enter image description here

    ANSWER

    Answered 2021-Jun-09 at 14:55

    You can give the h4 in CSS display: flex; and align-items: center;. Even when the icon is larger than the text it will be centered vertically.

    Here's the code example:

    1  <div class="col-md-4">
    2        {{ range .left_side }}
    3        <div class="mb-40 text-center text-md-left">
    4          <i class="d-inlin-block h2 mb-10 {{ .icon }}"></i>
    5          <h4 class="font-weight-bold mb-2">{{ .title | markdownify }}</h4>
    6          <p>{{ .content | markdownify }}</p>
    7        </div>
    8        {{ end }}
    9.bi {
    10  font-size: 50px; /* This is only added to show the centering */
    11}
    12
    13#testOne {
    14  font-size: 30px;
    15  display: flex;
    16  align-items: center;
    17}
    18
    19#testTwo {
    20  font-size: 50px;
    21  display: flex;
    22  align-items: center;
    23}
    1  <div class="col-md-4">
    2        {{ range .left_side }}
    3        <div class="mb-40 text-center text-md-left">
    4          <i class="d-inlin-block h2 mb-10 {{ .icon }}"></i>
    5          <h4 class="font-weight-bold mb-2">{{ .title | markdownify }}</h4>
    6          <p>{{ .content | markdownify }}</p>
    7        </div>
    8        {{ end }}
    9.bi {
    10  font-size: 50px; /* This is only added to show the centering */
    11}
    12
    13#testOne {
    14  font-size: 30px;
    15  display: flex;
    16  align-items: center;
    17}
    18
    19#testTwo {
    20  font-size: 50px;
    21  display: flex;
    22  align-items: center;
    23}<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/bootstrap-icons@1.5.0/font/bootstrap-icons.css">
    24
    25<h4 id="testOne">
    26  <i class="bi bi-alarm"></i>
    27  Test
    28</h4>
    29
    30<h4 id="testTwo">
    31  <i class="bi bi-alarm"></i>
    32  Test
    33</h4>

    Source https://stackoverflow.com/questions/67894062

    QUESTION

    How to save call_user_func_array() function output

    Asked 2021-May-31 at 20:50

    i am trying to make a static site generator which works with a great routing class.

    1if (php_sapi_name() === "cli") {
    2    foreach ($router->get() as $route) {
    3        $out = ob_get_contents();
    4        call_user_func_array($route['function'], array());
    5        ob_end_clean();
    6        file_put_contents("./temp/" . $route['expression'] . ".html", $out);
    7    }
    8}
    9

    So i am trying this I can see the compiled html code through terminal but file is empty. How can I save output of call_user_func_array() function?

    ANSWER

    Answered 2021-May-31 at 20:50

    See this example:

    1if (php_sapi_name() === "cli") {
    2    foreach ($router->get() as $route) {
    3        $out = ob_get_contents();
    4        call_user_func_array($route['function'], array());
    5        ob_end_clean();
    6        file_put_contents("./temp/" . $route['expression'] . ".html", $out);
    7    }
    8}
    9if (php_sapi_name() === "cli") {
    10    // Start output buffering here
    11    ob_start();
    12    foreach ($router->get() as $route) {
    13        call_user_func_array($route['function'], array());
    14        // get output of `$route['function']` to $out variable
    15        $out = ob_get_contents();
    16        // clean buffer
    17        ob_clean();
    18
    19        file_put_contents("./temp/" . $route['expression'] . ".html", $out);
    20    }
    21    // stop output buffering
    22    ob_end_clean();
    23}
    24

    Source https://stackoverflow.com/questions/67779900

    Community Discussions contain sources that include Stack Exchange Network

    Tutorials and Learning Resources in Static Site Generator

    Tutorials and Learning Resources are not available at this moment for Static Site Generator

    Share this Page

    share link

    Get latest updates on Static Site Generator