<commit_before>import pug from 'pug';
import path from 'path';
import rimraf from 'rimraf';
import { slugger, logoURL } from 'src/config/constants';
import writefile from 'src/server/modules/writefile';
import deleteFile from 'src/server/modules/deleteFile';
import webpackManifest from 'src/server/modules/webpack-manifest';
import splitItems from 'src/modules/split-items';

const views = path.join(process.cwd(), 'src/server/views');

/**
 * Build a partial gallery post and return the compiled html
 * @param {Object} post A post object
 */
export const buildGalleryPost = (post) => {
  const images = splitItems(post.images);
  return pug.renderFile(`${views}/partials/gallery-post.pug`, {
    post,
    images,
  });
}

export const buildGallery = (posts) => {
  const filePath = 'public/bilder.html';

  // Split images in each post into two columns
  const orderedPosts = posts.map((post) => {
    const orderedImages = splitItems(post.images);
    return { ...post.toObject(), images: orderedImages };
  });

  const html = pug.renderFile(`${views}/gallery.pug`, {
    orderedPosts,
    logoURL: logoURL(),
    webpack: webpackManifest(),
  });<commit_msg>Render only two gallery posts statically on the server<commit_after>import pug from 'pug';
import path from 'path';
import rimraf from 'rimraf';
import { slugger, logoURL } from 'src/config/constants';
import writefile from 'src/server/modules/writefile';
import deleteFile from 'src/server/modules/deleteFile';
import webpackManifest from 'src/server/modules/webpack-manifest';
import splitItems from 'src/modules/split-items';

const views = path.join(process.cwd(), 'src/server/views');

/**
 * Build a partial gallery post and return the compiled html
 * @param {Object} post A post object
 */
export const buildGalleryPost = (post) => {
  const images = splitItems(post.images);
  return pug.renderFile(`${views}/partials/gallery-post.pug`, {
    post,
    images,
  });
}

export const buildGallery = (posts) => {
  const filePath = 'public/bilder.html';

  // Split images in each post into two columns
  const orderedPosts = posts
    .slice(0, 2)
    .map((post) => {
      const orderedImages = splitItems(post.images);
      return { ...post.toObject(), images: orderedImages };
    });

  const html = pug.renderFile(`${views}/gallery.pug`, {
    orderedPosts,
    logoURL: logoURL(),
    webpack: webpackManifest(),
  });
{'fraction_non_alphanumeric': 0.13755731554814507, 'fraction_numerical': 0.0008336807002917883, 'mean_word_length': 4.161290322580645, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 9, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '4525074', 'n_tokens_mistral': 736, 'n_tokens_neox': 720, 'n_words': 205}