Skip to content

Commit

Permalink
Switching to use a custom route provider and scanning the routes.
Browse files Browse the repository at this point in the history
  • Loading branch information
Zoramite committed Jun 16, 2022
1 parent f3e3310 commit d7fd2a2
Show file tree
Hide file tree
Showing 8 changed files with 342 additions and 332 deletions.
16 changes: 13 additions & 3 deletions packages/amagaki-plugin-partial-library/example/amagaki.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,12 +13,22 @@ export default async (pod: Pod) => {
},
staticRoutes: [
{
path: `/static/`,
path: '/static/',
staticDir: '/dist/',
},
],
});


PartialLibraryPlugin.register(pod, {})
PartialLibraryPlugin.register(pod, {
parsing: {
partialDirectory: '/src/partials/',
partialsInSubDirectories: true,
},
partial: {
tracked: ['spacer'],
},
serving: {
template: '/views/library.njk',
},
});
};
24 changes: 13 additions & 11 deletions packages/amagaki-plugin-partial-library/example/views/base.njk
Original file line number Diff line number Diff line change
Expand Up @@ -9,15 +9,17 @@
<script src="{{pod.staticFile('/dist/js/main.js').url.path}}" defer></script>
<body>
<div class="main">
{% set partial = pod.doc('/content/partials/header.yaml').fields %}
{% include "/views/partials/header.njk" %}
{% if doc.fields.partials %}
{% asyncEach partial in doc.fields.partials %}
{% include "/views/partials/" ~ partial.partial ~ ".njk" %}
{% endeach %}
{% else %}
<div class="main__body">
{{doc.body|markdown|safe}}
</div>
{% endif %}
{% block main %}
{% set partial = pod.doc('/content/partials/header.yaml').fields %}
{% include "/views/partials/header.njk" %}
{% if doc.fields.partials %}
{% asyncEach partial in doc.fields.partials %}
{% include "/views/partials/" ~ partial.partial ~ ".njk" %}
{% endeach %}
{% else %}
<div class="main__body">
{{doc.body|markdown|safe}}
</div>
{% endif %}
{% endblock %}
</div>
42 changes: 42 additions & 0 deletions packages/amagaki-plugin-partial-library/example/views/library.njk
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
{% extends "/views/base.njk" %}

{% block main %}
<ul>
{% for key, partial in doc.fields.partials %}
<li><a href="{{ doc.fields.library.url.path }}{{key}}/">{{ key }}</a>: {{ partial.length }}</li>
{% endfor %}
</ul>
{% if doc.fields.partial %}
{% set trackedPartial = doc.fields.partials[doc.fields.partial] %}

<h2>{{ doc.fields.partial }}</h2>

<dl>
<dt>Instance count ({{trackedPartial.length}}) split by locale</dt>
{% for locale, localeLen in trackedPartial.lengthByLocale %}
<dd>{{locale}}: {{localeLen}}</dd>
{% endfor %}
</dl>

{% for partialInstance in trackedPartial.instances %}
{# Only show if we have the config. #}
{% if partialInstance.config %}
{% if loop.index > 1 %}
<hr>
{% endif %}

<div>
{% if partialInstance.urlPath %}
<a href="{{ partialInstance.urlPath }}">{{ partialInstance.urlPath }}</a>
{% endif %}
{% if partialInstance.locale %}
({{partialInstance.locale.id}})
{% endif %}
</div>

{% set partial = partialInstance.config %}
{% include "/views/partials/" ~ doc.fields.partial ~ ".njk" %}
{% endif %}
{% endfor %}
{% endif %}
{% endblock %}

This file was deleted.

Loading

0 comments on commit d7fd2a2

Please sign in to comment.