generated from 8fold/github-repo-template
-
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #77 from 8fold/sitemap
Sitemap
- Loading branch information
Showing
17 changed files
with
253 additions
and
11 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
APP_ENV={production|local|test} | ||
APP_URL={host with schema} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -10,3 +10,5 @@ yarn-error.log | |
.nova | ||
|
||
site-static-html/ | ||
|
||
!site-dynamic-php/public/.gitignore |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
.DS_Store | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
--- | ||
template: 'sitemap' | ||
--- |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
<?php | ||
|
||
declare(strict_types=1); | ||
|
||
namespace JoshBruce\Site\Documents; | ||
|
||
use Eightfold\XMLBuilder\Document; | ||
use Eightfold\XMLBuilder\Element; | ||
|
||
use JoshBruce\Site\FileSystem; | ||
use JoshBruce\Site\File; | ||
|
||
use JoshBruce\Site\Content\Markdown; | ||
|
||
class Sitemap | ||
{ | ||
public static function create(): string | ||
{ | ||
$finder = FileSystem::finder()->name('content.md')->sortByName() | ||
->notContains('redirect:') | ||
->notContains('noindex:'); | ||
|
||
$markdown = []; | ||
foreach ($finder as $file) { | ||
$markdown[] = Markdown::for( | ||
File::at($file->getPathname()) | ||
); | ||
} | ||
|
||
$urls = []; | ||
foreach ($markdown as $m) { | ||
$urls[] = Element::url( | ||
Element::loc($m->canonicalUrl()) | ||
); | ||
} | ||
|
||
return Document::urlset( | ||
...$urls | ||
)->props("xmlns http://www.sitemaps.org/schemas/sitemap/0.9")->build(); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
<?php | ||
|
||
declare(strict_types=1); | ||
|
||
use JoshBruce\Site\File; | ||
|
||
use JoshBruce\Site\FileSystem; | ||
|
||
test('can generate canonical URL', function() { | ||
expect( | ||
File::at(FileSystem::publicRoot() . '/content.md')->canonicalUrl() | ||
)->toBe( | ||
'https://joshbruce.com' | ||
); | ||
|
||
expect( | ||
File::at(FileSystem::publicRoot())->canonicalUrl() | ||
)->toBe( | ||
'https://joshbruce.com' | ||
); | ||
|
||
expect( | ||
File::at(FileSystem::publicRoot() . '/web-development')->canonicalUrl() | ||
)->toBe( | ||
'https://joshbruce.com/web-development' | ||
); | ||
|
||
expect( | ||
File::at(FileSystem::publicRoot() . '/web-development/content.md') | ||
->canonicalUrl() | ||
)->toBe( | ||
'https://joshbruce.com/web-development' | ||
); | ||
})->group('file'); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -29,4 +29,4 @@ | |
'Okay to fail in local.' | ||
)->toBeFalse(); | ||
} | ||
})->group('index', 'focus'); | ||
})->group('index'); |
Oops, something went wrong.