mirror of
https://github.com/TryGhost/Ghost.git
synced 2025-01-06 22:40:14 -05:00
Renamed meta/excerpt meta/generate-excerpt
- This function is quite different to the others, as it generates an excerpt from HTML (truncating) - Most functions in the meta data folder just contain content negotiation logic, like if post then feature_image else cover_image type things - This function is more like a library and shouldn't live in Ghost, it should probably be in @tryghost/helpers - It's definitely something we'd love to rewrite to work better tooooo
This commit is contained in:
parent
29af4b93a0
commit
fbf0636936
5 changed files with 5 additions and 5 deletions
|
@ -1,6 +1,6 @@
|
|||
const _ = require('lodash');
|
||||
const settingsCache = require('../../shared/settings-cache');
|
||||
const getExcerpt = require('./excerpt');
|
||||
const getExcerpt = require('./generate-excerpt');
|
||||
|
||||
function getDescription(data, root, options = {}) {
|
||||
const context = root ? root.context : null;
|
||||
|
|
|
@ -24,7 +24,7 @@ const getOgImage = require('./og_image');
|
|||
const getTwitterImage = require('./twitter_image');
|
||||
const getStructuredData = require('./structured_data');
|
||||
const getSchema = require('./schema');
|
||||
const getExcerpt = require('./excerpt');
|
||||
const generateExcerpt = require('./generate-excerpt');
|
||||
|
||||
function getMetaData(data, root) {
|
||||
const metaData = {
|
||||
|
@ -88,7 +88,7 @@ function getMetaData(data, root) {
|
|||
// @TODO: https://github.com/TryGhost/Ghost/issues/10062
|
||||
customExcerpt = data.post.excerpt || data.post.custom_excerpt;
|
||||
metaDescription = data.post.meta_description;
|
||||
fallbackExcerpt = data.post.html ? getExcerpt(data.post.html, {words: 50}) : '';
|
||||
fallbackExcerpt = data.post.html ? generateExcerpt(data.post.html, {words: 50}) : '';
|
||||
|
||||
metaData.excerpt = customExcerpt ? customExcerpt : metaDescription ? metaDescription : fallbackExcerpt;
|
||||
}
|
||||
|
|
|
@ -53,7 +53,7 @@ module.exports = {
|
|||
metaData: {
|
||||
get: require('../meta'), // ghost_head
|
||||
getAssetUrl: require('../meta/asset_url'), // asset
|
||||
getMetaDataExcerpt: require('../meta/excerpt'), // excerpt
|
||||
getMetaDataExcerpt: require('../meta/generate-excerpt'), // excerpt
|
||||
getMetaDataDescription: require('../meta/description'), // meta_desc
|
||||
getMetaDataTitle: require('../meta/title'), // meta_title
|
||||
getPaginatedUrl: require('../meta/paginated_url'), // page_url
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
const should = require('should');
|
||||
const getExcerpt = require('../../../core/frontend/meta/excerpt');
|
||||
const getExcerpt = require('../../../core/frontend/meta/generate-excerpt');
|
||||
|
||||
describe('getExcerpt', function () {
|
||||
it('should return html excerpt with no html', function () {
|
Loading…
Reference in a new issue