Skip to content

Commit

Permalink
fix lint, ncu
Browse files Browse the repository at this point in the history
  • Loading branch information
lexoyo committed Nov 16, 2023
1 parent d243e44 commit d1f9486
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 13 deletions.
6 changes: 3 additions & 3 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -26,13 +26,13 @@
"@rollup/plugin-eslint": "^9.0.5",
"@rollup/plugin-node-resolve": "^15.2.3",
"@rollup/plugin-typescript": "^11.1.5",
"@typescript-eslint/eslint-plugin": "^6.10.0",
"@typescript-eslint/parser": "^6.10.0",
"@typescript-eslint/eslint-plugin": "^6.11.0",
"@typescript-eslint/parser": "^6.11.0",
"eslint": "^8.53.0",
"jest": "^29.7.0",
"node_modules-path": "^2.0.7",
"nodemon": "^3.0.1",
"rollup": "^4.3.0",
"rollup": "^4.4.1",
"ts-jest": "^29.1.1",
"tslib": "^2.6.2",
"typescript": "^5.2.2"
Expand Down
21 changes: 11 additions & 10 deletions src/client/publication.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,15 +3,16 @@ import { DataSourceEditor, StoredState, getState, getStateIds } from '@silexlabs
import { echoBlock, ifBlock } from '../liquid'
import { ClientSideFileType, PublicationData } from '@silexlabs/silex/src/ts/types'
import { EleventyPluginOptions } from '../client'
import { PublicationTransformer } from '@silexlabs/silex/src/ts/client/publication-transformers'

/**
* Make html attribute
* Quote strings, no values for boolean
*/
function makeAttribute(key, value) {
switch (typeof value) {
case 'boolean': return value ? key : ''
default: return `${key}="${value}"`
case 'boolean': return value ? key : ''
default: return `${key}="${value}"`
}
}

Expand All @@ -27,7 +28,7 @@ function makeStyle(key, value) {
*/
export function transformPath(editor: DataSourceEditor, path: string, type: ClientSideFileType): string {
const config = editor.getModel().get('config')
return config.publicationTransformers.reduce((result: string, transformer: any) => {
return config.publicationTransformers.reduce((result: string, transformer: PublicationTransformer) => {
try {
return transformer.transformPath ? transformer.transformPath(result, type) ?? result : result
} catch (e) {
Expand Down Expand Up @@ -61,10 +62,10 @@ export function transformFiles(editor: DataSourceEditor, options: EleventyPlugin
}

function getDataFile(editor: DataSourceEditor, page: Page, query: Record<string, string>): string {
const content = Object.entries(query).map(([dataSourceId, query]) => {
const content = Object.entries(query).map(([dataSourceId, queryStr]) => {
const dataSource = editor.DataSourceManager.get(dataSourceId)
if (dataSource) {
return queryToDataFile(dataSource)
return queryToDataFile(dataSource, queryStr)
} else {
console.error('No data source for id', dataSourceId)
throw new Error(`No data source for id ${dataSourceId}`)
Expand All @@ -80,7 +81,7 @@ module.exports = async function () {
`
}

function queryToDataFile(dataSource) {
function queryToDataFile(dataSource, queryStr) {
if (dataSource.get('type') !== 'graphql') {
console.info('not graphql', dataSource)
return ''
Expand All @@ -99,7 +100,7 @@ function queryToDataFile(dataSource) {
},
method: '${method}',
body: JSON.stringify({
query: \`${query}\`,
query: \`${queryStr}\`,
})
}
}).data)
Expand Down Expand Up @@ -146,11 +147,11 @@ export function renderComponent(component: Component, toHtml: () => string): str
const after = (ifEnd ?? '') + (forEnd ?? '')
// TODO: src, href, alt
return `${before
}<${tagName}
}<${tagName}
${attributes}${className ? ` class="${className}"` : ''}${style ? ` style="${style}"` : ''}
>${innerHtml
}</${tagName}>${after
}`
}</${tagName}>${after
}`
} else {
// Not a real component
// FIXME: understand why
Expand Down

0 comments on commit d1f9486

Please sign in to comment.