repo
stringlengths
5
106
file_url
stringlengths
78
301
file_path
stringlengths
4
211
content
stringlengths
0
32.8k
language
stringclasses
1 value
license
stringclasses
7 values
commit_sha
stringlengths
40
40
retrieved_at
stringdate
2026-01-04 14:56:49
2026-01-05 02:23:25
truncated
bool
2 classes
TryGhost/Ghost
https://github.com/TryGhost/Ghost/blob/31ecb69a147e71743e74014b4e04ccce09ab8c1a/ghost/core/core/frontend/services/sitemap/BaseSiteMapGenerator.js
ghost/core/core/frontend/services/sitemap/BaseSiteMapGenerator.js
const _ = require('lodash'); const xml = require('xml'); const moment = require('moment'); const path = require('path'); const urlUtils = require('../../../shared/url-utils'); const localUtils = require('./utils'); // Sitemap specific xml namespace declarations that should not change const XMLNS_DECLS = { _attr: {...
javascript
MIT
31ecb69a147e71743e74014b4e04ccce09ab8c1a
2026-01-04T14:57:14.657301Z
false
TryGhost/Ghost
https://github.com/TryGhost/Ghost/blob/31ecb69a147e71743e74014b4e04ccce09ab8c1a/ghost/core/core/frontend/services/sitemap/SiteMapIndexGenerator.js
ghost/core/core/frontend/services/sitemap/SiteMapIndexGenerator.js
const _ = require('lodash'); const xml = require('xml'); const moment = require('moment'); const urlUtils = require('../../../shared/url-utils'); const localUtils = require('./utils'); const XMLNS_DECLS = { _attr: { xmlns: 'http://www.sitemaps.org/schemas/sitemap/0.9' } }; class SiteMapIndexGenerator ...
javascript
MIT
31ecb69a147e71743e74014b4e04ccce09ab8c1a
2026-01-04T14:57:14.657301Z
false
TryGhost/Ghost
https://github.com/TryGhost/Ghost/blob/31ecb69a147e71743e74014b4e04ccce09ab8c1a/ghost/core/core/frontend/services/sitemap/PostMapGenerator.js
ghost/core/core/frontend/services/sitemap/PostMapGenerator.js
const _ = require('lodash'); const BaseMapGenerator = require('./BaseSiteMapGenerator'); class PostMapGenerator extends BaseMapGenerator { constructor(opts) { super(); this.name = 'posts'; _.extend(this, opts); } } module.exports = PostMapGenerator;
javascript
MIT
31ecb69a147e71743e74014b4e04ccce09ab8c1a
2026-01-04T14:57:14.657301Z
false
TryGhost/Ghost
https://github.com/TryGhost/Ghost/blob/31ecb69a147e71743e74014b4e04ccce09ab8c1a/ghost/core/core/frontend/services/sitemap/utils.js
ghost/core/core/frontend/services/sitemap/utils.js
const urlUtils = require('../../../shared/url-utils'); let sitemapsUtils; sitemapsUtils = { getDeclarations: function () { let baseUrl = urlUtils.urlFor('sitemap_xsl', true); baseUrl = baseUrl.replace(/^(http:|https:)/, ''); return '<?xml version="1.0" encoding="UTF-8"?>' + '<?x...
javascript
MIT
31ecb69a147e71743e74014b4e04ccce09ab8c1a
2026-01-04T14:57:14.657301Z
false
TryGhost/Ghost
https://github.com/TryGhost/Ghost/blob/31ecb69a147e71743e74014b4e04ccce09ab8c1a/ghost/core/core/frontend/services/theme-engine/index.js
ghost/core/core/frontend/services/theme-engine/index.js
const active = require('./active'); module.exports = { getActive: active.get, setActive: active.set, middleware: require('./middleware') };
javascript
MIT
31ecb69a147e71743e74014b4e04ccce09ab8c1a
2026-01-04T14:57:14.657301Z
false
TryGhost/Ghost
https://github.com/TryGhost/Ghost/blob/31ecb69a147e71743e74014b4e04ccce09ab8c1a/ghost/core/core/frontend/services/theme-engine/engine.js
ghost/core/core/frontend/services/theme-engine/engine.js
const hbs = require('express-hbs'); const config = require('../../../shared/config'); const instance = hbs.create(); // @TODO think about a config option for this e.g. theme.devmode? if (config.get('env') !== 'production') { instance.handlebars.logger.level = 0; } instance.escapeExpression = instance.handlebars.U...
javascript
MIT
31ecb69a147e71743e74014b4e04ccce09ab8c1a
2026-01-04T14:57:14.657301Z
false
TryGhost/Ghost
https://github.com/TryGhost/Ghost/blob/31ecb69a147e71743e74014b4e04ccce09ab8c1a/ghost/core/core/frontend/services/theme-engine/active.js
ghost/core/core/frontend/services/theme-engine/active.js
/** * # Active Theme * * This file defines a class of active theme, and also controls the getting and setting a single instance, as there * can only ever be one active theme. Unlike a singleton, the active theme can change, however only in a controlled way. * * There are several different patterns available for k...
javascript
MIT
31ecb69a147e71743e74014b4e04ccce09ab8c1a
2026-01-04T14:57:14.657301Z
false
TryGhost/Ghost
https://github.com/TryGhost/Ghost/blob/31ecb69a147e71743e74014b4e04ccce09ab8c1a/ghost/core/core/frontend/services/theme-engine/preview.js
ghost/core/core/frontend/services/theme-engine/preview.js
// @TODO: put together a plan for how the frontend should exist as modules and move this out // The preview header contains a query string with the custom preview data // This is deliberately slightly obscure & means we don't need to add body parsing to the frontend :D // If we start passing in strings like title or de...
javascript
MIT
31ecb69a147e71743e74014b4e04ccce09ab8c1a
2026-01-04T14:57:14.657301Z
false
TryGhost/Ghost
https://github.com/TryGhost/Ghost/blob/31ecb69a147e71743e74014b4e04ccce09ab8c1a/ghost/core/core/frontend/services/theme-engine/middleware/update-global-template-options.js
ghost/core/core/frontend/services/theme-engine/middleware/update-global-template-options.js
const hbs = require('../engine'); const urlUtils = require('../../../../shared/url-utils'); const settingsCache = require('../../../../shared/settings-cache'); const customThemeSettingsCache = require('../../../../shared/custom-theme-settings-cache'); const labs = require('../../../../shared/labs'); const activeTheme =...
javascript
MIT
31ecb69a147e71743e74014b4e04ccce09ab8c1a
2026-01-04T14:57:14.657301Z
false
TryGhost/Ghost
https://github.com/TryGhost/Ghost/blob/31ecb69a147e71743e74014b4e04ccce09ab8c1a/ghost/core/core/frontend/services/theme-engine/middleware/index.js
ghost/core/core/frontend/services/theme-engine/middleware/index.js
module.exports = [ require('./ensure-active-theme'), require('./update-global-template-options'), require('./update-local-template-options') ];
javascript
MIT
31ecb69a147e71743e74014b4e04ccce09ab8c1a
2026-01-04T14:57:14.657301Z
false
TryGhost/Ghost
https://github.com/TryGhost/Ghost/blob/31ecb69a147e71743e74014b4e04ccce09ab8c1a/ghost/core/core/frontend/services/theme-engine/middleware/ensure-active-theme.js
ghost/core/core/frontend/services/theme-engine/middleware/ensure-active-theme.js
const errors = require('@tryghost/errors'); const tpl = require('@tryghost/tpl'); const activeTheme = require('../active'); const settingsCache = require('../../../../shared/settings-cache'); const messages = { missingTheme: 'The currently active theme "{theme}" is missing.' }; // ### Ensure Active Theme // Ensu...
javascript
MIT
31ecb69a147e71743e74014b4e04ccce09ab8c1a
2026-01-04T14:57:14.657301Z
false
TryGhost/Ghost
https://github.com/TryGhost/Ghost/blob/31ecb69a147e71743e74014b4e04ccce09ab8c1a/ghost/core/core/frontend/services/theme-engine/middleware/update-local-template-options.js
ghost/core/core/frontend/services/theme-engine/middleware/update-local-template-options.js
const _ = require('lodash'); const hbs = require('../engine'); const urlUtils = require('../../../../shared/url-utils'); const customThemeSettingsCache = require('../../../../shared/custom-theme-settings-cache'); const preview = require('../preview'); function updateLocalTemplateOptions(req, res, next) { const loc...
javascript
MIT
31ecb69a147e71743e74014b4e04ccce09ab8c1a
2026-01-04T14:57:14.657301Z
false
TryGhost/Ghost
https://github.com/TryGhost/Ghost/blob/31ecb69a147e71743e74014b4e04ccce09ab8c1a/ghost/core/core/frontend/services/theme-engine/handlebars/template.js
ghost/core/core/frontend/services/theme-engine/handlebars/template.js
// ## Template utils const templates = {}; const _ = require('lodash'); const errors = require('@tryghost/errors'); const tpl = require('@tryghost/tpl'); const hbs = require('../engine'); const messages = { templateNotFound: 'Template {name} not found.' }; // Execute a template helper // All template helpers are ...
javascript
MIT
31ecb69a147e71743e74014b4e04ccce09ab8c1a
2026-01-04T14:57:14.657301Z
false
TryGhost/Ghost
https://github.com/TryGhost/Ghost/blob/31ecb69a147e71743e74014b4e04ccce09ab8c1a/ghost/core/core/frontend/services/theme-engine/handlebars/utils.js
ghost/core/core/frontend/services/theme-engine/handlebars/utils.js
const _ = require('lodash'); module.exports.findKey = function findKey(key /* ...objects... */) { let objects = Array.prototype.slice.call(arguments, 1); return _.reduceRight(objects, function (result, object) { if (object && _.has(object, key) && !_.isEmpty(object[key])) { result = object...
javascript
MIT
31ecb69a147e71743e74014b4e04ccce09ab8c1a
2026-01-04T14:57:14.657301Z
false
TryGhost/Ghost
https://github.com/TryGhost/Ghost/blob/31ecb69a147e71743e74014b4e04ccce09ab8c1a/ghost/core/core/frontend/services/theme-engine/i18n/index.js
ghost/core/core/frontend/services/theme-engine/i18n/index.js
const config = require('../../../../shared/config'); const ThemeI18n = require('./ThemeI18n'); module.exports = new ThemeI18n({basePath: config.getContentPath('themes')}); module.exports.ThemeI18n = ThemeI18n;
javascript
MIT
31ecb69a147e71743e74014b4e04ccce09ab8c1a
2026-01-04T14:57:14.657301Z
false
TryGhost/Ghost
https://github.com/TryGhost/Ghost/blob/31ecb69a147e71743e74014b4e04ccce09ab8c1a/ghost/core/core/frontend/services/theme-engine/i18n/ThemeI18n.js
ghost/core/core/frontend/services/theme-engine/i18n/ThemeI18n.js
const errors = require('@tryghost/errors'); const logging = require('@tryghost/logging'); const I18n = require('./I18n'); class ThemeI18n extends I18n { /** * @param {object} [options] * @param {string} options.basePath - the base path for the translation directory (e.g. where themes live) * @param ...
javascript
MIT
31ecb69a147e71743e74014b4e04ccce09ab8c1a
2026-01-04T14:57:14.657301Z
false
TryGhost/Ghost
https://github.com/TryGhost/Ghost/blob/31ecb69a147e71743e74014b4e04ccce09ab8c1a/ghost/core/core/frontend/services/theme-engine/i18n/I18n.js
ghost/core/core/frontend/services/theme-engine/i18n/I18n.js
const errors = require('@tryghost/errors'); const logging = require('@tryghost/logging'); const fs = require('fs-extra'); const path = require('path'); const MessageFormat = require('intl-messageformat'); const jp = require('jsonpath'); const isString = require('lodash/isString'); const isObject = require('lodash/isObj...
javascript
MIT
31ecb69a147e71743e74014b4e04ccce09ab8c1a
2026-01-04T14:57:14.657301Z
false
TryGhost/Ghost
https://github.com/TryGhost/Ghost/blob/31ecb69a147e71743e74014b4e04ccce09ab8c1a/ghost/core/core/frontend/services/theme-engine/config/index.js
ghost/core/core/frontend/services/theme-engine/config/index.js
const _ = require('lodash'); const defaultConfig = require('./defaults'); const allowedKeys = ['posts_per_page', 'image_sizes', 'card_assets']; module.exports.create = function configLoader(packageJson) { let config = _.cloneDeep(defaultConfig); if (packageJson && Object.prototype.hasOwnProperty.call(packageJ...
javascript
MIT
31ecb69a147e71743e74014b4e04ccce09ab8c1a
2026-01-04T14:57:14.657301Z
false
TryGhost/Ghost
https://github.com/TryGhost/Ghost/blob/31ecb69a147e71743e74014b4e04ccce09ab8c1a/ghost/core/core/frontend/services/theme-engine/i18next/index.js
ghost/core/core/frontend/services/theme-engine/i18next/index.js
const config = require('../../../../shared/config'); const ThemeI18n = require('./ThemeI18n'); module.exports = new ThemeI18n({basePath: config.getContentPath('themes')}); module.exports.ThemeI18n = ThemeI18n;
javascript
MIT
31ecb69a147e71743e74014b4e04ccce09ab8c1a
2026-01-04T14:57:14.657301Z
false
TryGhost/Ghost
https://github.com/TryGhost/Ghost/blob/31ecb69a147e71743e74014b4e04ccce09ab8c1a/ghost/core/core/frontend/services/theme-engine/i18next/ThemeI18n.js
ghost/core/core/frontend/services/theme-engine/i18next/ThemeI18n.js
const errors = require('@tryghost/errors'); const i18nLib = require('@tryghost/i18n'); const path = require('path'); const fs = require('fs-extra'); class ThemeI18n { /** * @param {object} options * @param {string} options.basePath - the base path for the translation directory (e.g. where themes live) ...
javascript
MIT
31ecb69a147e71743e74014b4e04ccce09ab8c1a
2026-01-04T14:57:14.657301Z
false
TryGhost/Ghost
https://github.com/TryGhost/Ghost/blob/31ecb69a147e71743e74014b4e04ccce09ab8c1a/ghost/core/core/frontend/services/data/fetch-data.js
ghost/core/core/frontend/services/data/fetch-data.js
/** * # Fetch Data * Dynamically build and execute queries on the API */ const _ = require('lodash'); // The default settings for a default post query const queryDefaults = { type: 'browse', resource: 'posts', controller: 'postsPublic', options: {} }; /** * The theme expects to have access to the ...
javascript
MIT
31ecb69a147e71743e74014b4e04ccce09ab8c1a
2026-01-04T14:57:14.657301Z
false
TryGhost/Ghost
https://github.com/TryGhost/Ghost/blob/31ecb69a147e71743e74014b4e04ccce09ab8c1a/ghost/core/core/frontend/services/data/index.js
ghost/core/core/frontend/services/data/index.js
module.exports = { checks: require('./checks'), entryLookup: require('./entry-lookup'), fetchData: require('./fetch-data') };
javascript
MIT
31ecb69a147e71743e74014b4e04ccce09ab8c1a
2026-01-04T14:57:14.657301Z
false
TryGhost/Ghost
https://github.com/TryGhost/Ghost/blob/31ecb69a147e71743e74014b4e04ccce09ab8c1a/ghost/core/core/frontend/services/data/checks.js
ghost/core/core/frontend/services/data/checks.js
function isPost(jsonData) { return Object.prototype.hasOwnProperty.call(jsonData, 'html') && Object.prototype.hasOwnProperty.call(jsonData, 'title') && Object.prototype.hasOwnProperty.call(jsonData, 'slug'); } function isNewsletter(jsonData) { return Object.prototype.hasOwnProperty.call(jsonData, 'name...
javascript
MIT
31ecb69a147e71743e74014b4e04ccce09ab8c1a
2026-01-04T14:57:14.657301Z
false
TryGhost/Ghost
https://github.com/TryGhost/Ghost/blob/31ecb69a147e71743e74014b4e04ccce09ab8c1a/ghost/core/core/frontend/services/data/entry-lookup.js
ghost/core/core/frontend/services/data/entry-lookup.js
const _ = require('lodash'); const url = require('url'); const debug = require('@tryghost/debug')('services:data:entry-lookup'); const routeMatch = require('path-match')(); /** * Query API for a single entry/resource. * @param {String} postUrl * @param {Object} routerOptions * @param {Object} locals * @returns {*...
javascript
MIT
31ecb69a147e71743e74014b4e04ccce09ab8c1a
2026-01-04T14:57:14.657301Z
false
TryGhost/Ghost
https://github.com/TryGhost/Ghost/blob/31ecb69a147e71743e74014b4e04ccce09ab8c1a/ghost/core/core/frontend/apps/private-blogging/index.js
ghost/core/core/frontend/apps/private-blogging/index.js
const path = require('path'); const tpl = require('@tryghost/tpl'); const logging = require('@tryghost/logging'); const errors = require('@tryghost/errors'); const urlUtils = require('../../../shared/url-utils'); const middleware = require('./lib/middleware'); const router = require('./lib/router'); const messages = {...
javascript
MIT
31ecb69a147e71743e74014b4e04ccce09ab8c1a
2026-01-04T14:57:14.657301Z
false
TryGhost/Ghost
https://github.com/TryGhost/Ghost/blob/31ecb69a147e71743e74014b4e04ccce09ab8c1a/ghost/core/core/frontend/apps/private-blogging/lib/router.js
ghost/core/core/frontend/apps/private-blogging/lib/router.js
const path = require('path'); const express = require('../../../../shared/express'); const middleware = require('./middleware'); const bodyParser = require('body-parser'); const renderer = require('../../../services/rendering'); const web = require('../../../../server/web'); const templateName = 'private'; const privat...
javascript
MIT
31ecb69a147e71743e74014b4e04ccce09ab8c1a
2026-01-04T14:57:14.657301Z
false
TryGhost/Ghost
https://github.com/TryGhost/Ghost/blob/31ecb69a147e71743e74014b4e04ccce09ab8c1a/ghost/core/core/frontend/apps/private-blogging/lib/middleware.js
ghost/core/core/frontend/apps/private-blogging/lib/middleware.js
const fs = require('fs-extra'); const session = require('cookie-session'); const crypto = require('crypto'); const path = require('path'); const config = require('../../../../shared/config'); const urlUtils = require('../../../../shared/url-utils'); const tpl = require('@tryghost/tpl'); const errors = require('@tryghos...
javascript
MIT
31ecb69a147e71743e74014b4e04ccce09ab8c1a
2026-01-04T14:57:14.657301Z
false
TryGhost/Ghost
https://github.com/TryGhost/Ghost/blob/31ecb69a147e71743e74014b4e04ccce09ab8c1a/ghost/core/core/frontend/apps/private-blogging/lib/helpers/input_password.js
ghost/core/core/frontend/apps/private-blogging/lib/helpers/input_password.js
// # Input Password Helper // Usage: `{{input_password}}` // // Password input used on private.hbs for password-protected blogs // (less) dirty requires const {SafeString, templates} = require('../../../../services/handlebars'); // We use the name input_password to match the helper for consistency: module.exports = f...
javascript
MIT
31ecb69a147e71743e74014b4e04ccce09ab8c1a
2026-01-04T14:57:14.657301Z
false
TryGhost/Ghost
https://github.com/TryGhost/Ghost/blob/31ecb69a147e71743e74014b4e04ccce09ab8c1a/ghost/core/core/frontend/helpers/ghost_head.js
ghost/core/core/frontend/helpers/ghost_head.js
// # Ghost Head Helper // Usage: `{{ghost_head}}` // // Outputs scripts and other assets at the top of a Ghost theme const {labs, metaData, settingsCache, config, blogIcon, urlUtils, getFrontendKey, settingsHelpers} = require('../services/proxy'); const {escapeExpression, SafeString} = require('../services/handlebars')...
javascript
MIT
31ecb69a147e71743e74014b4e04ccce09ab8c1a
2026-01-04T14:57:14.657301Z
false
TryGhost/Ghost
https://github.com/TryGhost/Ghost/blob/31ecb69a147e71743e74014b4e04ccce09ab8c1a/ghost/core/core/frontend/helpers/plural.js
ghost/core/core/frontend/helpers/plural.js
// # Plural Helper // Usage example: `{{plural ../pagination.total empty='No posts' singular='1 post' plural='% posts'}}` // or for translatable themes, with (t) translation helper's subexpressions: // `{{plural ../pagination.total empty=(t "No posts") singular=(t "1 post") plural=(t "% posts")}}` // // Pluralises stri...
javascript
MIT
31ecb69a147e71743e74014b4e04ccce09ab8c1a
2026-01-04T14:57:14.657301Z
false
TryGhost/Ghost
https://github.com/TryGhost/Ghost/blob/31ecb69a147e71743e74014b4e04ccce09ab8c1a/ghost/core/core/frontend/helpers/facebook_url.js
ghost/core/core/frontend/helpers/facebook_url.js
// # Facebook URL Helper // Usage: `{{facebook_url}}` or `{{facebook_url author.facebook}}` // // Output a url for a facebook username const {socialUrls} = require('../services/proxy'); const {localUtils} = require('../services/handlebars'); // We use the name facebook_url to match the helper for consistency: /** * @...
javascript
MIT
31ecb69a147e71743e74014b4e04ccce09ab8c1a
2026-01-04T14:57:14.657301Z
false
TryGhost/Ghost
https://github.com/TryGhost/Ghost/blob/31ecb69a147e71743e74014b4e04ccce09ab8c1a/ghost/core/core/frontend/helpers/social_url.js
ghost/core/core/frontend/helpers/social_url.js
// # Social URL Helper // Usage: `{{social_url type="platform"}}` (e.g., type="facebook", type="twitter") // // Output a url for a social media username defined in site settings. const {socialUrls} = require('../services/proxy'); const {localUtils} = require('../services/handlebars'); // We use the name social_url to ...
javascript
MIT
31ecb69a147e71743e74014b4e04ccce09ab8c1a
2026-01-04T14:57:14.657301Z
false
TryGhost/Ghost
https://github.com/TryGhost/Ghost/blob/31ecb69a147e71743e74014b4e04ccce09ab8c1a/ghost/core/core/frontend/helpers/reading_time.js
ghost/core/core/frontend/helpers/reading_time.js
// # Reading Time Helper // // Usage: `{{reading_time}}` // or for translatable themes, with (t) translation helper's subexpressions: // `{{reading_time seconds=(t "< 1 min read") minute=(t "1 min read") minutes=(t "% min read")}}` // and in the theme translation file, for example Spanish es.json: // "< 1 min read": "...
javascript
MIT
31ecb69a147e71743e74014b4e04ccce09ab8c1a
2026-01-04T14:57:14.657301Z
false
TryGhost/Ghost
https://github.com/TryGhost/Ghost/blob/31ecb69a147e71743e74014b4e04ccce09ab8c1a/ghost/core/core/frontend/helpers/excerpt.js
ghost/core/core/frontend/helpers/excerpt.js
// # Excerpt Helper // Usage: `{{excerpt}}`, `{{excerpt words="50"}}`, `{{excerpt characters="256"}}` // // Attempts to remove all HTML from the string, and then shortens the result according to the provided option. // // Defaults to words="50" const {SafeString} = require('../services/handlebars'); const {metaData} =...
javascript
MIT
31ecb69a147e71743e74014b4e04ccce09ab8c1a
2026-01-04T14:57:14.657301Z
false
TryGhost/Ghost
https://github.com/TryGhost/Ghost/blob/31ecb69a147e71743e74014b4e04ccce09ab8c1a/ghost/core/core/frontend/helpers/img_url.js
ghost/core/core/frontend/helpers/img_url.js
// Usage: // `{{img_url feature_image}}` // `{{img_url profile_image absolute="true"}}` // Note: // `{{img_url}}` - does not work, argument is required // // Returns the URL for the current object scope i.e. If inside a post scope will return image permalink // `absolute` flag outputs absolute URL, else URL is relative...
javascript
MIT
31ecb69a147e71743e74014b4e04ccce09ab8c1a
2026-01-04T14:57:14.657301Z
false
TryGhost/Ghost
https://github.com/TryGhost/Ghost/blob/31ecb69a147e71743e74014b4e04ccce09ab8c1a/ghost/core/core/frontend/helpers/price.js
ghost/core/core/frontend/helpers/price.js
// # {{price}} helper // // Usage: `{{price 2100}}` // Usage: `{{price plan}}` // Usage: `{{price plan numberFormat="long"}}` // Usage: `{{price plan currencyFormat="code"}}` // Usage: `{{price plan currencyFormat="name"}}` // Usage: `{{price 500 currency="USD"}}` // Usage: `{{price currency="USD"}}` // // Returns amou...
javascript
MIT
31ecb69a147e71743e74014b4e04ccce09ab8c1a
2026-01-04T14:57:14.657301Z
false
TryGhost/Ghost
https://github.com/TryGhost/Ghost/blob/31ecb69a147e71743e74014b4e04ccce09ab8c1a/ghost/core/core/frontend/helpers/has.js
ghost/core/core/frontend/helpers/has.js
// # Has Helper // Usage: `{{#has tag="video, music"}}`, `{{#has author="sam, pat"}}` // `{{#has author="count:1"}}`, `{{#has tag="count:>1"}}` // // Checks if a post has a particular property const logging = require('@tryghost/logging'); const tpl = require('@tryghost/tpl'); const _ = require('lodash'); const ...
javascript
MIT
31ecb69a147e71743e74014b4e04ccce09ab8c1a
2026-01-04T14:57:14.657301Z
false
TryGhost/Ghost
https://github.com/TryGhost/Ghost/blob/31ecb69a147e71743e74014b4e04ccce09ab8c1a/ghost/core/core/frontend/helpers/t.js
ghost/core/core/frontend/helpers/t.js
// # t helper // i18n: Translatable handlebars expressions for templates of the front-end and themes. // Front-end: .hbs templates in core/server, overridden by copies in themes. Themes: in content/themes. // // Usage examples, for example in .hbs theme templates: // {{t "Get the latest posts delivered right to your in...
javascript
MIT
31ecb69a147e71743e74014b4e04ccce09ab8c1a
2026-01-04T14:57:14.657301Z
false
TryGhost/Ghost
https://github.com/TryGhost/Ghost/blob/31ecb69a147e71743e74014b4e04ccce09ab8c1a/ghost/core/core/frontend/helpers/post_class.js
ghost/core/core/frontend/helpers/post_class.js
// # Post Class Helper // Usage: `{{post_class}}` // // Output classes for the body element const {SafeString} = require('../services/handlebars'); // We use the name post_class to match the helper for consistency: module.exports = function post_class() { // eslint-disable-line camelcase let classes = ['post']; ...
javascript
MIT
31ecb69a147e71743e74014b4e04ccce09ab8c1a
2026-01-04T14:57:14.657301Z
false
TryGhost/Ghost
https://github.com/TryGhost/Ghost/blob/31ecb69a147e71743e74014b4e04ccce09ab8c1a/ghost/core/core/frontend/helpers/meta_description.js
ghost/core/core/frontend/helpers/meta_description.js
// # Meta Description Helper // Usage: `{{meta_description}}` // // Page description used for sharing and SEO const {metaData} = require('../services/proxy'); const {getMetaDataDescription} = metaData; // We use the name meta_description to match the helper for consistency: module.exports = function meta_description(o...
javascript
MIT
31ecb69a147e71743e74014b4e04ccce09ab8c1a
2026-01-04T14:57:14.657301Z
false
TryGhost/Ghost
https://github.com/TryGhost/Ghost/blob/31ecb69a147e71743e74014b4e04ccce09ab8c1a/ghost/core/core/frontend/helpers/authors.js
ghost/core/core/frontend/helpers/authors.js
'use strict'; // # Authors Helper // Usage: `{{authors}}`, `{{authors separator=' - '}}` // // Returns a string of the authors on the post. // By default, authors are separated by commas. // // Note that the standard {{#each authors}} implementation is unaffected by this helper. const {urlService} = require('../service...
javascript
MIT
31ecb69a147e71743e74014b4e04ccce09ab8c1a
2026-01-04T14:57:14.657301Z
false
TryGhost/Ghost
https://github.com/TryGhost/Ghost/blob/31ecb69a147e71743e74014b4e04ccce09ab8c1a/ghost/core/core/frontend/helpers/foreach.js
ghost/core/core/frontend/helpers/foreach.js
// # Foreach Helper // Usage: `{{#foreach data}}{{/foreach}}` // // Block helper designed for looping through posts const {checks} = require('../services/data'); const {hbs} = require('../services/handlebars'); const _ = require('lodash'); const logging = require('@tryghost/logging'); const tpl = require('@tryghost/tp...
javascript
MIT
31ecb69a147e71743e74014b4e04ccce09ab8c1a
2026-01-04T14:57:14.657301Z
false
TryGhost/Ghost
https://github.com/TryGhost/Ghost/blob/31ecb69a147e71743e74014b4e04ccce09ab8c1a/ghost/core/core/frontend/helpers/raw.js
ghost/core/core/frontend/helpers/raw.js
// # Raw helper // Usage: `{{{{raw}}}}...{{{{/raw}}}}` // // Returns raw contents unprocessed by handlebars. module.exports = function raw(options) { return options.fn(this); };
javascript
MIT
31ecb69a147e71743e74014b4e04ccce09ab8c1a
2026-01-04T14:57:14.657301Z
false
TryGhost/Ghost
https://github.com/TryGhost/Ghost/blob/31ecb69a147e71743e74014b4e04ccce09ab8c1a/ghost/core/core/frontend/helpers/link.js
ghost/core/core/frontend/helpers/link.js
// # link helper const {config} = require('../services/proxy'); const {SafeString, localUtils} = require('../services/handlebars'); const _ = require('lodash'); const errors = require('@tryghost/errors'); const tpl = require('@tryghost/tpl'); const {buildLinkClasses} = localUtils; const messages = { hrefIsRequir...
javascript
MIT
31ecb69a147e71743e74014b4e04ccce09ab8c1a
2026-01-04T14:57:14.657301Z
false
TryGhost/Ghost
https://github.com/TryGhost/Ghost/blob/31ecb69a147e71743e74014b4e04ccce09ab8c1a/ghost/core/core/frontend/helpers/total_members.js
ghost/core/core/frontend/helpers/total_members.js
// # Total Members Helper // Usage: `{{total_members}}` const {SafeString} = require('../services/handlebars'); const {memberCountRounding, getMemberStats} = require('../utils/member-count'); module.exports = async function total_members () { //eslint-disable-line if (this.total) { return new SafeString(m...
javascript
MIT
31ecb69a147e71743e74014b4e04ccce09ab8c1a
2026-01-04T14:57:14.657301Z
false
TryGhost/Ghost
https://github.com/TryGhost/Ghost/blob/31ecb69a147e71743e74014b4e04ccce09ab8c1a/ghost/core/core/frontend/helpers/collection.js
ghost/core/core/frontend/helpers/collection.js
// # Get Helper // Usage: `{{#get "posts" limit="5"}}`, `{{#get "tags" limit="all"}}` // Fetches data from the API const {config, api, prepareContextResource} = require('../services/proxy'); const {hbs} = require('../services/handlebars'); const logging = require('@tryghost/logging'); const errors = require('@tryghost...
javascript
MIT
31ecb69a147e71743e74014b4e04ccce09ab8c1a
2026-01-04T14:57:14.657301Z
false
TryGhost/Ghost
https://github.com/TryGhost/Ghost/blob/31ecb69a147e71743e74014b4e04ccce09ab8c1a/ghost/core/core/frontend/helpers/title.js
ghost/core/core/frontend/helpers/title.js
// # Title Helper // Usage: `{{title}}` // // Overrides the standard behavior of `{[title}}` to ensure the content is correctly escaped const {SafeString, escapeExpression} = require('../services/handlebars'); module.exports = function title() { return new SafeString(escapeExpression(this.title || '')); };
javascript
MIT
31ecb69a147e71743e74014b4e04ccce09ab8c1a
2026-01-04T14:57:14.657301Z
false
TryGhost/Ghost
https://github.com/TryGhost/Ghost/blob/31ecb69a147e71743e74014b4e04ccce09ab8c1a/ghost/core/core/frontend/helpers/content_api_key.js
ghost/core/core/frontend/helpers/content_api_key.js
const {SafeString} = require('../services/handlebars'); const logging = require('@tryghost/logging'); const {getFrontendKey} = require('../services/proxy'); module.exports = async function content_api_key() { // eslint-disable-line camelcase try { const frontendKey = await getFrontendKey(); if (!f...
javascript
MIT
31ecb69a147e71743e74014b4e04ccce09ab8c1a
2026-01-04T14:57:14.657301Z
false
TryGhost/Ghost
https://github.com/TryGhost/Ghost/blob/31ecb69a147e71743e74014b4e04ccce09ab8c1a/ghost/core/core/frontend/helpers/is.js
ghost/core/core/frontend/helpers/is.js
// # Is Helper // Usage: `{{#is "paged"}}`, `{{#is "index, paged"}}` // Checks whether we're in a given context. const logging = require('@tryghost/logging'); const tpl = require('@tryghost/tpl'); const _ = require('lodash'); const messages = { invalidAttribute: 'Invalid or no attribute given to is helper' }; mod...
javascript
MIT
31ecb69a147e71743e74014b4e04ccce09ab8c1a
2026-01-04T14:57:14.657301Z
false
TryGhost/Ghost
https://github.com/TryGhost/Ghost/blob/31ecb69a147e71743e74014b4e04ccce09ab8c1a/ghost/core/core/frontend/helpers/match.js
ghost/core/core/frontend/helpers/match.js
const {SafeString} = require('../services/handlebars'); const logging = require('@tryghost/logging'); const tpl = require('@tryghost/tpl'); const _ = require('lodash'); const messages = { invalidAttribute: 'Invalid or no attribute given to match helper' }; /** * This is identical to the built-in if helper, exc...
javascript
MIT
31ecb69a147e71743e74014b4e04ccce09ab8c1a
2026-01-04T14:57:14.657301Z
false
TryGhost/Ghost
https://github.com/TryGhost/Ghost/blob/31ecb69a147e71743e74014b4e04ccce09ab8c1a/ghost/core/core/frontend/helpers/comments.js
ghost/core/core/frontend/helpers/comments.js
const {SafeString} = require('../services/handlebars'); const {labs, urlUtils, getFrontendKey, settingsCache} = require('../services/proxy'); const {getFrontendAppConfig, getDataAttributes} = require('../utils/frontend-apps'); module.exports = async function comments(options) { // todo: For now check on the commen...
javascript
MIT
31ecb69a147e71743e74014b4e04ccce09ab8c1a
2026-01-04T14:57:14.657301Z
false
TryGhost/Ghost
https://github.com/TryGhost/Ghost/blob/31ecb69a147e71743e74014b4e04ccce09ab8c1a/ghost/core/core/frontend/helpers/total_paid_members.js
ghost/core/core/frontend/helpers/total_paid_members.js
// {{total_paid_members}} helper const {SafeString} = require('../services/handlebars'); const {memberCountRounding, getMemberStats} = require('../utils/member-count'); module.exports = async function total_paid_members () { //eslint-disable-line if (this.paid) { return new SafeString(memberCountRounding(...
javascript
MIT
31ecb69a147e71743e74014b4e04ccce09ab8c1a
2026-01-04T14:57:14.657301Z
false
TryGhost/Ghost
https://github.com/TryGhost/Ghost/blob/31ecb69a147e71743e74014b4e04ccce09ab8c1a/ghost/core/core/frontend/helpers/tiers.js
ghost/core/core/frontend/helpers/tiers.js
// # Tiers Helper // Usage: `{{tiers}}`, `{{tiers separator=' - ' prefix=' : ' suffix=''}}` // // Returns a string of the tiers with access to the post. // By default, tiers are separated by commas. const {SafeString, escapeExpression} = require('../services/handlebars'); const isString = require('lodash/isString'); ...
javascript
MIT
31ecb69a147e71743e74014b4e04ccce09ab8c1a
2026-01-04T14:57:14.657301Z
false
TryGhost/Ghost
https://github.com/TryGhost/Ghost/blob/31ecb69a147e71743e74014b4e04ccce09ab8c1a/ghost/core/core/frontend/helpers/cancel_link.js
ghost/core/core/frontend/helpers/cancel_link.js
// # {{cancel_link}} Helper // Usage: `{{cancel_link}}`, `{{cancel_link class="custom-cancel-class"}}`, `{{cancel_link cancelLabel="Cancel please!"}}` // // Should be used inside of a subscription context, e.g.: `{{#foreach @member.subscriptions}} {{cancel_link}} {{/foreach}}` // Outputs cancel/renew links to manage su...
javascript
MIT
31ecb69a147e71743e74014b4e04ccce09ab8c1a
2026-01-04T14:57:14.657301Z
false
TryGhost/Ghost
https://github.com/TryGhost/Ghost/blob/31ecb69a147e71743e74014b4e04ccce09ab8c1a/ghost/core/core/frontend/helpers/content_api_url.js
ghost/core/core/frontend/helpers/content_api_url.js
const {SafeString} = require('../services/handlebars'); const logging = require('@tryghost/logging'); const {urlUtils} = require('../services/proxy'); module.exports = function content_api_url(options) { // eslint-disable-line camelcase let result; const absoluteUrlRequested = getAbsoluteOption(options); ...
javascript
MIT
31ecb69a147e71743e74014b4e04ccce09ab8c1a
2026-01-04T14:57:14.657301Z
false
TryGhost/Ghost
https://github.com/TryGhost/Ghost/blob/31ecb69a147e71743e74014b4e04ccce09ab8c1a/ghost/core/core/frontend/helpers/ghost_foot.js
ghost/core/core/frontend/helpers/ghost_foot.js
// # Ghost Foot Helper // Usage: `{{ghost_foot}}` // // Outputs scripts and other assets at the bottom of a Ghost theme const {settingsCache} = require('../services/proxy'); const {SafeString} = require('../services/handlebars'); const _ = require('lodash'); // We use the name ghost_foot to match the helper for consis...
javascript
MIT
31ecb69a147e71743e74014b4e04ccce09ab8c1a
2026-01-04T14:57:14.657301Z
false
TryGhost/Ghost
https://github.com/TryGhost/Ghost/blob/31ecb69a147e71743e74014b4e04ccce09ab8c1a/ghost/core/core/frontend/helpers/tags.js
ghost/core/core/frontend/helpers/tags.js
// # Tags Helper // Usage: `{{tags}}`, `{{tags separator=' - '}}` // // Returns a string of the tags on the post. // By default, tags are separated by commas. // // Note that the standard {{#each tags}} implementation is unaffected by this helper const {urlService} = require('../services/proxy'); const {SafeString, esc...
javascript
MIT
31ecb69a147e71743e74014b4e04ccce09ab8c1a
2026-01-04T14:57:14.657301Z
false
TryGhost/Ghost
https://github.com/TryGhost/Ghost/blob/31ecb69a147e71743e74014b4e04ccce09ab8c1a/ghost/core/core/frontend/helpers/prev_post.js
ghost/core/core/frontend/helpers/prev_post.js
// ### prevNext helper exposes methods for prev_post and next_post - separately defined in helpers index. // Example usages // `{{#prev_post}}<a href ="{{url}}>previous post</a>{{/prev_post}}' // `{{#next_post}}<a href ="{{url absolute="true">next post</a>{{/next_post}}' const {api} = require('../services/proxy'); con...
javascript
MIT
31ecb69a147e71743e74014b4e04ccce09ab8c1a
2026-01-04T14:57:14.657301Z
false
TryGhost/Ghost
https://github.com/TryGhost/Ghost/blob/31ecb69a147e71743e74014b4e04ccce09ab8c1a/ghost/core/core/frontend/helpers/date.js
ghost/core/core/frontend/helpers/date.js
// # Date Helper // Usage: `{{date format="DD MM, YYYY"}}`, `{{date updated_at format="DD MM, YYYY"}}` // // Formats a date using moment-timezone.js. Formats published_at by default but will also take a date as a parameter const {SafeString} = require('../services/handlebars'); const moment = require('moment-timezone'...
javascript
MIT
31ecb69a147e71743e74014b4e04ccce09ab8c1a
2026-01-04T14:57:14.657301Z
false
TryGhost/Ghost
https://github.com/TryGhost/Ghost/blob/31ecb69a147e71743e74014b4e04ccce09ab8c1a/ghost/core/core/frontend/helpers/content.js
ghost/core/core/frontend/helpers/content.js
// # Content Helper // Usage: `{{content}}`, `{{content words="20"}}`, `{{content characters="256"}}` // // Turns content html into a safestring so that the user doesn't have to // escape it or tell handlebars to leave it alone with a triple-brace. // // Shows default or custom CTA when trying to see content without ac...
javascript
MIT
31ecb69a147e71743e74014b4e04ccce09ab8c1a
2026-01-04T14:57:14.657301Z
false
TryGhost/Ghost
https://github.com/TryGhost/Ghost/blob/31ecb69a147e71743e74014b4e04ccce09ab8c1a/ghost/core/core/frontend/helpers/asset.js
ghost/core/core/frontend/helpers/asset.js
// # Asset helper // Usage: `{{asset "css/screen.css"}}` // // Returns the path to the specified asset. const {metaData, urlUtils} = require('../services/proxy'); const {SafeString} = require('../services/handlebars'); const errors = require('@tryghost/errors'); const tpl = require('@tryghost/tpl'); const get = requir...
javascript
MIT
31ecb69a147e71743e74014b4e04ccce09ab8c1a
2026-01-04T14:57:14.657301Z
false
TryGhost/Ghost
https://github.com/TryGhost/Ghost/blob/31ecb69a147e71743e74014b4e04ccce09ab8c1a/ghost/core/core/frontend/helpers/comment_count.js
ghost/core/core/frontend/helpers/comment_count.js
const {SafeString} = require('../services/handlebars'); module.exports = function commentCount(options) { // Lazy require the dependency to keep boot fast const {html} = require('common-tags'); const empty = options.hash.empty === undefined ? '' : options.hash.empty; const singular = options.hash.sing...
javascript
MIT
31ecb69a147e71743e74014b4e04ccce09ab8c1a
2026-01-04T14:57:14.657301Z
false
TryGhost/Ghost
https://github.com/TryGhost/Ghost/blob/31ecb69a147e71743e74014b4e04ccce09ab8c1a/ghost/core/core/frontend/helpers/page_url.js
ghost/core/core/frontend/helpers/page_url.js
// ### Page URL Helper // // *Usage example:* // `{{page_url 2}}` // // Returns the URL for the page specified in the current object context. const {metaData} = require('../services/proxy'); const getPaginatedUrl = metaData.getPaginatedUrl; // We use the name page_url to match the helper for consistency: module.export...
javascript
MIT
31ecb69a147e71743e74014b4e04ccce09ab8c1a
2026-01-04T14:57:14.657301Z
false
TryGhost/Ghost
https://github.com/TryGhost/Ghost/blob/31ecb69a147e71743e74014b4e04ccce09ab8c1a/ghost/core/core/frontend/helpers/body_class.js
ghost/core/core/frontend/helpers/body_class.js
// # Body Class Helper // Usage: `{{body_class}}` // // Output classes for the body element const {settingsCache} = require('../services/proxy'); const {generateCustomFontBodyClass, isValidCustomFont, isValidCustomHeadingFont} = require('@tryghost/custom-fonts'); const {SafeString} = require('../services/handlebars'); ...
javascript
MIT
31ecb69a147e71743e74014b4e04ccce09ab8c1a
2026-01-04T14:57:14.657301Z
false
TryGhost/Ghost
https://github.com/TryGhost/Ghost/blob/31ecb69a147e71743e74014b4e04ccce09ab8c1a/ghost/core/core/frontend/helpers/readable_url.js
ghost/core/core/frontend/helpers/readable_url.js
// # Readable URL helper // Usage: `{{readable_url "https://google.com"}}` // // Returns a human readable URL for the given URL, e.g. google.com for https://www.google.com?query=1#section const logging = require('@tryghost/logging'); const sentry = require('../../shared/sentry'); const errors = require('@tryghost/erro...
javascript
MIT
31ecb69a147e71743e74014b4e04ccce09ab8c1a
2026-01-04T14:57:14.657301Z
false
TryGhost/Ghost
https://github.com/TryGhost/Ghost/blob/31ecb69a147e71743e74014b4e04ccce09ab8c1a/ghost/core/core/frontend/helpers/encode.js
ghost/core/core/frontend/helpers/encode.js
// # Encode Helper // // Usage: `{{encode uri}}` // // Returns URI encoded string const {SafeString} = require('../services/handlebars'); module.exports = function encode(string, options) { const uri = string || options; return new SafeString(encodeURIComponent(uri)); };
javascript
MIT
31ecb69a147e71743e74014b4e04ccce09ab8c1a
2026-01-04T14:57:14.657301Z
false
TryGhost/Ghost
https://github.com/TryGhost/Ghost/blob/31ecb69a147e71743e74014b4e04ccce09ab8c1a/ghost/core/core/frontend/helpers/search.js
ghost/core/core/frontend/helpers/search.js
// # search helper const {SafeString} = require('../services/handlebars'); module.exports = function search() { // We want this to output as one line, but splitting for readability const svg = '<button class="gh-search-icon" aria-label="search" data-ghost-search ' + 'style="display: inline-flex;...
javascript
MIT
31ecb69a147e71743e74014b4e04ccce09ab8c1a
2026-01-04T14:57:14.657301Z
false
TryGhost/Ghost
https://github.com/TryGhost/Ghost/blob/31ecb69a147e71743e74014b4e04ccce09ab8c1a/ghost/core/core/frontend/helpers/link_class.js
ghost/core/core/frontend/helpers/link_class.js
// # link_class helper const {config} = require('../services/proxy'); const {SafeString, localUtils} = require('../services/handlebars'); const _ = require('lodash'); const errors = require('@tryghost/errors'); const tpl = require('@tryghost/tpl'); const {buildLinkClasses} = localUtils; const messages = { forIsR...
javascript
MIT
31ecb69a147e71743e74014b4e04ccce09ab8c1a
2026-01-04T14:57:14.657301Z
false
TryGhost/Ghost
https://github.com/TryGhost/Ghost/blob/31ecb69a147e71743e74014b4e04ccce09ab8c1a/ghost/core/core/frontend/helpers/url.js
ghost/core/core/frontend/helpers/url.js
// # URL helper // Usage: `{{url}}`, `{{url absolute="true"}}` // // Returns the URL for the current object scope i.e. If inside a post scope will return post permalink // `absolute` flag outputs absolute URL, else URL is relative const {metaData} = require('../services/proxy'); const {SafeString} = require('../servic...
javascript
MIT
31ecb69a147e71743e74014b4e04ccce09ab8c1a
2026-01-04T14:57:14.657301Z
false
TryGhost/Ghost
https://github.com/TryGhost/Ghost/blob/31ecb69a147e71743e74014b4e04ccce09ab8c1a/ghost/core/core/frontend/helpers/concat.js
ghost/core/core/frontend/helpers/concat.js
const {SafeString} = require('../services/handlebars'); module.exports = function concat(...args) { const options = args.pop(); const separator = options.hash.separator || ''; // Flatten arrays - if an argument is an array, spread its elements const flattenedArgs = args.flat(); return new SafeStr...
javascript
MIT
31ecb69a147e71743e74014b4e04ccce09ab8c1a
2026-01-04T14:57:14.657301Z
false
TryGhost/Ghost
https://github.com/TryGhost/Ghost/blob/31ecb69a147e71743e74014b4e04ccce09ab8c1a/ghost/core/core/frontend/helpers/recommendations.js
ghost/core/core/frontend/helpers/recommendations.js
/* Recommendations helper * Usage: `{{recommendations}}` * * Renders the template defined in `tpl/recommendations.hbs` * Can be overridden by themes by uploading a partial under `partials/recommendations.hbs` * * Available options: limit, order, filter, page */ const {config, api, prepareContextResource, setting...
javascript
MIT
31ecb69a147e71743e74014b4e04ccce09ab8c1a
2026-01-04T14:57:14.657301Z
false
TryGhost/Ghost
https://github.com/TryGhost/Ghost/blob/31ecb69a147e71743e74014b4e04ccce09ab8c1a/ghost/core/core/frontend/helpers/meta_title.js
ghost/core/core/frontend/helpers/meta_title.js
// # Meta Title Helper // Usage: `{{meta_title}}` // // Page title used for sharing and SEO const {metaData} = require('../services/proxy'); const {getMetaDataTitle} = metaData; // We use the name meta_title to match the helper for consistency: module.exports = function meta_title(options) { // eslint-disable-line cam...
javascript
MIT
31ecb69a147e71743e74014b4e04ccce09ab8c1a
2026-01-04T14:57:14.657301Z
false
TryGhost/Ghost
https://github.com/TryGhost/Ghost/blob/31ecb69a147e71743e74014b4e04ccce09ab8c1a/ghost/core/core/frontend/helpers/navigation.js
ghost/core/core/frontend/helpers/navigation.js
// ### Navigation Helper // `{{navigation}}` // Outputs navigation menu of static urls const {SafeString, templates, hbs} = require('../services/handlebars'); const errors = require('@tryghost/errors'); const tpl = require('@tryghost/tpl'); const {slugify} = require('@tryghost/string'); const _ = require('lodash'); c...
javascript
MIT
31ecb69a147e71743e74014b4e04ccce09ab8c1a
2026-01-04T14:57:14.657301Z
false
TryGhost/Ghost
https://github.com/TryGhost/Ghost/blob/31ecb69a147e71743e74014b4e04ccce09ab8c1a/ghost/core/core/frontend/helpers/split.js
ghost/core/core/frontend/helpers/split.js
const {SafeString} = require('handlebars'); function renderResult(result, options, data) { if (options && typeof options.fn === 'function') { return options.fn(result, {data, blockParams: [result]}); } return result; } module.exports = function split(...args) { const options = args.pop(); ...
javascript
MIT
31ecb69a147e71743e74014b4e04ccce09ab8c1a
2026-01-04T14:57:14.657301Z
false
TryGhost/Ghost
https://github.com/TryGhost/Ghost/blob/31ecb69a147e71743e74014b4e04ccce09ab8c1a/ghost/core/core/frontend/helpers/pagination.js
ghost/core/core/frontend/helpers/pagination.js
// ### Pagination Helper // `{{pagination}}` // Outputs previous and next buttons, along with info about the current page const {templates, hbs} = require('../services/handlebars'); const errors = require('@tryghost/errors'); const tpl = require('@tryghost/tpl'); const _ = require('lodash'); const messages = { in...
javascript
MIT
31ecb69a147e71743e74014b4e04ccce09ab8c1a
2026-01-04T14:57:14.657301Z
false
TryGhost/Ghost
https://github.com/TryGhost/Ghost/blob/31ecb69a147e71743e74014b4e04ccce09ab8c1a/ghost/core/core/frontend/helpers/twitter_url.js
ghost/core/core/frontend/helpers/twitter_url.js
// # Twitter URL Helper // Usage: `{{twitter_url}}` or `{{twitter_url author.twitter}}` // // Output a url for a twitter username const {socialUrls} = require('../services/proxy'); const {localUtils} = require('../services/handlebars'); // We use the name twitter_url to match the helper for consistency: /** * @deprec...
javascript
MIT
31ecb69a147e71743e74014b4e04ccce09ab8c1a
2026-01-04T14:57:14.657301Z
false
TryGhost/Ghost
https://github.com/TryGhost/Ghost/blob/31ecb69a147e71743e74014b4e04ccce09ab8c1a/ghost/core/core/frontend/helpers/get.js
ghost/core/core/frontend/helpers/get.js
// # Get Helper // Usage: `{{#get "posts" limit="5"}}`, `{{#get "tags" limit="all"}}` // Fetches data from the API const {config, api, prepareContextResource} = require('../services/proxy'); const {hbs, SafeString} = require('../services/handlebars'); const {applyLimitCap} = require('../../shared/max-limit-cap'); cons...
javascript
MIT
31ecb69a147e71743e74014b4e04ccce09ab8c1a
2026-01-04T14:57:14.657301Z
false
TryGhost/Ghost
https://github.com/TryGhost/Ghost/blob/31ecb69a147e71743e74014b4e04ccce09ab8c1a/ghost/core/core/frontend/helpers/tpl/styles.js
ghost/core/core/frontend/helpers/tpl/styles.js
/* Default CSS Styles for helpers which are appended in theme via ghost_head */ const contentHelper = `.gh-post-upgrade-cta-content, .gh-post-upgrade-cta { display: flex; flex-direction: column; align-items: center; font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, Cant...
javascript
MIT
31ecb69a147e71743e74014b4e04ccce09ab8c1a
2026-01-04T14:57:14.657301Z
false
TryGhost/Ghost
https://github.com/TryGhost/Ghost/blob/31ecb69a147e71743e74014b4e04ccce09ab8c1a/ghost/core/core/frontend/src/cards/js/toggle.js
ghost/core/core/frontend/src/cards/js/toggle.js
(function() { const toggleHeadingElements = document.getElementsByClassName("kg-toggle-heading"); const toggleFn = function(event) { const targetElement = event.target; const parentElement = targetElement.closest('.kg-toggle-card'); var toggleState = parentElement.getAttribute("data-kg-...
javascript
MIT
31ecb69a147e71743e74014b4e04ccce09ab8c1a
2026-01-04T14:57:14.657301Z
false
TryGhost/Ghost
https://github.com/TryGhost/Ghost/blob/31ecb69a147e71743e74014b4e04ccce09ab8c1a/ghost/core/core/frontend/src/cards/js/gallery.js
ghost/core/core/frontend/src/cards/js/gallery.js
(function() { const images = document.querySelectorAll('.kg-gallery-image img'); images.forEach(function (image) { const container = image.closest('.kg-gallery-image'); const width = image.attributes.width.value; const height = image.attributes.height.value; const ratio = width /...
javascript
MIT
31ecb69a147e71743e74014b4e04ccce09ab8c1a
2026-01-04T14:57:14.657301Z
false
TryGhost/Ghost
https://github.com/TryGhost/Ghost/blob/31ecb69a147e71743e74014b4e04ccce09ab8c1a/ghost/core/core/frontend/src/cards/js/video.js
ghost/core/core/frontend/src/cards/js/video.js
(function() { const handleVideoPlayer = function (videoElementContainer) { const videoPlayer = videoElementContainer.querySelector('.kg-video-player'); const videoPlayerContainer = videoElementContainer.querySelector('.kg-video-player-container'); const playIconContainer = videoElementContai...
javascript
MIT
31ecb69a147e71743e74014b4e04ccce09ab8c1a
2026-01-04T14:57:14.657301Z
false
TryGhost/Ghost
https://github.com/TryGhost/Ghost/blob/31ecb69a147e71743e74014b4e04ccce09ab8c1a/ghost/core/core/frontend/src/cards/js/audio.js
ghost/core/core/frontend/src/cards/js/audio.js
(function() { const handleAudioPlayer = function (audioElementContainer) { const audioPlayerContainer = audioElementContainer.querySelector('.kg-audio-player-container'); const playIconContainer = audioElementContainer.querySelector('.kg-audio-play-icon'); const pauseIconContainer = audioEle...
javascript
MIT
31ecb69a147e71743e74014b4e04ccce09ab8c1a
2026-01-04T14:57:14.657301Z
false
TryGhost/Ghost
https://github.com/TryGhost/Ghost/blob/31ecb69a147e71743e74014b4e04ccce09ab8c1a/ghost/core/core/frontend/src/utils/privacy.js
ghost/core/core/frontend/src/utils/privacy.js
/** * Utility functions for data privacy and PII protection */ /** * Default attributes that should be masked for privacy */ export const SENSITIVE_ATTRIBUTES = [ 'username', 'user', 'user_id', 'userid', 'password', 'pass', 'pin', 'passcode', 'token', 'api_token', ...
javascript
MIT
31ecb69a147e71743e74014b4e04ccce09ab8c1a
2026-01-04T14:57:14.657301Z
false
TryGhost/Ghost
https://github.com/TryGhost/Ghost/blob/31ecb69a147e71743e74014b4e04ccce09ab8c1a/ghost/core/core/frontend/src/utils/url-attribution.js
ghost/core/core/frontend/src/utils/url-attribution.js
/** * Utility functions for URL and referrer attribution parsing */ /** * @typedef {Object} AttributionData * @property {string|null} source - Primary attribution source (ref || source || utm_source) * @property {string|null} medium - UTM medium parameter * @property {string|null} url - Browser's document.referr...
javascript
MIT
31ecb69a147e71743e74014b4e04ccce09ab8c1a
2026-01-04T14:57:14.657301Z
false
TryGhost/Ghost
https://github.com/TryGhost/Ghost/blob/31ecb69a147e71743e74014b4e04ccce09ab8c1a/ghost/core/core/frontend/src/ghost-stats/ghost-stats.js
ghost/core/core/frontend/src/ghost-stats/ghost-stats.js
import { getCountryForTimezone } from 'countries-and-timezones'; import { getReferrer, parseReferrerData } from '../utils/url-attribution'; import { processPayload } from '../utils/privacy'; import { BrowserService } from './browser-service'; /** * @typedef {Object} TinybirdApi * @property {function} trackEvent - Fu...
javascript
MIT
31ecb69a147e71743e74014b4e04ccce09ab8c1a
2026-01-04T14:57:14.657301Z
false
TryGhost/Ghost
https://github.com/TryGhost/Ghost/blob/31ecb69a147e71743e74014b4e04ccce09ab8c1a/ghost/core/core/frontend/src/ghost-stats/browser-service.js
ghost/core/core/frontend/src/ghost-stats/browser-service.js
/** * @typedef {Object} CustomWindow * @property {any} [__nightmare] * @property {any} [Cypress] * @property {any} [Tinybird] * @property {boolean} [__GHOST_SYNTHETIC_MONITORING__] */ /** * @typedef {Window & typeof globalThis & CustomWindow} ExtendedWindow */ export class BrowserService { /** * @par...
javascript
MIT
31ecb69a147e71743e74014b4e04ccce09ab8c1a
2026-01-04T14:57:14.657301Z
false
TryGhost/Ghost
https://github.com/TryGhost/Ghost/blob/31ecb69a147e71743e74014b4e04ccce09ab8c1a/ghost/core/core/frontend/src/member-attribution/member-attribution.js
ghost/core/core/frontend/src/member-attribution/member-attribution.js
/* eslint-env browser */ /* eslint-disable no-console */ const urlAttribution = require('../utils/url-attribution'); const parseReferrerData = urlAttribution.parseReferrerData; const getReferrer = urlAttribution.getReferrer; // Location where we want to store the history in sessionStorage const STORAGE_KEY = 'ghost-hi...
javascript
MIT
31ecb69a147e71743e74014b4e04ccce09ab8c1a
2026-01-04T14:57:14.657301Z
false
TryGhost/Ghost
https://github.com/TryGhost/Ghost/blob/31ecb69a147e71743e74014b4e04ccce09ab8c1a/ghost/core/core/frontend/src/comment-counts/comment-counts.js
ghost/core/core/frontend/src/comment-counts/comment-counts.js
(async function () { const countsMap = {}; const fetchingIds = new Set(); const api = document.querySelector('[data-ghost-comments-counts-api]') .dataset.ghostCommentsCountsApi; const debounce = function (func, timeout = 100) { let timer; return (...args) => { clear...
javascript
MIT
31ecb69a147e71743e74014b4e04ccce09ab8c1a
2026-01-04T14:57:14.657301Z
false
TryGhost/Ghost
https://github.com/TryGhost/Ghost/blob/31ecb69a147e71743e74014b4e04ccce09ab8c1a/ghost/core/core/frontend/src/admin-auth/message-handler.js
ghost/core/core/frontend/src/admin-auth/message-handler.js
const adminUrl = window.location.href.replace('auth-frame/', '') + 'api/admin'; // At compile time, we'll replace the value with the actual origin. const siteOrigin = '{{SITE_ORIGIN}}'; window.addEventListener('message', async function (event) { if (event.origin !== siteOrigin) { console.warn('Ignored mes...
javascript
MIT
31ecb69a147e71743e74014b4e04ccce09ab8c1a
2026-01-04T14:57:14.657301Z
false
TryGhost/Ghost
https://github.com/TryGhost/Ghost/blob/31ecb69a147e71743e74014b4e04ccce09ab8c1a/ghost/core/core/frontend/public/admin-auth/admin-auth.min.js
ghost/core/core/frontend/public/admin-auth/admin-auth.min.js
"use strict";const adminUrl=window.location.href.replace("auth-frame/","")+"api/admin",siteOrigin="{{SITE_ORIGIN}}";window.addEventListener("message",async function(a){if(a.origin!==siteOrigin){console.warn("Ignored message to admin auth iframe because of mismatch in origin","expected",siteOrigin,"got",a.origin,"with d...
javascript
MIT
31ecb69a147e71743e74014b4e04ccce09ab8c1a
2026-01-04T14:57:14.657301Z
false
TryGhost/Ghost
https://github.com/TryGhost/Ghost/blob/31ecb69a147e71743e74014b4e04ccce09ab8c1a/ghost/core/core/frontend/utils/frontend-apps.js
ghost/core/core/frontend/utils/frontend-apps.js
const {config} = require('../services/proxy'); function getFrontendAppConfig(app) { const appVersion = config.get(`${app}:version`); let scriptUrl = config.get(`${app}:url`); let stylesUrl = config.get(`${app}:styles`); if (typeof scriptUrl === 'string' && scriptUrl.includes('{version}')) { scr...
javascript
MIT
31ecb69a147e71743e74014b4e04ccce09ab8c1a
2026-01-04T14:57:14.657301Z
false
TryGhost/Ghost
https://github.com/TryGhost/Ghost/blob/31ecb69a147e71743e74014b4e04ccce09ab8c1a/ghost/core/core/frontend/utils/member-count.js
ghost/core/core/frontend/utils/member-count.js
const humanNumber = require('human-number'); const {api} = require('../services/proxy'); async function getMemberStats() { let memberStats = this.data || await api.stats.memberCountHistory.query(); const {free, paid, comped} = memberStats.meta.totals; let total = free + paid + comped; return {free, pai...
javascript
MIT
31ecb69a147e71743e74014b4e04ccce09ab8c1a
2026-01-04T14:57:14.657301Z
false
TryGhost/Ghost
https://github.com/TryGhost/Ghost/blob/31ecb69a147e71743e74014b4e04ccce09ab8c1a/ghost/core/core/frontend/utils/images.js
ghost/core/core/frontend/utils/images.js
const url = require('url'); const imageTransform = require('@tryghost/image-transform'); const urlUtils = require('../../shared/url-utils'); module.exports.detectInternalImage = function detectInternalImage(requestedImageUrl) { const siteUrl = urlUtils.getSiteUrl(); const isAbsoluteImage = /https?:\/\//.test(r...
javascript
MIT
31ecb69a147e71743e74014b4e04ccce09ab8c1a
2026-01-04T14:57:14.657301Z
false
TryGhost/Ghost
https://github.com/TryGhost/Ghost/blob/31ecb69a147e71743e74014b4e04ccce09ab8c1a/ghost/core/core/frontend/web/index.js
ghost/core/core/frontend/web/index.js
module.exports = require('./site');
javascript
MIT
31ecb69a147e71743e74014b4e04ccce09ab8c1a
2026-01-04T14:57:14.657301Z
false
TryGhost/Ghost
https://github.com/TryGhost/Ghost/blob/31ecb69a147e71743e74014b4e04ccce09ab8c1a/ghost/core/core/frontend/web/site.js
ghost/core/core/frontend/web/site.js
const debug = require('@tryghost/debug')('frontend'); const path = require('path'); const express = require('../../shared/express'); const DomainEvents = require('@tryghost/domain-events'); const {MemberPageViewEvent} = require('../../shared/events'); // App requires const config = require('../../shared/config'); cons...
javascript
MIT
31ecb69a147e71743e74014b4e04ccce09ab8c1a
2026-01-04T14:57:14.657301Z
false
TryGhost/Ghost
https://github.com/TryGhost/Ghost/blob/31ecb69a147e71743e74014b4e04ccce09ab8c1a/ghost/core/core/frontend/web/routes.js
ghost/core/core/frontend/web/routes.js
const debug = require('@tryghost/debug')('frontend:routes'); const routing = require('../services/routing'); /** * * @param {import('../services/routing/RouterManager').RouterConfig} routerConfig * @returns {import('express').Router} */ module.exports = function siteRoutes(routerConfig) { debug('site Routes', ...
javascript
MIT
31ecb69a147e71743e74014b4e04ccce09ab8c1a
2026-01-04T14:57:14.657301Z
false
TryGhost/Ghost
https://github.com/TryGhost/Ghost/blob/31ecb69a147e71743e74014b4e04ccce09ab8c1a/ghost/core/core/frontend/web/middleware/cors.js
ghost/core/core/frontend/web/middleware/cors.js
const {URL} = require('url'); const cors = require('cors'); const errors = require('@tryghost/errors'); const config = require('../../../shared/config'); /** * Dynamically configures the expressjs/cors middleware * * @param {import('express').Request} req * @param {Function} callback */ function corsOptionsDelega...
javascript
MIT
31ecb69a147e71743e74014b4e04ccce09ab8c1a
2026-01-04T14:57:14.657301Z
false
TryGhost/Ghost
https://github.com/TryGhost/Ghost/blob/31ecb69a147e71743e74014b4e04ccce09ab8c1a/ghost/core/core/frontend/web/middleware/index.js
ghost/core/core/frontend/web/middleware/index.js
module.exports = { cors: require('./cors'), errorHandler: require('./error-handler'), frontendCaching: require('./frontend-caching'), handleImageSizes: require('./handle-image-sizes'), redirectGhostToAdmin: require('./redirect-ghost-to-admin'), servePublicFile: require('./serve-public-file'), ...
javascript
MIT
31ecb69a147e71743e74014b4e04ccce09ab8c1a
2026-01-04T14:57:14.657301Z
false
TryGhost/Ghost
https://github.com/TryGhost/Ghost/blob/31ecb69a147e71743e74014b4e04ccce09ab8c1a/ghost/core/core/frontend/web/middleware/redirect-ghost-to-admin.js
ghost/core/core/frontend/web/middleware/redirect-ghost-to-admin.js
const express = require('../../../shared/express'); const config = require('../../../shared/config'); const urlUtils = require('../../../shared/url-utils'); // Extract the core redirect logic for easier testing const handleAdminRedirect = function (req, res) { const adminPath = req.path.replace(/^\/ghost/, '') || ...
javascript
MIT
31ecb69a147e71743e74014b4e04ccce09ab8c1a
2026-01-04T14:57:14.657301Z
false
TryGhost/Ghost
https://github.com/TryGhost/Ghost/blob/31ecb69a147e71743e74014b4e04ccce09ab8c1a/ghost/core/core/frontend/web/middleware/serve-public-file.js
ghost/core/core/frontend/web/middleware/serve-public-file.js
const crypto = require('crypto'); const fs = require('fs-extra'); const path = require('path'); const errors = require('@tryghost/errors'); const config = require('../../../shared/config'); const urlUtils = require('../../../shared/url-utils'); const tpl = require('@tryghost/tpl'); const messages = { imageNotFound...
javascript
MIT
31ecb69a147e71743e74014b4e04ccce09ab8c1a
2026-01-04T14:57:14.657301Z
false