Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Files aren't generated for extensions besides .md and .emu #16

Closed
dillonkearns opened this issue Oct 28, 2019 · 6 comments
Closed

Files aren't generated for extensions besides .md and .emu #16

dillonkearns opened this issue Oct 28, 2019 · 6 comments
Labels
bug Something isn't working

Comments

@dillonkearns
Copy link
Owner

The problem is that currently the extension is hardcoded for .md files here:

const content = glob.sync(contentGlobPath, {}).map(unpackMarkup);
const staticRoutes = generateRecords();
const markdownContent = glob
.sync("content/**/*.md", {})
.map(unpackFile)
.map(({ path, contents }) => {
return parseMarkdown(path, contents);
});
const images = glob
.sync("images/**/*", {})
.filter(imagePath => !fs.lstatSync(imagePath).isDirectory());
let app = Elm.Main.init({
flags: {
argv: process.argv,
versionMessage: version,
content,
markdownContent,
images

.emu files need special treatment so they can remain separate. Removing the hardcoded .md extension should fix the problem.

@dillonkearns dillonkearns added the bug Something isn't working label Oct 28, 2019
@dbj
Copy link

dbj commented Oct 31, 2019

This is really holding me back. I need to be able to parse different types of files. I'm using dillonkearns/elm-markdown and it does not parse HTML. I tried defining my own htmlDocument and it does not work:

main =
    Pages.application
        { init = init
        , view = view
        , update = update
        , subscriptions = subscriptions
        , documents = [ markdownDocument, htmlDocument ]
        , head = head
        , manifest = manifest
        , canonicalSiteUrl = canonicalSiteUrl
        }

htmlDocument =
    let
        res =
            \md ->
                case HP.run md of
                    Ok hp_nodes ->
                        Ok (H.div [] (HPU.toVirtualDom hp_nodes))

                    Err deadends ->
                        Ok (H.text (Parser.deadEndsToString deadends))
    in
    Pages.Document.parser
        { extension = "html"
        , metadata = Metadata.decoder
        , body = res
        }

@dillonkearns
Copy link
Owner Author

I'm doing my best to keep on top of these issues. There are a lot of people using elm-pages, and I'm working on a big new feature. And I'm getting married in less than a month, so it's crunch time. I'll do my best to work through the queue and push out some new changes, but please have patience as it's a super busy time for me.

@dbj
Copy link

dbj commented Oct 31, 2019 via email

@dillonkearns
Copy link
Owner Author

Thanks for understanding! I'm excited to hear that you're using it for your project, and definitely want to make it work for your needs!

And yeah, that's right I'm working on the StaticHttp functionality right now, which is actually getting pretty close to production-ready! Here's some (already working!) code to give you a sense of what it will look like:

airtableRequest : StaticHttp.Request (List Company)
airtableRequest =
StaticHttp.jsonRequestWithSecrets
(\secrets ->
secrets
|> Secrets.get "AIRTABLE_API_KEY"
|> Result.map
(\airtableApiKey ->
"https://api.airtable.com/v0/appNsAv2iE9mFm56N/Table%201?view=Approved&api_key=" ++ airtableApiKey
)
)
(Decode.field "records"
(Decode.list
(Decode.field "fields"
(Decode.map3 Company
(Decode.field "Company Name" Decode.string)
(Decode.field "Company Logo" (Decode.index 0 (Decode.field "url" Decode.string)))
(Decode.field "Significant lines of Elm code (in thousands)"
(Decode.index 0 Decode.string)
)
)
)
)
)
view :
List ( PagePath Pages.PathKey, Metadata )
->
{ path : PagePath Pages.PathKey
, frontmatter : Metadata
}
->
StaticHttp.Request
{ view : Model -> View -> { title : String, body : Html Msg }
, head : List (Head.Tag Pages.PathKey)
}
view siteMetadata page =
case page.frontmatter of
() ->
StaticHttp.map2
(\elmCompanies starCount ->
{ view =
\model viewForPage ->
{ title = "Landing Page"
, body =
(header starCount
:: (elmCompanies
|> List.map companyView
)
)
|> Element.column [ Element.width Element.fill ]
|> layout
}
, head = head page.frontmatter
}
)
airtableRequest
(StaticHttp.jsonRequest "https://api.github.com/repos/dillonkearns/elm-pages"
(Decode.field "stargazers_count" Decode.int)
)

I'm actually getting some help in a sort of closed beta round right now on it, and it's working really nicely. It skips GraphQL entirely, which I love because it reduces the number of extra abstractions... you just directly ask for the data in your Elm code, and it grabs it in the build step! I'm working on StaticHttp.andThen right now, which will allow for some really interesting possibilities. As you may have seen, I'm tracking that at https://github.com/dillonkearns/elm-pages/projects/1.

Thanks for your interest in the project! I appreciate the feedback, please keep it coming. I'll do my best to get out some of these features and fixes before I head out for the wedding 😄

@dbj
Copy link

dbj commented Nov 1, 2019

Nice! I love Airtable and was definitely going to be using it for one of my sources.

@dillonkearns
Copy link
Owner Author

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants