An open API service indexing awesome lists of open source software.

https://github.com/nath-green/nathan-green-photography

Basic theme for Anchor CMS using Tailwind
https://github.com/nath-green/nathan-green-photography

Last synced: 3 months ago
JSON representation

Basic theme for Anchor CMS using Tailwind

Awesome Lists containing this project

README

        

# Nathan Green Photography

Theme for Anchor CMS using Tailwind.

## Anchor CMS Installation

- Download the latest Anchor zip installation from [here]('https://anchorcms.com/download')
- Extract .zip file to subdirectory (for example: `/blog`)
- Create a database for Anchor to connect to (phpMyAdmin)
- Navigate to the new subdirectory to install Anchor
- Once installation is complete, delete the `install` folder
- Create a `.htaccess` file in the root of the subdirectory, this will remove the stray `/index.php/` in the url

```

RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^ index.php [L]

```

### Prep site for theme installation

- Update `/anchor/config/app.php`

Set `url` to empty string
Set `index` to empty string

- Create a new function in `/anchor/functions/users.php`

```
function user_custom_field($key, $default = '', $id = null) {
if ($id == null) {
$id = user_authed_id();
}

if ($extend = Extend::field('user', $key, $id)) {
return Extend::value($extend, $default);
}

return $default;
}
```

- Create new functions in `/anchor/functions/helpers.php`

```
function base_domain_url($append = '') {
return (isset($_SERVER['HTTPS']) && $_SERVER['HTTPS'] === 'on' ? "https" : "http") . "://" . $_SERVER['SERVER_NAME'] . $append;
}

function complete_url() {
return (isset($_SERVER['HTTPS']) && $_SERVER['HTTPS'] === 'on' ? "https" : "http") . "://$_SERVER[HTTP_HOST]$_SERVER[REQUEST_URI]";
}
```

- Add sitemap generator `Route` in `/anchor/routes/site.php`

**This has to be before the `View Pages` function**

Note: This will create a Sitemap dynamically when hitting the route, no physical file will be created.

```
/** * Sitemap */

Route::get('blog-sitemap.xml', function() { $sitemap = ''; $sitemap .= ' ';

// Main page
$sitemap .= '';
$sitemap .= '' . Uri::full(Registry::get('posts_page')->slug . '/') . '';
$sitemap .= '0.9';
$sitemap .= 'weekly';
$sitemap .= '';

while(categories()):
$sitemap .= '';
$sitemap .= '' . base_domain_url() . category_url() . '';
$sitemap .= 'monthly';
$sitemap .= '0.8';
$sitemap .= '';
endwhile;

$query = Post::where('status', '=', 'published')->sort(Base::table('posts.created'), 'desc');
foreach($query->get() as $article) {
$sitemap .= '';
$sitemap .= '' . Uri::full(Registry::get('posts_page')->slug . '/' . $article->slug) . '';
$sitemap .= '' . date("Y-m-d", strtotime($article->created)) .'';
$sitemap .= 'monthly';
$sitemap .= '0.8';
$sitemap .= '';
}
$sitemap .= '';

return Response::create($sitemap, 200, array('content-type' => 'application/xml'));
});
```

- Add site variables to Admin Panel in `Extend -> Site Variables`

- `blog_description`
- `blog_heading`
- `facebook_url`
- `instagram_url`

- Add custom fields to type `post`

**Hero Image**

| Key | Value |
| ---------- | ------------ |
| Type | `post` |
| Field | `image` |
| Unique key | `hero` |
| Label | `Hero Image` |

**Hero Image Alt Text**

| Key | Value |
| ---------- | --------------------- |
| Type | `post` |
| Field | `text` |
| Unique key | `image_alt` |
| Label | `Hero Image Alt Text` |

**OG Image**

| Key | Value |
| ---------- | ---------- |
| Type | `post` |
| Field | `image` |
| Unique key | `og_image` |
| Label | `OG Image` |

- Add custom fields to type `user`

**Avatar**

| Key | Value |
| ---------- | -------- |
| Type | `user` |
| Field | `image` |
| Unique key | `avatar` |
| Label | `Avatar` |

- Add custom fields to type `page`

**Meta Description**

| Key | Value |
| ---------- | ------------------ |
| Type | `page` |
| Field | `text` |
| Unique key | `meta_description` |
| Label | `Meta Description` |

**Meta Title**

| Key | Value |
| ---------- | ------------ |
| Type | `page` |
| Field | `text` |
| Unique key | `meta_title` |
| Label | `Meta Title` |

### Theme generation and installation

- Run `yarn prod`

This will generate a new `/dist` folder, these are your theme files.

- Copy/push the newly generated files into a folder within `/anchor/themes`

Note: the generated theme files need to be in a folder within `/themes`