adding asset from blade

develop
HerrHase 2 years ago
parent 0720e3c583
commit d579d0a40f

@ -1,12 +1,11 @@
{% layout 'layout.liquid' %}
{{# layout('layout') }}
{% block siteHeader %}
<h1 class="site-header__title">
{{ page.data.title }}
</h1>
{% endblock %}
{% block siteMain %}
{{# section('content') { }}
<h1 class="site-header__title">
{{ page.data.title }}
</h1>
<div class="container">
<div class="grid">
<div class="col-12">
@ -18,4 +17,8 @@
</div>
</div>
</div>
{% endblock %}
{{# endsection }}
{{# push('footer') { }}
{{# } }}

@ -8,7 +8,7 @@
{{ it.page.data.title }} | {{ it.settings.data.project_name }}
</title>
<meta name="viewport" content="width=device-width, initial-scale=1">
<link href="/static/css/styles.css" rel="stylesheet" type="text/css">
<link href="{{ asset('/public/css/styles.css') }}" rel="stylesheet" type="text/css">
</head>
<body class="site-body {{ it.templateClass(it.page) }}">
<header class="site-header">

@ -63,9 +63,9 @@ mix.webpackConfig({
})
mix
.setPublicPath('../../')
.setPublicPath('../../public')
//.js('js/app.js', 'public/js')
.sass('scss/styles.scss', 'public/css')
.sass('scss/styles.scss', 'css')
.purgeCss({
extend: {
content: [

@ -117,7 +117,7 @@ import postHttp from './http/post.js'
// page and static has always the last routes, if no route before match, it try get a page
import sitemapHttp from './http/sitemap.js'
import pageHttp from './http/page.js'
import staticHttp from './http/static.js'
import publicHttp from './http/public.js'
server
.register(commentHttp, {
@ -129,6 +129,6 @@ server
})
.register(sitemapHttp)
.register(pageHttp)
.register(staticHttp)
.register(publicHttp)
export default server

@ -28,19 +28,6 @@ function asset($path, $prefix = '/public')
return $path;
}
/**
* getting name of view as slug
*
* @param array $page
* @return string
*
*/
function viewName(array $page)
{
$slugify = new \Cocur\Slugify\Slugify();
return $slugify->slugify($page['data']['view']);
}
/**
* getting name of view as slug
*
@ -86,27 +73,8 @@ function title($page, $site)
return join(' | ', $title);
}
/**
* getting url for assets of directus api
*
* @param string string
* @param array array
* @return string
*
*/
function assetsUrl(string $id, array $options = NULL)
{
$query = NULL;
if ($options) {
$query = '?'.http_build_query($options);
}
return $_ENV['DIRECTUS_API_URL'].'/assets/'.$id.$query;
}
function styles($values) {
$result = '';
if ($values && is_array($values)) {

@ -1,6 +1,10 @@
import slugify from 'slugify'
import { marked } from 'marked'
import * as fs from 'fs'
import path from 'path'
const basePath = path.join(path.resolve(), '/../../')
/**
* etaHelpers
@ -11,30 +15,32 @@ import * as fs from 'fs'
*/
/**
* asset -
* asset - checks manifest.json for given path and return
* file path with id for cache busting
*
* @param {String} path
* @param {String} [prefix='/public']
*
* @param {String} publicPath
*
*/
function asset(path, prefix = '/public')
function asset(publicPath)
{
// getting basePath
const basePath = path
let result = publicPath
// path to mix-manifest
file = basePath + 'mix-manifest.json';
const file = basePath + 'mix-manifest.json'
if (fs.existsSync(file)) {
if (!fs.existsSync(file)) {
//const manifest = file_get_contents($file);
//const files = json_decode(manifest, true);
const manifest = fs.readFileSync(file)
const files = JSON.parse(manifest)
//if (files[prefix + path]) {
// path = str_replace(prefix, '', files[prefix + path]);
//}
if (files[publicPath]) {
result = files[publicPath]
}
}
return path
return result
}
/**
@ -98,4 +104,23 @@ async function injectStore(name) {
return store
}
/**
* getting url for assets of directus api
*
* @param string string
* @param array array
* @return string
*
*/
function fileUrl(id, options = NULL)
{
$query = NULL;
if (options) {
$query = '?'.http_build_query($options);
}
return process.ENV.DIRECTUS_API_URL + '/assets/' + id + $query;
}
export { asset, templateClass, isHome, injectStore }

@ -18,7 +18,7 @@ export default async function(fastify, opts) {
*/
fastify.register(fastifyStatic, {
root: path.join(path.resolve(), '/../../public'),
prefix: '/static',
prefix: '/public',
preCompressed: true
})

@ -3,6 +3,9 @@ import DirectusAbstractStore from './directusAbstract.js'
/**
* Comments
*
* @author Björn Hase <me@herr-hase.wtf>
* @license http://opensource.org/licenses/MIT The MIT License
* @link https://gitea.node001.net/HerrHase/super-fastify-directus.git
*
*/
@ -11,7 +14,7 @@ class CommentStore extends DirectusAbstractStore {
/**
*
*
* @param {string} endpoint
* @param {String} endpoint
*
*/
constructor() {
@ -21,8 +24,9 @@ class CommentStore extends DirectusAbstractStore {
/**
* getting page by permalink
*
* @param {string} permalink
* @return {object}
* @param {String} permalink
* @return {Object}
*
*/
find(page, uuid, limit = 20) {
return this.items.readByQuery({
@ -43,6 +47,32 @@ class CommentStore extends DirectusAbstractStore {
})
}
/**
* getting page by permalink
*
* @param {String} permalink
* @return {Object}
*
*/
page(page, uuid, limit = 20) {
return this.items.readByQuery({
fields: [
'name',
'content',
'approved',
'belongs_to.comments_id'
],
filter: {
approved : true,
belongs_to : {
comments_id: uuid
}
},
limit : limit,
offset : ((page - 1) * limit)
})
}
}
export default CommentStore

@ -3,7 +3,10 @@ import { Directus } from '@directus/sdk';
/**
* Abstract Class for handling Directus Api
*
*
* @author Björn Hase <me@herr-hase.wtf>
* @license http://opensource.org/licenses/MIT The MIT License
* @link https://gitea.node001.net/HerrHase/super-fastify-directus.git
*
*/
class DirectusAbstractStore {

@ -3,7 +3,10 @@ import DirectusAbstractStore from './directusAbstract.js'
/**
* Pages from Directus
*
*
* @author Björn Hase <me@herr-hase.wtf>
* @license http://opensource.org/licenses/MIT The MIT License
* @link https://gitea.node001.net/HerrHase/super-fastify-directus.git
*
*/
class PageStore extends DirectusAbstractStore {

Loading…
Cancel
Save