Location via proxy:   [ UP ]  
[Report a bug]   [Manage cookies]                
Skip to content

update: prototype – serializedTitle, improving logic, and little revamp #210

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 10 commits into from
May 27, 2025

Conversation

EmptyWork
Copy link
Owner

No description provided.

EmptyWork added 2 commits May 26, 2025 09:03
splicing year and title, where year becomes 2 last digits, and title is first letter of each words
Copy link

netlify bot commented May 26, 2025

Deploy Preview for emptywork ready!

Name Link
🔨 Latest commit 8ad51c5
🔍 Latest deploy log https://app.netlify.com/projects/emptywork/deploys/6833cf2f91ef88000831ed89
😎 Deploy Preview https://deploy-preview-210--emptywork.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify project configuration.

@EmptyWork EmptyWork changed the title update: prototype – serializedTitle update: prototype – serializedTitle, improving logic, and little revamp May 26, 2025
Comment on lines +79 to +104
eleventyConfig.addFilter('cutText', (string, size) => {
return string.split('-').splice(0, size).join('-')
})

eleventyConfig.addFilter('serializeTitle', (string, yearSplice = 2) => {
const titleParts = string.split('-')
const [year, ...title] = titleParts
const titleInitials = title.map(title => title.split('')[0]).join('')
const yearSuffix = year.slice(-yearSplice)

return `${yearSuffix}-${titleInitials}`
})

eleventyConfig.addFilter('breakLine', (string, cutAt = 3, maxSize = 30) => {
const titleWords = string.split(' ')
const titleLength = string.length
const titlePreview = titleWords.slice(0, cutAt).join(" ")
const titleRemaining = titleWords.slice(cutAt).join(" ")

const hasTitleRemaining = !!titleRemaining
const formattedTitleWithBreak = hasTitleRemaining ? `${titlePreview}<br/>${titleRemaining}` : titlePreview

const returnTitle = titleLength <= maxSize || !hasTitleRemaining ? string : formattedTitleWithBreak
return returnTitle
})

Copy link
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Still not sure the naming of the functions, but for now the naming is sufficient.

Copy link
Owner Author

@EmptyWork EmptyWork left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Probably need to review back the naming for .eleventy filters name.

@EmptyWork EmptyWork merged commit 1822d1c into main May 27, 2025
4 checks passed
@EmptyWork EmptyWork deleted the section-prototype-title branch May 27, 2025 00:44
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant