Skip to content

Commit

Permalink
[FIX] Alias Listing.
Browse files Browse the repository at this point in the history
  • Loading branch information
Seiger committed Jun 20, 2024
1 parent 0bbfd29 commit f7db5ed
Show file tree
Hide file tree
Showing 4 changed files with 31 additions and 12 deletions.
1 change: 1 addition & 0 deletions docs/_config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@ repo: https://github.com/Seiger/sMultisite
github_user: seiger
github_repo: sMultisite
# discord: https://community.discord.com
ko_fi: seigerkornelyuk

# If you have a logo, put here to include in meta tags
logo: assets/img/logo.svg
Expand Down
16 changes: 13 additions & 3 deletions docs/_includes/social-menu.html
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<nav aria-label="Social menu" class="hidden xl:flex w-50 h-10">
<div class="flex space-x-3 items-center w-full z-10 bg-white text-sky-500">
{% if site.repo %}
<a href="{{ site.repo }}" class="hover:text-sky-700 transition-colors">
<a href="{{site.repo}}" class="hover:text-sky-700 transition-colors">
<span class=sr-only>Github</span>
<svg role=img class=icon viewBox="0 0 24 24" style='width: 20px; height: 20px; ' fill=currentColor>
<g buffered-rendering=static>
Expand All @@ -11,7 +11,7 @@
</a>
{% endif %}
{% if site.twitter %}
<a href="https://twitter.com/{{ site.twitter }}" class="hover:text-sky-700 transition-colors">
<a href="https://twitter.com/{{site.twitter}}" class="hover:text-sky-700 transition-colors">
<span class=sr-only>Twitter</span>
<svg role=img class="" viewBox="0 0 24 24" style="pointer-events: none; width: 20px; height: 20px;" fill=currentColor>
<g buffered-rendering=static>
Expand All @@ -21,7 +21,7 @@
</a>
{% endif %}
{% if site.support %}
<a href="{{ site.support }}" class="hover:text-sky-700 transition-colors">
<a href="{{site.support}}" class="hover:text-sky-700 transition-colors">
<span class=sr-only>Support forum</span>
<svg role=img class=icon viewBox="0 0 24 24" style='width: 20px; height: 20px' fill=currentColor>
<g buffered-rendering=static>
Expand All @@ -30,5 +30,15 @@
</svg>
</a>
{% endif %}
{% if site.ko_fi %}
<a href="https://ko-fi.com/{{site.ko_fi}}" class="hover:text-sky-700 transition-colors">
<span class=sr-only>By Coffee</span>
<svg role=img class=icon viewBox="0 0 24 24" style='width: 20px; height: 20px' fill=currentColor>
<g buffered-rendering=static>
<path d="M23.881 8.948c-.773-4.085-4.859-4.593-4.859-4.593H.723c-.604 0-.679.798-.679.798s-.082 7.324-.022 11.822c.164 2.424 2.586 2.672 2.586 2.672s8.267-.023 11.966-.049c2.438-.426 2.683-2.566 2.658-3.734 4.352.24 7.422-2.831 6.649-6.916zm-11.062 3.511c-1.246 1.453-4.011 3.976-4.011 3.976s-.121.119-.31.023c-.076-.057-.108-.09-.108-.09-.443-.441-3.368-3.049-4.034-3.954-.709-.965-1.041-2.7-.091-3.71.951-1.01 3.005-1.086 4.363.407 0 0 1.565-1.782 3.468-.963 1.904.82 1.832 3.011.723 4.311zm6.173.478c-.928.116-1.682.028-1.682.028V7.284h1.77s1.971.551 1.971 2.638c0 1.913-.985 2.667-2.059 3.015z"/>
</g>
</svg>
</a>
{% endif %}
</div>
</nav>
4 changes: 4 additions & 0 deletions plugins/sMultisitePlugin.php
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,10 @@
evo()->setConfig('site_root', (int)$domain->resource);
}
}
$aliasListing = Cache::get('sMultisite-' . evo()->getConfig('site_key', 'default') . '-resources') ?? [];
if (is_array($aliasListing)) {
evo()->documentListing = $aliasListing;
}
});

/**
Expand Down
22 changes: 13 additions & 9 deletions src/sMultisite.php
Original file line number Diff line number Diff line change
Expand Up @@ -64,26 +64,30 @@ public function route(string $name): string
*/
public function domainsTree()
{
$domains = \Seiger\sMultisite\Models\sMultisite::all();
$domainIds = [];
$domainBaseIds = evo()->getChildIds(0, 1);
$domains = \Seiger\sMultisite\Models\sMultisite::all();
$multisiteResources = $domains->pluck('resource')->toArray();

if (count($multisiteResources)) {
$domainBaseIds = array_diff($domainBaseIds, $multisiteResources);
}
foreach ($domainBaseIds as $domainBaseId) {
$domainIds = array_merge($domainIds, evo()->getChildIds($domainBaseId));
}
Cache::forget('sMultisite-default-resources');
Cache::rememberForever('sMultisite-default-resources', function () use ($domainIds) {
return $domainIds;
});

if ($domains) {
foreach ($domains as $domain) {
$domainIds = evo()->getChildIds($domain->resource);
Cache::forget('sMultisite-' . $domain->key . '-resources');
Cache::rememberForever('sMultisite-' . $domain->key . '-resources', function () use ($domainIds) {
return $domainIds;
});
}
}

$domainDefaultIds = $domainBaseIds;
foreach ($domainBaseIds as $domainBaseId) {
$domainDefaultIds = array_merge($domainDefaultIds, evo()->getChildIds($domainBaseId));
}
Cache::rememberForever('sMultisite-default-resources', function () use ($domainDefaultIds) {
return $domainDefaultIds;
});
}
}

0 comments on commit f7db5ed

Please sign in to comment.