Skip to content

Commit

Permalink
fix: cover path
Browse files Browse the repository at this point in the history
  • Loading branch information
denisavitski committed Sep 26, 2024
1 parent 5359c54 commit c86cd31
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 15 deletions.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "automizer",
"version": "0.3.4",
"version": "0.3.5",
"repository": {
"type": "git",
"url": "git+https://github.com/denisavitski/automizer.git"
Expand Down
9 changes: 1 addition & 8 deletions playground/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,6 @@ import { automizer } from '../src'

automizer({
sourceFolder: 'playground/source',
destinationFolder: 'playground/dest',
destinationFolder: 'public',
clearDestination: true,
settings: {
head: () => {
return {
url: 'https://denisavitski.netlify.app/',
}
},
},
})
16 changes: 10 additions & 6 deletions src/generateHead.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ import { generateFavicon } from './generateFavicon'
import { optimizeImage } from './optimizeImage'
import { OutputItem } from '../lib'
import dedent from 'dedent'
import { join } from 'path'

export async function generateHead(source: Omit<HeadSource, 'type'>) {
const output: Output = []
Expand All @@ -23,17 +24,20 @@ export async function generateHead(source: Omit<HeadSource, 'type'>) {
output.push(...res.slice(0, -1))
}

const base = source.settings.path || ''
const title = source.settings.title || source.settings.appName || ''
const metaTitle = source.settings.metaTitle || title || ''
const description =
source.settings.description || source.settings.appDescription || ''
let url = source.settings.url || ''
url = url.endsWith('/') ? url.slice(0, -1) : url
const keywords = source.settings.keywords || ''
const cover = `${url}${base}${source.settings.destinationCoverPath
.split(base)
.slice(-1)}`

const url = source.settings.url || ''
const path = source.settings.path || ''
const coverName = source.settings.destinationCoverPath
.split('/')
.slice(-1)
.join('/')

const cover = join(url, path, coverName)

head.data += dedent`
<title>${title}</title>
Expand Down

0 comments on commit c86cd31

Please sign in to comment.